The Simplex Method or Solving Linear Program Frédéric Giroire FG Simplex 1/20
Motivation • Most popular method to solve linear programs. • Principle: smartly explore basic solutions (corner point solutions), improving the value of the solution. FG Simplex 2/20
The simplex Start with a problem written under the standard form. + + Maximize 5 x 1 4 x 2 3 x 3 Subject to : + 2 x 1 3 x 2 − x 3 ≤ 5 4 x 1 + 2 x 3 11 x 2 − ≤ + 3 x 1 4 x 2 − 2 x 3 ≤ 8 x 1 , x 2 , x 3 0 . ≥ FG Simplex 3/20
The simplex First step: introduce new variables, slack variables. 2 x 1 + 3 x 2 + x 3 ≤ 5 We note x 4 the slack (difference) between the right member and 5, that is x 4 = 5 − 2 x 1 − 3 x 2 − x 3 . The inequation can now be written as x 4 ≥ 0 . FG Simplex 4/20
The simplex Similarly, for the 2 others inequalities: + 4 x 1 x 2 2 x 3 11 − ≤ + 3 x 1 4 x 2 − 2 x 3 ≤ 8 We define x 5 and x 6 : = x 5 11 4 x 1 x 2 2 x 3 − − − = x 6 8 − 3 x 1 − 4 x 2 − 2 x 3 And the inequalities can be written as x 5 ≥ 0 , x 6 ≥ 0 . FG Simplex 5/20
The simplex To summarize, we introduce three slack variables x 4 , x 5 , x 6 : = 5 2 x 1 3 x 2 x 4 − − − x 3 = x 5 11 − 4 x 1 − x 2 − 2 x 3 = x 6 8 − 3 x 1 − 4 x 2 − 2 x 3 = + + 3 x 3 . z 5 x 1 4 x 2 The problem can be written as: Maximize z subject to x 1 , x 2 , x 3 , x 4 , x 5 , x 6 ≥ 0 . slack variables x 4 , x 5 , x 6 decision variables x 1 , x 2 , x 3 . The two problems are equivalent. FG Simplex 6/20
The simplex Second step: Find an initial solution. In our example, x 1 = 0 , x 2 = 0 , x 3 = 0 is feasible. We compute the value of x 4 , x 5 , x 6 . = x 3 = 5 x 4 5 − 2 x 1 − 3 x 2 − Similarly, x 5 = 11 and x 6 = 8. We get an initial solution x 1 = 0 , x 2 = 0 , x 3 = 0 , x 4 = 5 , x 5 = 11 , x 6 = 8 of value z = 0 FG Simplex 7/20
The simplex Dictionary: = x 4 5 − 2 x 1 − 3 x 2 − x 3 = x 5 11 − 4 x 1 − x 2 − 2 x 3 = x 6 8 − 3 x 1 − 4 x 2 − 2 x 3 = + + 3 x 3 . z 5 x 1 4 x 2 Basic variables: x 4 , x 5 , x 6 , variables on the left. Non-basic variable: x 1 , x 2 , x 3 , variables on the right. A dictionary is feasible if a feasible solution is obtained by setting all non-basic variables to 0. FG Simplex 8/20
The simplex Dictionary: = x 4 5 − 2 x 1 − 3 x 2 − x 3 = x 5 11 − 4 x 1 − x 2 − 2 x 3 = x 6 8 − 3 x 1 − 4 x 2 − 2 x 3 = + + 3 x 3 . z 5 x 1 4 x 2 Basic variables: x 4 , x 5 , x 6 , variables on the left. Non-basic variable: x 1 , x 2 , x 3 , variables on the right. A dictionary is feasible if a feasible solution is obtained by setting all non-basic variables to 0. FG Simplex 8/20
The simplex Simplex strategy: find an optimal solution by successive improvements. Rule: we increase the value of the variable of largest positive coefficient in z . = x 4 5 − 2 x 1 − 3 x 2 − x 3 = x 5 11 4 x 1 x 2 2 x 3 − − − = x 6 8 − 3 x 1 − 4 x 2 − 2 x 3 = + + 3 x 3 . z 5 x 1 4 x 2 Here, we try to increase x 1 . FG Simplex 9/20
The simplex How much can we increase x 1 ? = x 4 5 2 x 1 3 x 2 x 3 − − − = x 5 11 − 4 x 1 − x 2 − 2 x 3 = 8 3 x 1 4 x 2 2 x 3 x 6 − − − = + + 3 x 3 . z 5 x 1 4 x 2 We have x 4 ≥ 0 . that is x 1 ≤ 5 It implies 5 − 2 x 1 ≥ 0, 2 . FG Simplex 10/20
The simplex How much can we increase x 1 ? = x 4 5 2 x 1 3 x 2 x 3 − − − = x 5 11 − 4 x 1 − x 2 − 2 x 3 = 8 3 x 1 4 x 2 2 x 3 x 6 − − − = + + 3 x 3 . z 5 x 1 4 x 2 We have x 4 ≥ 0 . that is x 1 ≤ 5 / 2 . It implies 5 − 2 x 1 ≥ 0, Similarly, x 5 ≥ 0 gives x 1 ≤ 11 / 4. x 6 ≥ 0 gives x 1 ≤ 8 / 3. FG Simplex 11/20
The simplex How much can we increase x 1 ? = x 4 5 2 x 1 3 x 2 x 3 − − − = x 5 11 − 4 x 1 − x 2 − 2 x 3 = 8 3 x 1 4 x 2 2 x 3 x 6 − − − = + + 3 x 3 . z 5 x 1 4 x 2 We have x 4 ≥ 0 . that is x 1 ≤ 5 / 2 It implies 5 − 2 x 1 ≥ 0, Strongest constraint Similarly, x 5 ≥ 0 gives x 1 ≤ 11 / 4. x 6 ≥ 0 gives x 1 ≤ 8 / 3. FG Simplex 12/20
The simplex How much can we increase x 1 ? = x 4 5 2 x 1 3 x 2 x 3 − − − = x 5 11 − 4 x 1 − x 2 − 2 x 3 = x 6 8 3 x 1 4 x 2 2 x 3 − − − = + + 3 x 3 . z 5 x 1 4 x 2 We have x 4 ≥ 0 . that is x 1 ≤ 5 / 2 It implies 5 − 2 x 1 ≥ 0, Strongest constraint We get a new solution: x 1 = 5 / 2, x 4 = 0 with better value z = 5 · 5 / 2 = 25 / 2. We still have x 2 = x 3 = 0 and now x 5 = 11 − 4 · 5 / 2 = 1, x 6 = 8 − 3 · 5 / 2 = 1 / 2 FG Simplex 13/20
The simplex We build a new feasible dictionary. = x 4 5 − 2 x 1 − 3 x 2 − x 3 = x 5 11 4 x 1 x 2 2 x 3 − − − = x 6 8 − 3 x 1 − 4 x 2 − 2 x 3 = + + 3 x 3 . z 5 x 1 4 x 2 x 1 enters the bases and x 4 leaves it: = 5 / 2 3 / 2 x 2 1 / 2 x 3 1 / 2 x 4 x 1 − − − FG Simplex 14/20
The simplex We replace x 1 by its expression in function of x 2 , x 3 , x 4 . = 5 / 2 1 / 2 x 4 3 / 2 x 2 1 / 2 x 3 x 1 − − − = 4 ( 5 / 2 − 3 / 2 x 2 − 1 / 2 x 3 − 1 / 2 x 4 ) x 5 11 x 2 2 x 3 − − − = 3 ( 5 / 2 − 3 / 2 x 2 − 1 / 2 x 3 − 1 / 2 x 4 ) x 6 8 4 x 2 2 x 3 − − − = 5 ( 5 / 2 − 3 / 2 x 2 − 1 / 2 x 3 − 1 / 2 x 4 ) + + 3 x 3 . z 4 x 2 FG Simplex 15/20
The simplex Finally, we get the new dictionary: 5 3 1 1 = x 1 − x 2 − x 3 − x 4 2 2 2 2 = + + x 5 1 5 x 2 2 x 4 1 1 1 3 = + + x 6 x 2 − x 3 x 4 2 2 2 2 25 7 1 5 = + x 4 . z − x 2 x 3 − 2 2 2 2 FG Simplex 16/20
The simplex Finally, we get the new dictionary: 3 1 1 = 5 / 2 x 1 − x 2 − x 3 − x 4 2 2 2 = + + x 5 1 5 x 2 2 x 4 1 1 3 = 1 / 2 + + x 6 x 2 − x 3 x 4 2 2 2 = 25 / 2 7 / 2 + 1 / 2 5 / 2 x 4 . z − x 2 x 3 − We can read the solution directly from the dictionary: Non basic variables: x 2 = x 3 = x 4 = 0. Basic variables: x 1 = 5 / 2, x 5 = 1, x 6 = 1 / 2. Value of the solution: z = 25 / 2. FG Simplex 17/20
The simplex 5 3 1 1 = x 1 − x 2 − x 3 − x 4 2 2 2 2 = + + x 5 1 5 x 2 2 x 4 1 1 1 3 = + + x 6 x 2 x 3 x 4 − 2 2 2 2 25 7 1 5 = + x 4 . z − x 2 x 3 − 2 2 2 2 New step of the simplex: - x 3 enters the basis (variable with largest positive coefficient). - 3 d equation is the strictest constaint x 3 ≤ 1. - x 6 leaves the basis. FG Simplex 18/20
The simplex New feasible dictionary: = + + x 3 1 x 2 3 x 4 2 x 6 − = + x 1 2 − 2 x 2 − 2 x 4 x 6 = + + x 5 1 5 x 2 2 x 4 = x 6 . z 13 3 x 2 x 4 − − − With new solution: x 1 = 2 , x 2 = 0 , x 3 = 1 , x 4 = 0 , x 5 = 1 , x 6 = 0 of value z = 13 . This solution is optimal. All coefficients in z are negative and x 2 ≥ 0 , x 4 ≥ 0 , x 6 ≥ 0 , so z ≤ 13 . FG Simplex 19/20
The simplex New feasible dictionary: = + + x 3 1 x 2 3 x 4 2 x 6 − = + x 1 2 − 2 x 2 − 2 x 4 x 6 = + + x 5 1 5 x 2 2 x 4 = x 6 . z 13 3 x 2 x 4 − − − With new solution: x 1 = 2 , x 2 = 0 , x 3 = 1 , x 4 = 0 , x 5 = 1 , x 6 = 0 of value z = 13 . This solution is optimal. All coefficients in z are negative and x 2 ≥ 0 , x 4 ≥ 0 , x 6 ≥ 0 , so z ≤ 13 . FG Simplex 19/20
Take Aways • Most popular method to solve linear programs. • Principle: smartly explore basic solutions (corner point solutions), improving the value of the solution. • Complexity: • In theory, NP-complete (can explore a number of solutions exponentiel in the number of variables and constraints). • In practice, almost linear in the number of constraints. • Polynomial methods exists: the ellipsoid method. FG Simplex 20/20
Recommend
More recommend