1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by...

34
1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at the Fuqua School of Business MIT and James Orlin © 2003

Transcript of 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by...

Page 1: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

1MIT and James Orlin © 2003 1

Simplex Method Continued …

file Simplex2_AMII_05b_gr

Rev. 2.71 by M. Miccio on December 15, 2014

from a presentation at the Fuqua School of BusinessMIT and James Orlin

© 2003

Page 2: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

2MIT and James Orlin © 2003 2

Today’s Lecture

Review of the simplex algorithm Alternative Optimal Solutions Unbounded Solution Degeneracy Is the simplex algorithm finite? (Answer, yes,

but only if we are careful)

Page 3: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

3MIT and James Orlin © 2003 3

Today’s Lecture

Review of the simplex algorithm Alternative Optimal Solutions Unbounded Solution Degeneracy Is the simplex algorithm finite? (Answer, yes,

but only if we are careful)

Page 4: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

4MIT and James Orlin © 2003 4

Review of the Notation

n number of variables m number of constraints c index of entering variable r index of pivot row

– note: the rth basic variable leaves the basis

The original data is cj, aij, bi

After performing pivots we represent the revised coefficients as cj, aij, bi

The bar − indicates that it is the coefficient after some pivots

Page 5: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

5MIT and James Orlin © 2003 5

Tableau

x1 x2 xm+1xm

1 0

10

-z

0

0

xr xn

0 a1,m+1

a2,m+10

0

0

a1,n

a2,n

b1

b2

=

=

xs

a1,s

a2,s

000 ar,m+101 ar,n br=ar,s

000 am,m+110 am,n bm=am,s0

001 cm+100 cn -z0=cs0

CV

m constraints, n variables

Basic Variables Non-basic Variables

. . . . .

. . . . .

Page 6: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

6MIT and James Orlin © 2003 6

The basic feasible solution The current values are all non-negative.

– This is needed for canonical form

There is a basic variable associated with each constraint.– in this Tableau, the basic variable associated with

constraint i is xi.

There are (n-m) nonbasic variables.– In this Tableau, the nonbasic variables are

xm+1, … xn.

This bfs is as follows: x1 =b1, … , xm =bm. All other variables are 0.

Page 7: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

7MIT and James Orlin © 2003 7

Today’s Lecture

Review of the simplex algorithm. Alternative Optimal Solutions Unbounded Solution Degeneracy Degenerate Solutions Proving finiteness and optimality under no

degeneracy

Page 8: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

8MIT and James Orlin © 2003 8

1 3 1 0

-1 2 0 1

Alternative Optima (maximization)Initial Tableau

=

= 2

6

x2 x4x3

0 -4 00

-z

0

0

1 = -8

This basic feasible solution is optimal! Is there another optimal solution?

Suppose that x1 entered the basis. What would leave?

x1

z = 0x1 -4x2 + 8 max!

How much can x1 be increased?

Page 9: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

9MIT and James Orlin © 2003 9

1 3 1 0

-1 2 0 1

Alternative Optima (maximization)Initial Tableau

=

= 2

6

x2 x4x3

0 -4 00

-z

0

0

1 = -8

x1

Use the min ratio rule to select the pivot row and to determine which variable leaves the basis.

c1 c2

Page 10: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

10MIT and James Orlin © 2003 10

1 3 1 0

-1 2 0 1

Alternative Optima (maximization)Tableau No.1

=

= 2

6

x2 x4x3

0 -4 00

-z

0

0

1 = -8

Let x1 enter the basis. Let the basic variable in constraint 1 leave the basis.

x1

1 3 1 0

0 -4 0 0 -8

6

0 5 1 1 8

Note: the solution is different, but the objective function value is the same.

Page 11: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

11MIT and James Orlin © 2003 11

Alternative Optima

Test for infinite solutions

? jcolumn basic-nonany for

0c 'j

There are alternative optima

ifcj = 0 for some j where xj is non-basic

Page 12: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

12MIT and James Orlin © 2003 12

Today’s Lecture

Review of the simplex algorithm. Alternative Optimal Solutions Unbounded Solution Degeneracy Degenerate Solutions Proving finiteness and optimality under no

degeneracy

Page 13: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

13MIT and James Orlin © 2003 13

x1 = x2 = 1 x3 = 3 x4 = 0 z = 2

x1 = x2 = 1 − (-2) x3 = 3 − (-3) x4 = 0 z = 2 +

x1

Unboundedness

=

=

x2 x4x3-z

0

0

1 =

can be as large as we like !

-2 1 0 .5

1 0 0 -1

-3 0 1 -1.5

