02.1 Chapter2 Solving Linear Programs.pdf

24
Simplex Method George Dantzig (FEUP | DEGI) Operations Research March 3, 2014 1 / 24

Transcript of 02.1 Chapter2 Solving Linear Programs.pdf

Page 1: 02.1 Chapter2 Solving Linear Programs.pdf

Simplex Method

George Dantzig

(FEUP | DEGI) Operations Research March 3, 2014 1 / 24

Page 2: 02.1 Chapter2 Solving Linear Programs.pdf

Simplex Method – Learning Objectives I

Ability to transform any linear program to a canonical form:

with nonnegative variablesby replacing each decision variable unconstrained in sign by a difference between two nonnegative variables. This

replacement applies to all equations including the objective function.

with equality constraintsby changing inequalities to equalities by the introduction of slack and surplus variables.

by multiplying equations with a negative righthand side coefficient by -1.

with one basic variable isolated in each constraintby adding a (nonnegative) artificial variable to any equation that does not have an isolated variable readily apparent, andconstruct the BIG M objective function.

Ability to use the Simplex Method in “tableau form” to solve a linear program represented in theCanonical Form, i.e.:

Ability to determine the starting point to initiate the simplex method.

Ability to write the linear program in “tableau form”.

Ability to use the improvement mechanism for moving from a point to another point with abetter value of the objective function.Improvement CriterionIn a maximization (minimization) problem, choose the nonbasic variable that has the most positive (negative) coefficient inthe objective function of a canonical form.If that variable has a positive coefficient in some constraint, then a new basic feasible solution may be obtained by pivoting.Ratio and Pivoting Criterion

When improving a given canonical form by introducing variable xs into the basis, pivot in a constraint that gives the

minimum ratio of righthand-side coefficient to the corresponding xs coefficient. Compute these ratios only for constraints

that have a positive coefficient for xs .

(FEUP | DEGI) Operations Research March 3, 2014 2 / 24

Page 3: 02.1 Chapter2 Solving Linear Programs.pdf

Simplex Method – Learning Objectives II

Ability to detect termination criteria to indicate when a solution has been obtained bydemonstrating that:

there is no feasible solution;

the solution is optimal;

there is more than one optimal solution;

the objective function is unbounded over the feasible region.

(FEUP | DEGI) Operations Research March 3, 2014 3 / 24

Page 4: 02.1 Chapter2 Solving Linear Programs.pdf

http://www.cccblog.org/2012/08/20/the-algorithm-that-runs-the-world/

(FEUP | DEGI) Operations Research March 3, 2014 4 / 24

Page 5: 02.1 Chapter2 Solving Linear Programs.pdf

The method proceeds bymoving from one feasible so-lution to another, at each stepimproving the value of theobjective function and termi-nates after a finite number ofsuch transitions.

http://en.wikipedia.org/wiki/File:Simplex-method-3-dimensions.png

(FEUP | DEGI) Operations Research March 3, 2014 5 / 24

Page 6: 02.1 Chapter2 Solving Linear Programs.pdf

Simplex method: A systematic procedure for solving linearprograms

Two important characteristics of the simplex method:

The method is robust it solves any linear program;it detects redundant constraints in the problem formulation;it identifies instances when the objective value is unbounded overthe feasible region;it solves problems with one or more optimal solutions;the method is also self-initiating: it uses itself either to generatean appropriate feasible solution, as required, to start the method,or to show that the problem has no feasible solution.

The method provides much more than just optimal solutions. .

it indicates how the optimal solution varies as a function of theproblem data (cost coefficients, constraint coefficients, andrighthand-side data).it gives information intimately related with a linear program calledthe dual of the given problem: the simplex method automaticallysolves this dual problem along with the given problem.

(FEUP | DEGI) Operations Research March 3, 2014 6 / 24

Page 7: 02.1 Chapter2 Solving Linear Programs.pdf

The canonical form

Objective:max 0x1 +0x2 −3x3 −x4 +20Subject to:

1x1 +0x2 −3x3 +3x4 = 60x1 +1x2 −8x3 +4x4 = 4x1, x2, x3, x4 ≥ 0

(FEUP | DEGI) Operations Research March 3, 2014 7 / 24

Page 8: 02.1 Chapter2 Solving Linear Programs.pdf

The canonical form – Unbounded objective value

Objective:max 0x1 +0x2 +3x3 −x4 +20Subject to:

1x1 +0x2 −3x3 +3x4 = 60x1 +1x2 −8x3 +4x4 = 4x1, x2, x3, x4 ≥ 0

(FEUP | DEGI) Operations Research March 3, 2014 8 / 24

