Chapter 4. Solving Linear Programs the Simplex Method

download Chapter 4. Solving Linear Programs the Simplex Method

of 34

Transcript of Chapter 4. Solving Linear Programs the Simplex Method

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    1/34

    Chapter 4. Solving Linear ProgramsChapter 4. Solving Linear ProgramsThe Simplex MethodThe Simplex Method

    LP Model: The Augmented (Canonical) FormLP Model: The Augmented (Canonical) Formmax 3 x1 + 5 x2s.t. x1 = 4

    2 x2 = 12

    3 x1 + 2 x2 = 18x1, x2, >= 0

    Variable.Slack :

    0X,,X, ,, 0,0

    =X++++

    X++++ X++++

    s.t.

    +++max

    xxxx

    bxaxaxa

    bxaxaxa bxaxaxa

    xcxcxc

    i+n

    m+n 1+nn21

    mm+nnmn2m21m1

    22+nn2n222121

    11+nn1n212111

    nn2211

    =

    =

    +x3+x4

    +x5x3, x4, x5

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    2/34

    x1 + x3 = 4

    2 x2 + x4 = 123 x1 + 2 x2 + x5 = 18

    Augmented Solution : A solution for the originalvariables that has been augmented by the correspondingvalues of the slack variables.

    In the standard form: (3, 2)

    In the augmented form: (3, 2, 1, 8, 5 )

    How does the augmented corner solution look like?

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    3/34

    Rank of MatrixRank of Matrix A A

    .0 0

    0 0

    ...

    ...

    ......

    ...

    ...

    ...

    and

    if onlyandif rank fullhas

    mn

    2n

    n1

    m2

    22

    12

    m1

    21

    11

    ==

    ==

    =

    y y A

    x Ax A

    a

    aa

    a

    aa

    a

    aa

    A

    T

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    4/34

    Basis of MatrixBasis of Matrix A A

    (B, N). A

    a

    aa

    a

    aa

    a

    aa

    B

    A A B A

    B A

    mm

    mm

    mnnm

    =

    =

    >

    mm

    2m

    m1

    m2

    22

    12

    m1

    21

    11

    :Example

    .of columnsselectedarecolumnsitsand

    of matrix-subrank -fullais if of basis

    aisThen,. andrank fullhavematrixLet

    .

    ...

    ...

    ......

    ...

    ...

    ...

    ,

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    5/34

    Basic Solution of Basic Solution of Ax=b Ax=b

    . and 1

    is, basistoingcorrespondsolution, basicThe

    as decomposed

    becanequationthe,of basisselectedaFor

    .equationmatrixheConsider t

    0

    .

    ==

    =+

    =

    N B

    N B

    xb B x

    Bb Nx Bx

    A B

    b Ax

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    6/34

    A Basis Solution of the Augmented SystemA Basis Solution of the Augmented System

    .0

    0 and

    8

    12

    4

    . and

    1

    0

    0

    0

    1

    0

    0

    0

    1

    ),,(Select.

    1

    0

    0

    002

    102

    010

    3

    0

    1

    N

    1

    B

    2

    1

    N

    5

    4

    3

    B

    543

    =

    ==

    =

    ==

    =

    =

    xb B x

    x

    x x

    x

    x

    x

    x

    A A A B A

    x1 + x3 = 4

    2 x2 + x4 = 123 x1 + 2 x2 + x5 = 18

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    7/34

    s Basic Solution: An augmented corner-point solution.

    Basic variables are x 1, x 2 and x 5In the standard form: (4, 6)

    In the augmented form: ( 4, 6 , 0, 0, -6) s Basic Feasible Solution: An augmented feasible corner-

    point solution.

    Basic variables are x 2, x 3 and x 5In the standard form: ( 0, 6)

    In the augmented form: ( 0, 6, 4, 0, 6)

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    8/34

    Basic Solution of the Augmented Form

    Basic VariableBasic Variable: A basic variable solution has at leastA basic variable solution has at least nn variables, original or variables, original or

    slack, whose value are zero. These variables are called non-slack, whose value are zero. These variables are called non- basic variables, and the others are called basic variables. basic variables, and the others are called basic variables.

    ( 4, 6, 0, 0, -6)( 0, 6, 4, 0, 6 )

    A basic solution can be obtained directly form the augmentedA basic solution can be obtained directly form the augmentedform by settingform by setting nn ( non-basic ) variables equal to zero and( non-basic ) variables equal to zero andsolvingsolving mm equations for equations for mm ( basic ) variables( basic ) variables

    The coefficient matrix of theThe coefficient matrix of the mm equations is called basis.equations is called basis. If the values of theIf the values of the mm basic variables are nonnegative, then it is basic variables are nonnegative, then it is

    a basic feasible solution corresponding to a feasible corner-a basic feasible solution corresponding to a feasible corner- point in the original form. point in the original form.

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    9/34

    Adjacent Basic Solutions

    Two basic solutions are adjacent if all but one of their Two basic solutions are adjacent if all but one of their basic variables are the same. Two adjacent basic basic variables are the same. Two adjacent basicsolutions represent two neighbor corner-point in thesolutions represent two neighbor corner-point in theoriginal form.original form.

    ( 4, 6, 0, 0, -6 ) and ( 4, 3, 0, 6, 0 )( 4, 6, 0, 0, -6 ) and ( 4, 3, 0, 6, 0 )

    Two basic feasible solutions are adjacent if all but oneTwo basic feasible solutions are adjacent if all but oneof their basic variables are the same. Two adjacentof their basic variables are the same. Two adjacent

    basic feasible solutions represent two feasible neighbor basic feasible solutions represent two feasible neighbor corner-point in the original form.corner-point in the original form.

    ( 4, 0, 0, 12, 6 ) and ( 4, 3, 0, 6, 0 )( 4, 0, 0, 12, 6 ) and ( 4, 3, 0, 6, 0 )

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    10/34

    Algebraic Outline of the Simplex Method

    Start from a basic feasible solution

    Is there a better adjacent basic feasible solution exists?

    Move to a better adjacent basic feasible solution

    The movement involves converting one non-basic variable into a basicThe movement involves converting one non-basic variable into a basicvariable ( called entering basic variable ) and simultaneously converting avariable ( called entering basic variable ) and simultaneously converting a

    basic variable into a non-basic variable ( called the leaving basic variable ), basic variable into a non-basic variable ( called the leaving basic variable ),and then compute the new basic feasible solution.and then compute the new basic feasible solution.

    NO

    YES

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    11/34

    Z = 3x1 + 5x2

    x1 + x3 =42x2 + x4 = 12

    3x1 + 2x2 + x5 = 18

    1. What is the criterion for selecting the entering basic1. What is the criterion for selecting the entering basicvariable or to show that the current basic feasible solutionvariable or to show that the current basic feasible solutionis optimal?is optimal?

    The candidate for the entering basic variables are the n currentnonbasic variables. The one chosen would be changed from nonbasic

    into basic, so its value would be increased from zero to some positivenumber and the others would be kept at zero. Since we require animprovement, the rate of change in the objective function must be a

    positive one.

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    12/34

    Z = 3x1 + 5 x2

    x1 + x3 =4

    2x2 + x4 = 123x1 + 2 x2 + x5 = 18

    1. What is the criterion for selecting the entering basic1. What is the criterion for selecting the entering basicvariable or to show that the current basic feasible solutionvariable or to show that the current basic feasible solutionis optimal?is optimal?

    Express the objective function in terms of only nonbasic variables andalso the basic variables in terms of the nonbasic variables---calledCanonical Form . Then, the coefficient of the entering variable must be

    positive. If the coefficients are all nonpositive, then no better adjacent basic feasible solution exists and the current one is optimal.

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    13/34

    2. How to select the leaving basic variable?2. How to select the leaving basic variable?Z = 5Z = 5 X2X2

    + X3+ X3 = 4= 4

    22X2X2 + X 4 = 12+ X 4 = 12

    22X2X2 + X5 = 18+ X5 = 18

    X3X3 = 4= 4

    X4 = 12 - 2X4 = 12 - 2 X2X2

    X5 = 18 - 2X5 = 18 - 2 X2X2

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    14/34

    2. How to select the leaving basic variable?2. How to select the leaving basic variable?Z = 5Z = 5 X2X2

    + X3+ X3 = 4= 4

    22X2X2 + X 4 = 12+ X 4 = 12

    22X2X2 + X5 = 18+ X5 = 18

    X3X3 = 4= 4

    X4X4 = 12 - 2= 12 - 2 X2X2

    X5 = 18 - 2X5 = 18 - 2 X2X2

    3. How to compute the new basic feasible solution?3. How to compute the new basic feasible solution?

    Z = 3X1Z = 3X1 - (5/2) X4 +30- (5/2) X4 +30

    X1 + X3 = 4X1 + X3 = 4

    X2 + ( 1/2 ) X4 = 6X2 + ( 1/2 ) X4 = 6

    X1X1 - X4 + X5 = 6- X4 + X5 = 6

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    15/34

    Iteration 2 for the example:

    Z = 3Z = 3 X1X1 + 30+ 30

    X1X1 + X3+ X3 = 4= 4X2X2 = 6= 6

    33X1X1 + X5 = 6+ X5 = 6

    Z =Z = + 30 + 3X1+ 30 + 3X1

    X3X3 = 4 -= 4 - X1X1

    X2X2 = 6= 6

    X5X5 = 6 -= 6 - 3X13X1

    Z =Z = - (5/2 ) X4 - X5 + 36- (5/2 ) X4 - X5 + 36

    X3 + ( 1/3 ) X4 - ( 1/3 ) X5 = 2X3 + ( 1/3 ) X4 - ( 1/3 ) X5 = 2

    X2X2 + ( 1/2 ) X4+ ( 1/2 ) X4 = 6= 6

    X1X1 - ( 1/3 ) X4 + ( 1/3 ) X5 =2- ( 1/3 ) X4 + ( 1/3 ) X5 =2

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    16/34

    Summary of the Simplex MethodSummary of the Simplex Method

    1.1. Select a basic feasible solutionSelect a basic feasible solution

    2.2. Express the basic variables in terms of the nonbasic variables, andExpress the basic variables in terms of the nonbasic variables, andexpress the objective function in terms of only nonbasic variablesexpress the objective function in terms of only nonbasic variables.

    If all objective coefficients are non-positive, then stop: the currentIf all objective coefficients are non-positive, then stop: the current basic feasible solution is optimal. basic feasible solution is optimal.Otherwise, select the entering variable such that its coefficient is theOtherwise, select the entering variable such that its coefficient is thelargest, and among basic variables select the leaving variable suchlargest, and among basic variables select the leaving variable suchthat it becomes zero first when increasing the entering variable andthat it becomes zero first when increasing the entering variable andkeeping the other nonbasic variables at zero. If no basic variablekeeping the other nonbasic variables at zero. If no basic variable

    becomes zero, then stop: the objective function is unbounded. becomes zero, then stop: the objective function is unbounded.

    3.3. Goto Step 2.Goto Step 2.

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    17/34

    The Original Simplex Method: Tabular FormThe Original Simplex Method: Tabular Forms Gaussian Elimination

    X1 + X3 = 4X2 - X3 = 1

    3X1 + 2X2 - 4X3 = -5

    1 0 1 40 2 -1 1

    3 2 -4 -5Row 3 - 3 x Row 1:

    1 0 1 40 2 -1 10 2 -7 -17

    ( Row 2 ) / 2:1 0 1 40 1 -1/2 1/20 2 -7 -17

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    18/34

    Row 3 - 2 x (Row 2):1 0 1 40 1 -1/2 1/2

    0 0 -6 -18

    (Row 3 ) / (-6 ):1 0 1 40 1 -1/2 1/20 0 1 3

    Row 2 + ( Row 3 ) / 2:1 0 1 40 1 0 20 0 1 3

    Row 1 - Row 3:1 0 0 10 1 0 20 0 1 3

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    19/34

    Variable.Slack :

    0X,,X, ,, 0,0

    =X++++

    X++++

    X++++

    s.t.

    +++max

    x

    xxx bxaxaxa

    bxaxaxa

    bxaxaxa

    xcxcxc

    i+n

    m+n 1+nn21

    mm+nnmn2m21m1

    22+nn2n222121

    11+nn1n212111

    nn2211

    =

    =

    max 3 x1+ 5 x2

    s.t. x1 + x3 = 42 x2 + x4 = 12

    3 x1 + 2 x2 + x5 = 18x1, x2, x3, x4, x5 >= 0

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    20/34

    =X++++

    X++++

    X++++

    0= - - -

    bxaxaxa

    bxaxaxa

    bxaxaxaxcxcxc-z

    mm+nnm n2m 21m1

    22+nn2n222121

    11+nn1n212111

    nn2211

    =

    =

    z - 3 x1 -5 x2 = 0x1 + x3 = 4

    2 x2 + x4 = 123 x1 + 2 x2 + x5 = 18

    x1, x2, x3, x4, x5 >= 0

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    21/34

    Step 0. Initial TableStep 0. Initial Table

    Basic Right-HandVar.. Side

    x x x x m+n 1+n21 ...

    baa x

    baa x

    baa x

    cc

    mmmmn

    n

    n

    1 0

    0 0 0 0

    1 1

    0 0 0 - - Z

    21

    222212

    112111

    21

    +

    +

    +

    Basic Variable RHS

    Z -3 -5 0 0 0 0

    3 1 0 1 0 0 4

    4 0 2 0 1 0 12

    5 3 2 0 0 1 18

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    22/34

    s Step 1. Optimality TestStep 1. Optimality TestThe current basic feasible solution is optimal if and only if everyThe current basic feasible solution is optimal if and only if everycoefficient in Row 0 is nonnegative. If it is, stop; otherwise, go tocoefficient in Row 0 is nonnegative. If it is, stop; otherwise, go toStep 2.Step 2.

    s Step 2. Update the Basic Feasible SolutionStep 2. Update the Basic Feasible Solution

    1.1. Determine the variable by selecting the variable with the lowestDetermine the variable by selecting the variable with the lowestcoefficient in Row 0. The corresponding column is called the pivotcoefficient in Row 0. The corresponding column is called the pivotcolumn.column.

    Basic VariableBasic Variable RHSRHS

    ZZ -3-3 -5-5 00 00 00 00

    33 11 00 11 00 00 44

    44 00 22 00 11 00 1212

    55 33 22 00 00 11 1818

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    23/34

    Step 2. ( Continued )Step 2. ( Continued )

    2.2. Determine the leaving variable byDetermine the leaving variable bya)a) picking out each coefficient in the pivot column that is strictly picking out each coefficient in the pivot column that is strictly

    positive, ( if no positive coefficient exists, then stop; the positive, ( if no positive coefficient exists, then stop; the problem is unbounded. ) problem is unbounded. )

    b) b) dividing each of these coefficients into RHS for the samedividing each of these coefficients into RHS for the samerow,row,

    c)c) identifying the row that has the smallest of these ratios, andidentifying the row that has the smallest of these ratios, and

    d)d) selecting the basic variable for this row, which is called theselecting the basic variable for this row, which is called the pivot rowpivot row.

    Basic Variable RHSBasic Variable RHS RatioRatio

    ZZ -3-3 -5-5 00 00 00 00

    33 11 00 11 00 00 44

    44 00 22 00 11 00 12 6 = 12/212 6 = 12/2

    55 33 22 00 00 11 16 9 = 18/216 9 = 18/2

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    24/34

    Step 2. ( Continued )Step 2. ( Continued )

    3.3. The intersection of the pivot column and pivot row is the pivotThe intersection of the pivot column and pivot row is the pivotnumber. Replace the leaving basic variable by the entering basicnumber. Replace the leaving basic variable by the entering basicvariable in Column 0. Perform Gaussian elimination for the pivotvariable in Column 0. Perform Gaussian elimination for the pivotnumber. Goto Step 1.number. Goto Step 1.

    Basic VariableBasic Variable RHSRHS

    ZZ -3-3 -5-5 00 00 00 00

    33 11 00 11 00 00 44

    22 00 22 00 11 00 1212

    55 33 22 00 00 11 1818

    ( Row 2 ) / 2 :( Row 2 ) / 2 : Basic VariableBasic Variable RHSRHSZZ -3-3 -5-5 00 00 00 00

    33 11 00 11 00 00 44

    44 00 11 0 1/20 1/2 00 66

    55 33 22 00 00 11 1818

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    25/34

    Row 3 - 2 x Row 2

    Basic VariableBasic Variable RHSRHS

    Z -3 -5 0 0 0 03 1 0 1 0 0 42 0 1 0 1/2 0 65 3 0 0 -1 1 6

    Row 0 + 5 x Row 2

    Basic VariableBasic Variable RHSRHSZ -3 0 0 5/2 0 30

    3 1 0 1 0 0 42 0 1 0 1/2 0 65 3 0 0 -1 1 6

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    26/34

    Iteration 2:

    Basic Variable RHS Ratio

    Z -3 0 0 5/2 0 303 1 0 1 0 0 4 42 0 1 0 1/2 0 65 3 0 0 -1 1 6 2

    Basic Variable RHS

    Z -3 0 0 5/2 0 303 1 0 1 0 0 4

    2 0 1 0 1/2 0 6

    1 1 0 0 -1/3 1/3 2

    Basic Variable RHSZ 0 0 0 3/2 1 36

    3 0 0 1 1/3 -1/3 2

    2 0 1 0 1/2 0 6

    1 1 0 0 -1/3 1/3 2

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    27/34

    Initial BFS for General FormInitial BFS for General Form

    Artificial Variable for Equality ConstrainsArtificial Variable for Equality Constrains

    maximizemaximize 3x1 + 5x23x1 + 5x2subject tosubject to x1 = 4x1 = 42x2 = 0

    maximizemaximize 3x1 + 5x23x1 + 5x2subject tosubject to x1 + x3 = 4x1 + x3 = 4

    2x2 + x4 = 122x2 + x4 = 123x1 + 2x2 + x5 = 183x1 + 2x2 + x5 = 18

    x1, x2, x3, x4, x5 >= 0x1, x2, x3, x4, x5 >= 0

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    28/34

    maximizemaximize 3x1 + 5x2 - Mx33x1 + 5x2 - Mx3subject tosubject to x1 + x3 = 4x1 + x3 = 4

    2x2 + x4 = 122x2 + x4 = 123x1 + 2x2 + x5 = 183x1 + 2x2 + x5 = 18

    x1, x2, x3, x4, x5 >= 0x1, x2, x3, x4, x5 >= 0

    Basic VariableBasic Variable RHSRHSZZ -3-3 -5-5 100100 00 00 00

    33

    11

    00

    11

    00

    00

    44

    44 00 22 00 11 00 121255 33 22 00 00 11 1818

    Basic VariableBasic Variable RHSRHS

    ZZ -103-103 -105-105 00 00 00 -400-40033 11 0 10 1 00 00 4444 00 22 00 11 00 12125 35 3 22 00 00 11 1818

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    29/34

    The BigThe Big M M MethodMethod

    1.1. Change every > = constraint to = constraint to

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    30/34

    The Two-Phase MethodThe Two-Phase Method

    1.1. Change every >= constraint to

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    31/34

    Tie BreakingTie Breaking

    Degeneracy: The number of zero-value variables (including slacks) isalways greater than or equal to the number of original variables. In otherwords, the number of positive-value variables is always less than or equalto the number of inequality constraints. When they are not equal, we havea degenerate corner or basic feasible solution.

    Left-Right and Top-Bottom Rule

    Max 2x1 - 3x2 + 5x3s.t. 8x1 + 5x2 + 4x3

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    32/34

    Simplex Method:Basic Variable RHS Ratio

    Z -2 3 -5 0 0 0 04 8 -5 4 1 0 0 24 65 1 -7 0 0 1 0 176 5 3 10 0 0 1 60 6

    Basic Variable RHS Ratio

    Z 8 -13/4 0 5/4 0 0 303 2 -5/4 1 1/4 0 0 6

    5 1 -7 0 0 1 0 17

    6 -15 31/2 0 -5/2 0 1 0 0

    Basic Variable RHS Ratio

    Z 301/62 0 0 45/62 0 13/62 30

    3 49/62 0 1 3/62 0 5/62 6

    5 -179/31 0 0 -35/31 1 14/31 17

    2 -30/31 1 0 -5/31 0 2/31 0

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    33/34

    Min - (3/4)x4 +20x5 - (1/2)x6 + 6x7

    s.t. x1 + (1/4)x4 - 8x5 - x6 + 9x7 = 0x2 + (1/2)x4 - 12x5 - (1/2)x6 + 3x7 = 0

    x3 + x6 = 1x1, x2, x3, x4, x5, x6, x7 >= 0

    Cycling:Cycling:

    Degeneracy can cause the phenomenon called cycling, theinfinite repetition of a finite sequence of basic feasiblesolutions producing non change in the value of the objectiveand thereby preventing the finite termination of theSimplex method.

  • 8/14/2019 Chapter 4. Solving Linear Programs the Simplex Method

    34/34

    Methods Handling DegeneracyMethods Handling Degeneracys

    Random ChoiceRandom Choice Chose the row randomly from among all thoseChose the row randomly from among all thosethat yield the minimum ratiothat yield the minimum ratio

    s Perturbation of the RHSPerturbation of the RHS b b ii ++ ii, i=1,,m, i=1,,m

    s Lexicographic OrderingLexicographic Orderings Double Least Index RuleDouble Least Index Rule

    Least indexed variable among all eligibleLeast indexed variable among all eligibleentering variablesentering variables

    Least indexed variable among all rows that yieldLeast indexed variable among all rows that yieldthe minimum ratiothe minimum ratio