1

-2

3

If all the coefficients in the entering column are 0, then the solution is unbounded from above

The entry variable is x1. Set x1 = while x4 = 0.

-2

1

-3

z = 1x1+ 0x2 + 2 max!

Page 14: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

14MIT and James Orlin © 2003 14

Unboundedness

If aic 0 for all i, then the solution is unbounded.

Test for Unbounded Solution

0a ,i 'ic

Page 15: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

15MIT and James Orlin © 2003 15

Simplex Algorithm step by step (Search for Max)

Step 0. The problem is in canonical form withb 0.

Step 1. If c 0 then stop. The solution is optimal. If there exists

some cj>0, then we continue.

Step 2. Choose any non-basic variable to pivot in with cs > 0, e.g.,

cs = maxj {cj | cj > 0 }. If ais 0 for all i, then stop; the LP is

unbounded. If we continue, then there exists some ais > 0.

Step 3. Pivot out the basic variable in row r, where r is chosen by

the min ratio rule, that is r = argmini (bi/ais : ais > 0 ).

Step 4. Replace the basic variable in row r with variable xs and re-

establish canonical form (i.e., pivot on the coefficient ars)

Step 5. Go back to Step 1.

Page 16: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

16MIT and James Orlin © 2003 16

Today’s Lecture

Review of the simplex algorithm. Alternative Optimal Solutions Unbounded Solution Degeneracy and Degenerate Solutions Proving finiteness and optimality under no

degeneracy

Page 17: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

17MIT and James Orlin © 2003 17

x1

-3 3 1 0

-4 2 0 1

DegeneracyInitial Tableau

=

= 2

6

x2 x4x3

-3 2 00

-z

0

0

1 = -2

1x3

x4

BV

-z

A bfs is degenerate if the Tableau revealsbi = 0 for some i. Otherwise, it is non-degenerate.

0

This bfs is degenerate.

0

Page 18: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

18MIT and James Orlin © 2003 18

x1

-3 3 1 0

-4 2 0 1

Degeneracy

=

= 2

6

x2 x4x3

-3 2 00

-z

0

0

1 = -2

1x3

x4

BV

-z

A bfs is degenerate if the Tableau revealsbi = 0 for some i. Otherwise, it is non-degenerate.

3

This bfs is non-degenerate.

3

Page 19: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

19MIT and James Orlin © 2003 19

Degenerate the solution may stay the same z stays the same

x1

-3 3 1 0

-4 2 0 1

Degeneracy

=

= 2

6

x2 x4x3

-3 2 00

-z

0

0

1 = -2

1

x1 = 0 x2 = x3 = 6 - 3 x4 = 0 - 2 z = 2 + 2

x3

x4

BV

-z

0

Suppose that variable x2 will enter the basis.

Page 20: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

20MIT and James Orlin © 2003 20

In this case the objective function did not change. (But the tableau did !)

x1

-3 3 1 0

-4 2 0 1

A degenerate pivotingTableau No.1

=

=

6

x2 x4x3

-3 2 00

-z

0

0

1 = -2

1

x1 = 0 x2 = x3 = 6 x4 = 0 z = 2

x3

x4

BV

-z

The entering variable is x2, which takes a zero value. The exiting variable is the one in constraint 2.

0-2 1 0 1/2 0

1 0 0 -1 -2

3 0 1 -3/2 6

Page 21: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

2111 November, 2002The Simplex Algorithm 21

Cycling

Problem:– if one of the basic variables is zero: Xi = 0 + …

a pivot could be performed which does not change the corresponding value of the objective function

danger of pivoting back (“cycling”)

Solution:– use e.g. Bland’s anti-cycling rule:

• always select the candidate pivot column with smallest index, i.e., the leftmost in Tableau (e.g., x2 instead of x4)

• if several rows have the same minimum ratio, choose for pivoting the first one (i.e., topmost) of them

– this is alternative to the pivot column selection rule that was previously discussed

Page 22: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

2211 November, 2002The Simplex Algorithm 22

Degeneracy

Test for Degeneracy

0

'ic

'i

i'rc

'r

ab

minab

:for which rows moreor 2

The next bfs will be degenerate !

Page 23: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

23MIT and James Orlin © 2003 23

x1

-3 3 1 0

-4 2 0 1

Non-degeneracy leads to strict improvement

=

= 2

6

x2 x4x3

-3 2 00

-z

0

0

1 = -2

1

x1 = 0 x2 = x3 = 6 - 3 x4 = 2 - 2 z = 2+ 2

x3

x4

BV

-z