Page 9: 02.1 Chapter2 Solving Linear Programs.pdf

The canonical form – Improving a nonoptimal solution

Objective:max 0x1 +0x2 −3x3 +x4 +20Subject to:

1x1 +0x2 −3x3 +3x4 = 60x1 +1x2 −8x3 +4x4 = 4x1, x2, x3, x4 ≥ 0

Objective:max 0x1 + 1

4x2 −x3 +0x4 +21

Subject to:1x1 − 3

4x2 3x3 +0x4 = 3

0x1 + 14

x2 −2x3 +1x4 = 1x1, x2, x3, x4 ≥ 0

(FEUP | DEGI) Operations Research March 3, 2014 9 / 24

Page 10: 02.1 Chapter2 Solving Linear Programs.pdf

Production Planning at BALinear Programming Model

Objective:

max Z = 50xVP + 60xA

Subject to:

50xVP + 30xA ≤ 2000 (time in the oven)

6xVP + 5xA ≤ 300 (space in the warehouse)

3xVP + 5xA ≤ 200 (capacity in the decoration sector)

xVP , xA ≥ 0

Adding slack variables s1, s2 and s3:

Objective:max 50xVP + 60xA

Subject to:50xVP +30xA +s1 = 2000

6xVP +5xA +s2 = 3003xVP +5xA +s3 = 200xVP , xA, s1, s2, s3 ≥ 0

(FEUP | DEGI) Operations Research March 3, 2014 10 / 24

Page 11: 02.1 Chapter2 Solving Linear Programs.pdf

Objective:max Z = 50xVP + 60xA

Subject to:50xVP +30xA +s1 = 2000

6xVP +5xA +s2 = 3003xVP +5xA +s3 = 200xVP , xA, s1, s2, s3 ≥ 0

Basic (admissible) solution:

Non-basic variables:

