Top Banner
1 Thomas Stidsen Informatics and Mathematical Modelling / Operations Research Linear Programming – the simple Wyndor Glass example Thomas Stidsen [email protected] Informatics and Mathematical Modeling Technical University of Denmark
32

Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen [email protected] Informatics and Mathematical Modeling

Oct 17, 2018

Download

Documents

lydat
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

1Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Linear Programming– the simple Wyndor Glass example

Thomas Stidsen

[email protected]

Informatics and Mathematical Modeling

Technical University of Denmark

Page 2: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

2Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

OutlineAbbreviations

LP parts:Decision variablesObjective functionConstraints

Wyndor glass

Wyndor model in Excel

Page 3: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

3Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

AbbreviationsLP: Linear Programming

ILP: Integer Linear Programming

Solver: An algorithm/a program which finds theoptimal solution to LP/ILP problems

Decision variables: An un-decided decisionwhich is left to the solver

Objective function: A function specifying thecost of a certain setting of the decision variables

Constraint set: A set of equations limiting thepossible values of the decision variables

Page 4: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

4Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

The Basic LPThe basic LP model/formulation contains 3 differentelements:

(Decision) Variables

(Linear) Objective function

A set of (linear) constraints

Page 5: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

5Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

A Linear Program

MAX 300x + 500y

Page 6: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

5Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

A Linear Program

MAX 300x + 500y

ST :

x ≤ 4

2y ≤ 12

3x + 2y ≤ 18

Page 7: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

5Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

A Linear Program

MAX 300x + 500y

ST :

x ≤ 4

2y ≤ 12

3x + 2y ≤ 18

x ≥ 0

y ≥ 0

Page 8: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

6Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Graphicallyy

x

8

6

4

2

2 864

Only positive

Page 9: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

6Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Graphicallyy

x

8

6

4

2

2 86

y <= 6

4

2y ≤ 12

Page 10: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

6Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Graphically

y <= 6

y

x

8

6

4

2

2 8

x <= 4

64

x ≤ 4

Page 11: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

6Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Graphically

4 6 82

2

4

6

8

x

y

y <= 6

x <= 4

3x + 2y <= 18

3x + 2y ≤ 18

Page 12: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

6Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Graphically

4 6 82

2

4

6

8

x

y

y <= 6

x <= 4

3x + 2y <= 18

f(x)=300x+500y

f(x) = 300x + 500y

Page 13: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

6Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Graphically

4 6 82

2

4

6

8

x

y

y <= 6

x <= 4

3x + 2y <= 18

Maximisation

f(x)=300x+500y

Maximal point: x = 2 and y = 6

Page 14: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

7Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

ModellingWhat does this have to do with the real world ?

LP models are extremely usefull

Modelling is the proces of formulating amahtematical model for the problem.

Lets look at a simple problem, the Wyndor glass

problem, from the book “Introduction to Operations

Research”, by Hillier & Liberman.

Page 15: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

8Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Wyndor Glass: Profit maximationWyndor glass is a compagny producing different

kinds of windows and (window) doors. They are

considering two new types of products, a new alu-

minium door and wooden window. The question is

now: Which mix of products should be produced,

limited by the capacity of the production lines such

that the profit is maximized ?

Page 16: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

9Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Wyndor Glass: The production linesWyndor glass have three types of production lines:

A production line for aluminium frames, (4production hours available)

A production line for wood frames, (12production hours available)

An assembly line, (18 production hoursavailable)

Page 17: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

10Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Door productionEach batch of doors requires:

1 hour of work on the aluminium framing line

3 hours of work on the assembling line

Each batch of doors can be sold for 300 $’s.

Page 18: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

11Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Door & Window productionEach batch of windows requires:

2 hours of work on the wood framing line

2 hours of work on the assembling line

Each batch of windows can be sold for 500 $’s.

Page 19: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

12Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Modelling: How ?Given a problem we should ask the followingquestions:

What should we decide ?

The ammount of production of Doors andWindows

What are the limits on the produktion plans ?Do not overuse the production capacity andonly allow positive production.

What is the goal ?Maximize the profit: 300D + 500W

Page 20: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

12Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Modelling: How ?Given a problem we should ask the followingquestions:

What should we decide ?The ammount of production of Doors andWindows

What are the limits on the produktion plans ?Do not overuse the production capacity andonly allow positive production.

What is the goal ?Maximize the profit: 300D + 500W

Page 21: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

12Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Modelling: How ?Given a problem we should ask the followingquestions:

What should we decide ?The ammount of production of Doors andWindows

What are the limits on the produktion plans ?

Do not overuse the production capacity andonly allow positive production.

What is the goal ?Maximize the profit: 300D + 500W

Page 22: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

12Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Modelling: How ?Given a problem we should ask the followingquestions:

What should we decide ?The ammount of production of Doors andWindows

What are the limits on the produktion plans ?Do not overuse the production capacity andonly allow positive production.

What is the goal ?Maximize the profit: 300D + 500W

Page 23: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

12Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Modelling: How ?Given a problem we should ask the followingquestions:

What should we decide ?The ammount of production of Doors andWindows

What are the limits on the produktion plans ?Do not overuse the production capacity andonly allow positive production.

What is the goal ?

Maximize the profit: 300D + 500W

Page 24: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

12Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Modelling: How ?Given a problem we should ask the followingquestions:

What should we decide ?The ammount of production of Doors andWindows

What are the limits on the produktion plans ?Do not overuse the production capacity andonly allow positive production.

What is the goal ?Maximize the profit: 300D + 500W

Page 25: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

13Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

A LP modelWe decide:

The production (in batches) is defined by twodecision variables: D (Doors) and W(Windows)

The profit is calculated as a linear function:profit = 300 ·D + 500 ·W

The limited capacity of each line is modelled asa constraint.

Page 26: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

14Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

The LP model

MAX 300D + 500W

ST :

D ≤ 4

2W ≤ 12

3D + 2W ≤ 18

D ≥ 0

W ≥ 0

Hmmm, this looks familiar ....

Page 27: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

15Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Graphical view

4 6 82

2

4

6

8

x

y

y <= 6

x <= 4

3x + 2y <= 18

Maximisation

f(x)=300x+500y

Page 28: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

16Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Now what ?Ok, having a model is all very nice, but it does notearn us any money !

Finding optimal solutions is not trivial in morethan 2 dimensions ...

... and we would like the computer do do thework for us ...

This is where Excel comes in: We can translate our

above model into a linear model in Excel and the

built in solver will find the optimal solution (but of

course we already know it: D = 2 and W = 6).

Page 29: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

17Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Hence: Switch to Excel

Page 30: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

18Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Excel in GbarWe have access to Excel in the DTU databar in thefollowing way:

Login to the databar

Start windows: win desk

Log into Excel again (same login name andpassword)

Choose Excel from the start button

Page 31: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

19Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Excel in Gbar IIAdd solver login (unfortunately this is necessaryafter every Excel start up ...)

Tools drop down menuChoose add in’sChoose solver add inSelect ok

Load your favorite Excel model ....

Page 32: Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor Glass example Thomas Stidsen tks@imm.dtu.dk Informatics and Mathematical Modeling

20Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Implementing the first Wyndor modelLoad the data (or write it from scratch)

Establish the “constraint result cells”, usingsumproduct for each constraint

Establish the result cell (again sumproduct)

Enter the solverSelect the cellAdd the constraintsSet options (assume linear anndnon-negative)Say ok