If the bfs is non-degenerate, then the entering variable can strictly increase, and the objective value will strictly improve.

Page 24: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

24MIT and James Orlin © 2003 24

Cycling

Alternative to Bland’s anti-cycling rule

Perturb the RHS just a little, in just the right way– No basis is degenerate– Every bfs to the perturbed problem is also a

bfs for the original problem– The optimal basis for the perturbed problem is

optimal for the original problem

Page 25: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

25MIT and James Orlin © 2003 25

An LP before perturbationInitial Tableau

x1

-3 3 1 0

-4 2 0 1

=

= 2.

6.

x2 x4x3

-3 2 00

-z

0

0

1 = 0

1x3

x4

BV

-z

Goal: modify the problem by changing the RHS just a little

Perturb it so little that solving the perturbed problem also solves the original problem.

Perturb it to avoid degeneracy

Page 26: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

26MIT and James Orlin © 2003 26

An example of a perturbed initial bfs

x1

-3 3 1 0

-4 2 0 1

=

= 2.00000000000041

6.00000000000013

x2 x4x3

-3 2 00

-z

0

0

1 = 0

1x3

x4

BV

-z

In theory perturbations are even smaller

In practice, the simplex method works fine without perturbations, that is, it really obtains the optimum basic feasible solution.

Page 27: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

27MIT and James Orlin © 2003 27

Today’s Lecture

Review of the simplex algorithm. Alternative Optimal Solutions Unbounded Solution Degeneracy Degenerate Solutions Proving finiteness and optimality under no

degeneracy

Page 28: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

28MIT and James Orlin © 2003 28

Theorem: If every feasible basic solution is non-degenerate, the simplex method is finite.

1. The number of feasible basic solutions is at most n! / (n-m)! m!which is the number of ways of selecting m basic variables

2. Each feasible basic solution is different• Each has a better cost than the last, assuming non-degeneracy

3. Therefore, the simplex method is finite• Typical number of iterations is between m and 3m.

Number of operations per iteration: O(nm)

Page 29: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

29MIT and James Orlin © 2003 29

Some Remarks on Degeneracy and Alternative Optima

It might seem that degeneracy would be rare. After all, why should we expect that the RHS would be 0 for some variable?

In reality, degeneracy is incredibly common. The simplex method is not necessarily finite unless

care is taken in the pivot rule. In reality, almost no one takes care, and the simplex method is not only finite, but it is incredibly efficient.

The issue of alternative optima arises frequently, and is of importance in practice.

Page 30: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

Software for Simplex implementation and solution

30

Page 31: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

31

Demonstration Example

MIT and James Orlin © 2003 31

Maximize the Objective Function (P)

P = 15 x1 + 10 x2 subject to:L1: 0.25 x1 + 1.0 x2 <= 65L2: 1.25 x1 + 0.5 x2 <= 90L3: 1.0 x1 + 1.0 x2 <= 85      x1 >= 0; x2 >= 0

Solved step-by-step on Operations Research-Linear Programming-Simplex Algorithmby Elmer G. Wiens

http://www.egwald.ca/operationsresearch/lpsimplex.php

Page 32: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

32

Demonstration Simplex solver

MIT and James Orlin © 2003 32

Solved step-by-step Tableau and Final Solution on Finite mathematics utility: simplex method tool

http://www.zweigmedia.com/RealWorld/simplex.html

Page 33: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

33

SIMPLEX with MatLab®

function simplex2p(type, c, A, rel, b) % The Two-Phase Method for solving the LP problem% implements the Bland’s rule to avoid cycling in case of degeneracy%% min (max) z = c*x % subject to Ax rel b % x >= 0 . . .% input datatype = ‘min’ (OR ‘max’)

% simplex2p always searches for MIN!

c = [c1 c2 ... ck] % is a row vector A = [a11 a12 … a1k; ... ; am1 am2 … amk]rel = ‘<<< … >>> … ===‘b = [b1; b2; ... bm] % must be a column vector

LINEAR PROGRAMMING WITH MATLABcourse by Edward Neuman Department of Mathematics Southern Illinois University at

Carbondale

Page 34: 1 MIT and James Orlin © 2003 1 Simplex Method Continued … file Simplex2_AMII_05b_gr Rev. 2.71 by M. Miccio on December 15, 2014 from a presentation at.

34

Exercise 5 (for home) with contraints of type ≤

z = 3x1 + 2x2 - x3 + x4 max !

x1 + 2x2 + x3 - x4 5 inequality

2x1 + 4x2 + x3 + x4 1 inequality

x1 0, x2 0, x3 0 non-negativity

x4 uncostrained in sign