{xVP = 0xA = 0

Basic variables:

s1 = 2000s2 = 300s3 = 200

Z = 0

0

10

20

30

40

50

60

70

80

0 10 20 30 40 50 60 70 80

50XVP + 30XA = 2000

Z = 50XVP + 60XA

3XVP + 5XA = 200

6XVP + 5XA = 300

XA

XVP

Objective: maximize Z ; choose the variablewith the most positive coeficient in theobjective function: xA

s3 is the first variable that turns zero whenxA grows.

xA grows from 0 until 40, a value such thats3 = 0; s1 and s2 remain ≥ 0

(FEUP | DEGI) Operations Research March 3, 2014 11 / 24

Page 12: 02.1 Chapter2 Solving Linear Programs.pdf

Objective:max Z = 50xVP +60xA

= 50xVP +60(40− 35 xVP − 1

5 s3)= 2400 +14xVP −12s3

Subject to:32xVP +s1 −6s3 = 800

3xVP +s2 −s3 = 10035 xVP +xA + 1

5 s3 = 40xVP , xA, s1, s2, s3 ≥ 0

Basic (admissible) solution:

Non-basic variables:

{xVP = 0s3 = 0

Basic variables:

s1 = 800s2 = 100xA = 40

Z = 2400

0

10

20

30

40

50

60

70

80

0 10 20 30 40 50 60 70 80

50XVP + 30XA = 2000

Z = 50XVP + 60XA

3XVP + 5XA = 200

6XVP + 5XA = 300

XA

XVP

Objective: maximize Z ; choose the variablewith maximum coeficient in the objectivefunction: xVP

s1 is the first variable that turns zero whenxVP grows.

xVP grows from 0 until 25, a value such thats1 = 0; xA and s2 remain ≥ 0

(FEUP | DEGI) Operations Research March 3, 2014 12 / 24

Page 13: 02.1 Chapter2 Solving Linear Programs.pdf

Objective:max Z = 2400 +14xVP −12s3

= 2400 +14(25− 132 s1 + 3

16 s3) −12s3

= 2750 − 716 s1 − 75

8 s3

Subject to:xVP + 1

32 s1 − 316 s3 = 25

− 332 s1 +s2 − 5

16 s3 = 25

+xA − 3160 s1 − 71

80 s3 = 25xVP, xA, s1, s2, s3 ≥ 0

Basic (admissible) solution:

Non-basic variables:

{s∗1 = 0s∗3 = 0

Basic variables:

x∗VP = 25s∗2 = 25x∗A = 25

Z∗ = 2750

0

10

20

30

40

50

60

70

80

0 10 20 30 40 50 60 70 80

50XVP + 30XA = 2000

Z = 50XVP + 60XA

3XVP + 5XA = 200

6XVP + 5XA = 300

XA

XVP

This solution is optimal because an increasein s1 or s3 ⇒ reduction of Z .

(FEUP | DEGI) Operations Research March 3, 2014 13 / 24

Page 14: 02.1 Chapter2 Solving Linear Programs.pdf

Simplex MethodSteps of the algorithm

Initial Basic Admissible Solution (BAS) :Obtain an initial Basic Admissible Solution (BAS).

Optimality Test 1

Maximization – if all the marginal costs are negative then the solution is optimal;Minimization – if all the marginal costs are positive then the solution is optimal.If the BAS is not optimal then ITERATE.

ITERATE :1 Choose the variable that enters the basis:2

Maximization – the non-basic variable with the most positive marginal cost.Minimization – the non-basic variable with the most negative marginal cost.

2 Choose the variable that leaves the basis:

divide the RHS of all the equations by the positive coefficients of the variable that willenter the basis;the variable that will leave the basis will be the basic variable of the equation with thelowest ratio;if all the coefficients of the variable that will enter the basis are negative or zero thenthe solution is non-limited.

3 Change the lines in the tableau in order to obtain coeficient equal to one for the“pivot” element and zero for all the other elements of the column, including theobjective function.

4 Go To Optimality Test1There are alternative optimal solutions when, in the optimal solution, one non-basic variable has a zero marginal

cost.2If there is more than one variable that fulfills the criterion choose one arbitrarilly.

(FEUP | DEGI) Operations Research March 3, 2014 14 / 24

Page 15: 02.1 Chapter2 Solving Linear Programs.pdf

Production Planning at BASimplex method

Objective:max Z = 50xVP + 60xA

Subject to:50xVP + 30xA ≤ 2000

6xVP + 5xA ≤ 3003xVP + 5xA ≤ 200

xVP , xA ≥ 0

Objective:max Z = 50xVP + 60xA

Subject to:50xVP + 30xA+ s1 = 2000

6xVP + 5xA+ s2 = 3003xVP + 5xA+ s3 = 200

xVP , xA, s1, s2, s3 ≥ 0

(FEUP | DEGI) Operations Research March 3, 2014 15 / 24

Page 16: 02.1 Chapter2 Solving Linear Programs.pdf

xVP xA s1 s2 s3

s1 50 30 1 0 0 2000s2 6 5 0 1 0 300

⇔ s3 3 5 0 0 1 200

−Z 50 60 0 0 0 0�

xA enters the basis becausemax(50, 60) = 60

s3 leaves the basis becausemin( 2000

30, 300

5, 200

5) = 200

5

xVP xA s1 s2 s3

⇔ s1160

50 1 0 − 30

5800

s2 3 0 0 1 −1 100xA

35

1 0 0 15

40

−Z 14 0 0 0 −12 −2400�

xVP enters the basis becausemax(14) = 14

s1 leaves the basis becausemin( 800

1505

, 1003, 40

35

) = 800150

5

xVP xA s1 s2 s3

xVP 1 0 5160

0 − 316

25

s2 0 0 − 15160

1 − 716

25

xA 0 1 − 3160

0 516

25

−Z 0 0 − 716

0 − 758−2750

All the coefficients of the objectivefunction are ≤ 0.Optimal solution:(xVP , xA)∗ = (25, 25) and Z∗ =2750What does s2 = 25 mean?

(FEUP | DEGI) Operations Research March 3, 2014 16 / 24

Page 17: 02.1 Chapter2 Solving Linear Programs.pdf

Finding an initial Basic Admissible Solution (BAS)

An important condition for the Simplex method is the availability of an initial BasicAdmissible Solution in the canonical form.

Sometimes this initial BAS is not evident or it may evn not exist (and sometimes there is noBasic Admissible Solution!).

Solutions:Trial and error – solve the system for different sets of variables, reduce it to the canonical form andtest if the resulting solution is admissible.Using artificial variables.

(FEUP | DEGI) Operations Research March 3, 2014 17 / 24

Page 18: 02.1 Chapter2 Solving Linear Programs.pdf

Using artificial variables

1. Convert the LP problem to a normalized form.

max∑n

j=1 cj xj

Subject to:

n∑j=1

aij xj = bi ∀i∈{1,...,m}

xj ≥ 0 ∀j∈{1,...,n}

2. Examine each constraint and verify if there issome variable that can be basic for that constraint.If it does not exist, then sum an artificial variableyi , yi ≥ 0.

Obs: The articial variables do not have any meaning in theoriginal problem, that is why they are called artificial. Theyare only used to built an initial basis for the problem.

max∑n

j=1 cj xj

Subject to:

n∑j=1

aij xj = bi ∀i∈{1,...,k}

n∑j=1

aij xj + yi = bi ∀i∈{k+1,...,m}

xj ≥ 0 ∀j∈{1,...,n}

yi ≥ 0 ∀i∈{k+1,...,m}

3. The “artificial” problem will only be equivalent to the original one if all the artificial variables have value zero.

Objective: All the artificial variables must leave the basis. “Big M” method.

(FEUP | DEGI) Operations Research March 3, 2014 18 / 24

Page 19: 02.1 Chapter2 Solving Linear Programs.pdf

“Big M” method

Assign a very high cost (M) – (minimization problem) in the objective function to the artificialvariables .The simplex method will take care, by improving the objective function, to expel the arficicialvariables from the basis ↔ artificial variables equal to zero.

min∑n

j=1 cj xj +∑m

i=k+1 Myi

Subject to:

n∑j=1

aij xj = bi ∀i∈{1,...,k}

n∑j=1

aij xj + yi = bi ∀i∈{k+1,...,m}

xj ≥ 0 ∀j∈{1,...,n}

yi ≥ 0 ∀i∈{k+1,...,m}

(FEUP | DEGI) Operations Research March 3, 2014 19 / 24

Page 20: 02.1 Chapter2 Solving Linear Programs.pdf

Big M methodexample

Objective:min Z = −3x1 + x2 + x3

Subject to:x1 − 2x2 + x3 ≤ 11

−4x1 + x2 + 2x3 ≥ 3−2x1 + x3 = 1

x1 , x2 , x3 ≥ 0

Objective:min Z = −3x1 + x2 + x3

Subject to:x1 − 2x2 + x3 + s1 = 11

−4x1 + x2 + 2x3 − s2 = 3−2x1 + x3 = 1

x1 , x2 , x3 , s1 , s2 ≥ 0

(FEUP | DEGI) Operations Research March 3, 2014 20 / 24

Page 21: 02.1 Chapter2 Solving Linear Programs.pdf

Objective:min Z = −3x1 + x2 + x3 + My1 + My2

Subject to:x1 − 2x2 + x3 + s1 = 11

−4x1 + x2 + 2x3 − s2 + y1 = 3−2x1 + x3 + y2 = 1

x1 , x2 , x3 , s1 , s2 , y1 , y2 ≥ 0

Z = −3x1 + x2 + x3 + M(3 + 4x1 − x2 − 2x3 + s2) + M(1 + 2x1 − x3)

= 4M + (−3 + 6M)x1 + (1−M)x2 + (1− 3M)x3 + Ms2

(FEUP | DEGI) Operations Research March 3, 2014 21 / 24

Page 22: 02.1 Chapter2 Solving Linear Programs.pdf

x1 x2 x3 s1 s2 y1 y2

s1 1 −2 1 1 0 0 0 11y1 −4 1 2 0 −1 1 0 3

⇔ y2 −2 0 1 0 0 0 1 1

−Z −3 1 1 0 0 0 0 06M −M −3M 0 M 0 0 −4M

x1 x2 x3 s1 s2 y1 y2

s1 3 −2 0 1 0 0 −1 10

⇔ y1 0 1 0 0 −1 1 −2 1x3 −2 0 1 0 0 0 1 1−Z −1 1 0 0 0 0 −1 −1

0 −M 0 0 M 0 3M −M�

(FEUP | DEGI) Operations Research March 3, 2014 22 / 24

Page 23: 02.1 Chapter2 Solving Linear Programs.pdf

x1 x2 x3 s1 s2 y1 y2

⇔ s1 3 0 0 1 −2 2 −5 12x2 0 1 0 0 −1 1 −2 1x3 −2 0 1 0 0 0 1 1−Z −1 0 0 0 1 −1 +1 −2

0 0 0 0 0 M M 0�

x1 x2 x3 s1 s2

x1 1 0 0 13− 2

34

x2 0 1 0 0 −1 1x3 0 0 1 2

3− 4

39

−Z 0 0 0 13

13

2

Optimal solution: (x1, x2, x3, s1, s2)? = (4, 1, 9, 0, 0) with Z? = −2

(FEUP | DEGI) Operations Research March 3, 2014 23 / 24

Page 24: 02.1 Chapter2 Solving Linear Programs.pdf

Some remarks

The artificial variables are only used to serve as basic variables in a given equation. Once replacedin the base by the original variables, the artificial variables can be eliminated from the simplextableau (eliminating the respective columns).

If, in the optimal simplex tableau, some artificial variables have a value > 0, it means that theoriginal problem has no admissible solution, and therefore it is an impossible problem.

(FEUP | DEGI) Operations Research March 3, 2014 24 / 24