Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor...

32
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

Transcript of Linear Programming - Technical University of Denmark · Linear Programming – the simple Wyndor...

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

2Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

OutlineAbbreviations

LP parts:Decision variablesObjective functionConstraints

Wyndor glass

Wyndor model in Excel

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

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

5Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

A Linear Program

MAX 300x + 500y

5Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

A Linear Program

MAX 300x + 500y

ST :

x ≤ 4

2y ≤ 12

3x + 2y ≤ 18

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

6Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Graphicallyy

x

8

6

4

2

2 864

Only positive

6Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Graphicallyy

x

8

6

4

2

2 86

y <= 6

4

2y ≤ 12

6Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Graphically

y <= 6

y

x

8

6

4

2

2 8

x <= 4

64

x ≤ 4

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

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

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

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.

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 ?

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)

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.

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.

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

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

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

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

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

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

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.

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 ....

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

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).

17Thomas Stidsen

Informatics and Mathematical Modelling / Operations Research

Hence: Switch to Excel

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

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 ....

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