Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 4 The Simplex Algorithm( 單體法 ) and Goal Programming Copyright (c) 2004 Brooks/Cole, a division of Thomson Learning, Inc.

Similar presentations


Presentation on theme: "Chapter 4 The Simplex Algorithm( 單體法 ) and Goal Programming Copyright (c) 2004 Brooks/Cole, a division of Thomson Learning, Inc."— Presentation transcript:

1 Chapter 4 The Simplex Algorithm( 單體法 ) and Goal Programming Copyright (c) 2004 Brooks/Cole, a division of Thomson Learning, Inc.

2 2 4.1 How to Convert an LP to Standard Form Before the simplex algorithm can be used to solve an LP, the LP must be converted into a problem where all the constraints are equations and all variables are nonnegative. An LP in this form is said to be in standard form( 標準型式 ). p.127

3 3 Example 1: Leather Limited Leather Limited manufactures two types of leather belts: deluxe model and regular model. Each type requires 1 square yard of leather. A regular belt requires 1 hour of skilled labor and a deluxe belt requires 2 hours of skilled labor. Each week, 40 square yards of leather and 60 hours of skilled labor are available. Each regular belt contributes $3 profit and each deluxe belt $4. Write an LP to maximize profit. p.127

4 4 Example 1: Solution The decision variables are: x 1 = number of deluxe belts produced weekly x 2 = number of regular belts produced weekly The appropriate LP is: max z = 4x 1 + 3x 2 s.t. x 1 + x 2 ≤ 40(leather constraint) 2x 1 +x 2 ≤ 60(labor constraint) x 1, x 2 ≥ 0

5 5 To convert ith ≤ constraint ( 不等式限制式 ) to an equality constraint ( 等式限制式 ), define a slack variable ( 寬鬆變數 ) s i (s i = slack variable for the ith constraint). Adding a slack variable s i to the ith constraint and adding the sign restriction s i ≥ 0. To convert the ith ≥ constraint to an equality constraint, define an excess variable ( 剩餘變數 ) e i (sometimes called a surplus variable) (e i = excess variable for the ith ≥ constraint) Subtracting the excess variable e i from the ith constraint and adding the sign restriction e i ≥ 0. If an LP has both ≤ and ≥ constraints, apply the previous procedures to the individual constraints.

6 6 Example : Slack Variable max z = 4x 1 + 3x 2 s.t. x 1 + x 2 + s 1 = 40 (leather constraint) 2x 1 +x 2 + s 2 = 60 (labor constraint) x 1, x 2, s 1, s 2 ≥ 0 max z = 4x 1 + 3x 2 s.t. x 1 + x 2 ≤ 40(leather constraint) 2x 1 +x 2 ≤ 60(labor constraint) x 1, x 2 ≥ 0 p.128

7 7 Example : Surplus Variable max z = 50x 1 + 20x 2 +30x 3 + 80x 4 s.t. 400x 1 + 200x 2 + 150x 3 + 500x 4 ≥ 500 3x 1 + 2x 2 ≥ 6 2x 1 + 2x 2 + 4x 3 + 4x 4 ≥ 10 2x 1 + 4x 2 + x 3 + 5x 4 ≥ 8 x 1, x 2, x 3, x 4 ≥ 0 max z = 50x 1 + 20x 2 +30x 3 + 80x 4 s.t. 400x 1 + 200x 2 + 150x 3 + 500x 4 – e 1 = 500 3x 1 + 2x 2 – e 2 = 6 2x 1 + 2x 2 + 4x 3 + 4x 4 – e 3 = 10 2x 1 + 4x 2 + x 3 + 5x 4 – e 4 = 8 x i, e i ≥ 0,(i=1,2,3,4) p.129

8 8 Slack Variable and Surplus Variable max z = 20x 1 + 15x 2 s.t. x 1 ≤ 100 x 2 ≤ 100 50x 1 + 35x 2 ≤ 6000 20x 1 + 15x 2 ≥ 2000 x 1, x 2 ≥ 0 max z = 20x 1 + 15x 2 s.t. x 1 + s 1 = 100 x 2 + s 2 = 100 50x 1 + 35x 2 + s 3 = 6000 20x 1 + 15x 2 – e 4 = 2000 x 1, x 2,s 1,s 2,s 3,e 4 ≥ 0

9 9 Exercise : Convert the following LP to standard form.

10 10 Figure 1 and Table 1 max z = 4x 1 + 3x 2 s.t. x 1 + x 2 ≤ 40(leather constraint) 2x 1 +x 2 ≤ 60(labor constraint) x 1, x 2 ≥ 0 max z = 4x 1 + 3x 2 s.t. x 1 + x 2 + s 1 = 40 (leather constraint) 2x 1 +x 2 + s 2 = 60 (labor constraint) x 1, x 2, s 1, s 2 ≥ 0 p.133

11 11 4.2 Preview of the Simplex Algorithm Consider a system Ax = b of m linear equations in n variables (where n ≥ m). A basic solution( 基本解 ) to Ax = b is obtained by setting n – m variables equal to 0 and solving for the remaining m variables. (p.131) This assumes that setting the n – m variables equal to 0 yields a unique value for the remaining m variables, or equivalently, the columns for the remaining m variables are linearly independent. Any basic solution in which all variables are nonnegative is called a basic feasible solution ( 基本可行解 ) (bfs). (p.132) p.130

12 12 Theorem 1. (p.132) The feasible region for any linear programming problem is a convex set. Also, if an LP has an optimal solution, there must be an extreme point of the feasible region that is optimal.

13 13 4.3 Direction of Unboundedness Consider an LP in standard form with feasible region S and constraints Ax=b and x ≥ 0. Assuming that our LP has n variables, 0 represents an n-dimensional column vector consisting of all 0’s. A non-zero vector d is a direction of unboundedness if for all xS and any c≥0, x +cdS p.134

14 14 min z = 50x 1 + 100x 2 s.t. 7x 1 + 2x 2 ≥ 28 2x 1 + 12x 2 ≥ 24 x 1, x 2 ≥ 0 min z = 50x 1 + 100x 2 s.t. 7x 1 + 2x 2 – e 1 = 28 2x 1 + 12x 2 – e 2 = 24 x 1, x 2,e 1,e 2 ≥ 0 Fig. 3 Fig. 4 p.134

15 15 Theorem 2. (p.135) Consider an LP in standard form, having bfs b 1, b 2,…b k. Any point x in the LP’s feasible region may be written in the form where d is 0 or a direction of unboundedness and =1 and  i ≥ 0. Any feasible x may be written as a convex combination of the LP’s bfs.

16 16 4.4 Why Does LP Have an Optimal bfs? Theorem 3. If an LP has an optimal solution, then it has an optimal bfs. For any LP with m constraints, two bfs are said to be adjacent ( 相鄰的 ) if their sets of BV have m – 1 BV in common. The set of points satisfying a linear inequality in three (or any number of) dimensions is a half- space( 半空間 ). The intersection of half-space is called a polyhedron( 多面體 ). p.136

17 17 Geometry of Three-Dimensional LPs P.138 LP : Fig. 5 Table 2

18 18 4.5 The Simplex Algorithm The simplex algorithm( 單體法 ) is used to solve LP where the goal is to maximize the objective function. Step 1 Convert the LP to standard form (p.148) Step 2 Obtain a bfs from the standard form Step 3 Determine whether the current bfs is optimal Step 4 If the current bfs is not optimal, determine which NBV should be come a BV and which BV should become a NBV to find a bfs with a better objective function value. Step 5 Use EROs to find a new bfs with a better objective function value. Go back to Step 3. p.140

19 19 Example 2: Dakota Furniture Company The Dakota Furniture company manufactures desk, tables, and chairs. The manufacture of each type of furniture requires lumber and two types of skilled labor: finishing and carpentry. The amount of each resource needed to make each type of furniture is given in the table below. ResourceDeskTableChair Lumber8 board ft6 board ft1 board ft Finishing hours4 hours2 hours1.5 hours Carpentry hours2 hours1.5 hours0.5 hours p.140

20 20 At present, 48 board feet of lumber, 20 finishing hours, 8 carpentry hours are available. A desk sells for $60, a table for $30, and a chair for $ 20. Dakota believes that demand for desks and chairs is unlimited, but at most 5 tables can be sold. Since the available resources have already been purchased, Dakota wants to maximize total revenue.

21 21 Example 2: Solution Define: x 1 = number of desks produced x 2 = number of tables produced x 3 = number of chairs produced The LP is: max z = 60x 1 + 30x 2 + 20x 3 s.t. 8x 1 + 6x 2 + x 3 ≤ 48 (lumber constraint) 4x 1 + 2x 2 + 1.5x 3 ≤ 20 (finishing constraint) 2x 1 +1.5x 2 + 0.5x 3 ≤ 8 (carpentry constraint) x 2 ≤ 5 (table demand constraint) x 1, x 2, x 3 ≥ 0

22 22 Convert the constraints to the standard form. Convert the objective function to the row 0 format. Add slack variables s 1, s 2, s 3, s 4 to the four constraints. Label the constraints row 1, row 2, row 3, row 4, Add the sign restrictions s i ≥ 0. Put rows 1-4 together in row 0.

23 23 Ex. 2: Solution (converting to standard form) Table 5 Canonical Form 0 Row Basic Variable 0z – 60x 1 – 30x 2 – 20x 3 = 0 z = 0 1 8x 1 + 6x 2 + x 3 + s 1 = 48 s 1 = 48 2 4x 1 + 2x 2 + 1.5x 3 + s 2 = 20 s 2 = 20 3 2x 1 + 1.5x 2 + 0.5x 3 + s 3 = 8 s 3 = 8 4 x 2 + s 4 = 5 s 4 = 5 max z = 60x 1 + 30x 2 + 20x 3 s.t. 8x 1 + 6x 2 + x 3 ≤ 48 (lumber constraint) 4x 1 + 2x 2 + 1.5x 3 ≤ 20 (finishing constraint) 2x 1 +1.5x 2 + 0.5x 3 ≤ 8 (carpentry constraint) x 2 ≤ 5 (table demand constraint) x 1, x 2, x 3 ≥ 0

24 24 We need a BV for row 0. Since z appears in row 0 with a coefficient of 1, and z does not appear in any other row, we use z as the BV. With this convention, the bfs for our initial canonical form has BV = {z, s 1, s 2, s 3, s 4 } NBV = {x 1, x 2, x 3 }. For this initial bfs, z=0, s 1 =48, s 2 = 20, s 3 =8, s 4 =5, x 1 =x 2 =x 3 =0. A slack variable can be used as a BV if the rhs of the constraint is nonnegative.

25 25 Ex. 2: Solution continued (Is the current bfs optimal?) We try to determine if there is any way z can be increased by increasing some NBV from its current value of zero while holding all other NBV at their current values of 0. Solving for z in row 0 yields: Z = 60x 1 + 30x 2 + 20x 3

26 26 For each NBV, we use this equation to determine if increasing a NBV will increase z. Increasing any of the NBV will cause an increase in z. However increasing x 1 causes the greatest rate of increase in z. If x 1 increases from its current value of zero, it will have to become a BV. x 1 is called the entering variable( 進入變數 ). Observe x 1 has the most negative coefficient in row 0.

27 27 Ex. 2 : Solution continued (Determine Entering Variable) Choose the entering variable to be the NBV with the most negative coefficient in row 0. Goal is to make x 1 as large as possible but as it increases, the current BV will change value. Thus, increasing x 1 may cause a BV to become negative. This means to keep all the BV nonnegative, the largest we can make x 1 is min {6, 5, 4} = 4.

28 28 Ex. 2: Solution continued (The Ratio Test) Rule for determining how large an entering variable can be. When entering a variable into the basis, compute the ratio for every constraint in which the entering variable has a positive coefficient. The constraint with the smallest ratio is called the winner of the ratio test. The smallest ration is the largest value of the entering variable that will keep all the current BV nonnegative.

29 29 Ex. 2: Solution continued (Find a new basic feasible solution) Always make the entering variable a BV in a row that wins the ratio test. To make x 1 a BV in row 3, we use elementary row operations (EROs) to make x 1 have a coefficient of 1 in row 3 and a coefficient of 0 in all other rows. This procedure is called pivoting on row 3; and row 3 is called the pivot row( 基準列 ). The final result is that x 1 replaces s 3 as the BV for row 3. The term in the pivot row that involves the entering BV is called the pivot term or positive element ( 基準元素 ).

30 30 To determine if the current bfs is optimal. Rearranging row 0 from Canonical Form 1, and solving for z yields z = 240 – 15x 2 +5x 3 -30s 3 The current bfs is NOT optimal because increasing x 3 to 1 (while holding the other NBV to zero) will increase the value of z. Making either x 2 or s 3 basic will cause the value of z to decrease.

31 31 Table 6 Canonical Form 1 RowBVratio 0'0'z +0 x 1 + 15x 2 – 5x 3 + 30s 3 = 240z = 240 1'1' – x 3 + s 1 - 4s 3 = 16s 1 = 16 2'2' - x 2 + 0.5 x 3 + s 2 - 2 s 3 = 4s 2 = 4 3'3' x 1 + 0.75x 2 + 0.25x 3 + 0.5s 3 = 4x 1 = 4 4'4' x 2 + s 4 = 5s 4 = 5 Table 5 Canonical Form 0 RowBVratio 0z – 60x 1 – 30x 2 – 20x 3 = 0 z = 0 1 8x 1 + 6x 2 + x 3 + s 1 = 48s 1 = 486 2 4x 1 + 2x 2 + 1.5x 3 + s 2 = 20s 2 = 205 3 2x 1 + 1.5x 2 + 0.5x 3 + s 3 = 8s 3 = 84 4 x 2 + s 4 = 5s 4 = 5- min EV LV

32 32 To determine the entering variable is the row 0 coefficient with the greatest negative value. Since x 3 is the only variable with a negative coefficient, x 3 should be entered into the basis. Performing the ratio test using x 3 as the entering variable yields the following results (holding other NBVs to zero): From row 1, s 1 ≥ 0 for all values of x 3 since s 1 =16 + x 3 From row 2, s 2 ≥ 0 if x 3 > 4 / 0.5 = 8 From row 3, x 1 ≥ 0 if x 3 >4 / 0.25 = 16 From row 4, s 4 ≥ 0 for all values of x 3 since s 4 = 5

33 33 This means to keep all the BV nonnegative, the largest we can make x 1 is min {8,16} = 8. So, row 2 becomes the pivot row. The result of using EROs, to make x 3 a BV in row 2.

34 34 Table 6 Canonical Form 1 RowBVratio 0'0'z +0 x 1 + 15x 2 – 5x 3 + 30s 3 = 240z = 240 1'1' – x 3 + s 1 - 4s 3 = 16s 1 = 16 2'2' - x 2 + 0.5 x 3 + s 2 - 2 s 3 = 4s 2 = 48 3'3' x 1 + 0.75x 2 + 0.25x 3 + 0.5s 3 = 4x 1 = 416 4'4' x 2 + s 4 = 5s 4 = 5- Table 7 Canonical Form 2 RowBVratio 0''z + 5x 2 + 10s 2 + 10s 3 = 280 z = 280 1'' - 2x 2 + s 1 + 2s 2 - 8s 3 = 24 s 1 = 24 2'' - 2x 2 + x 3 + 2s 2 - 4s 3 = 8 x 3 = 8 3'' x 1 + 1.25x 2 - 0.5 s 2 + 1.5s 3 = 2 x 1 = 2 4'' x 2 + s 4 = 5 s 4 = 5 min EV LV

35 35 In Canonical Form 2 BV = {z, s 1, x 3, x 1, s 4 } NBV = {s 3, s 2, x 2 } Yielding the bfs z = 280, s 1 =24, x 3 =8, x 1 =2, s 4 =5, s 2 =s 3 =x 2 =0 Solving for z in row 0 yields z = 280 - 5x 2 - 10s 2 -10s 3 We see that increasing x 2, s 2, or s 3 (while holding the other NBVs to zero) will not cause the value of z to decrease. The solution at the end of iteration 2 is therefore optimal. The following rule can be applied to determine whether a canonical form’s bfs is optimal. A canonical form is optimal (for a max problem) if each NBV a nonnegative coefficient in the canonical form’s row 0.

36 36 Exercise : p.149 #1 Use the simplex method to solve the LP : Initial Tableau BVzx1x1 x2x2 s1s1 s2s2 RHSRatio z1 -2-3000 s1s1 012106 s2s2 021018

37 37 BVzx1x1 x2x2 s1s1 s2s2 RHSRatio z 1 ‑ 1/2 03/209 x2x2 01/21 03 s2s2 03/20 ‑ 1/2 15 BVzx1x1 x2x2 s1s1 s2s2 RHSRatio z1 -2-3000 s1s1 0121066/2=3 LV s2s2 0210188/1=8 EV EROs

38 38 BVzx1x1 x2x2 s1s1 s2s2 RHSRatio z 1004/31/332/3 x2x2 0012/3 ‑ 1/3 4/3 x1x1 010 ‑ 1/3 2/310/3 BVzx1x1 x2x2 s1s1 s2s2 RHSRatio z 1 ‑ 1/2 03/209 x2x2 01/21 036 s2s2 03/20 ‑ 1/2 1510/3 LV EV the optimal solution is z = 32/3, x 1 = 10/3, x 2 = 4/3, s 1 = s 2 = 0.

39 39 4.6 Using the Simplex Algorithm to solve Minimization Problems Two different ways the simplex method can be used to solve minimization problems. Method 1 – Modified the LP to another form.  The optimal solution is the point (x 1,x 2 ) that makes z = 2x 1 – 3x 2 the smallest. Equivalently, this point makes max -z = - 2x 1 + 3x 2 the largest. min z = 2x 1 – 3x 2 s.t. x 1 + x 2 ≤ 4 x 1 – x 2 ≤ 6 x 1, x 2 ≥ 0 max -z = -2x 1 + 3x 2 s.t. x 1 + x 2 ≤ 4 x 1 – x 2 ≤ 6 x 1, x 2 ≥ 0 p.149

40 40 max -z = -2x 1 + 3x 2 s.t. x 1 + x 2 ≤ 4 x 1 – x 2 ≤ 6 x 1, x 2 ≥ 0 Initial Tableau BV- Zx1x1 x2x2 s1s1 s2s2 RHSRatio - Z 1 2-3000 s1s1 011104 s2s2 01016 -z + 2x 1 - 3x 2 = 0 x 1 + x 2 + s 1 = 4 x 1 – x 2 + s 2 = 6 x 1, x 2, s 1, s 2 ≥ 0

41 41 BV- Zx1x1 x2x2 s1s1 s2s2 RHSRatio - Z 1503012 x2x2 011104 s2s2 0201110 BV- Zx1x1 x2x2 s1s1 s2s2 RHSRatio - Z1 2-3000 s1s1 0111044/1=4 LV s2s2 01016 - EV EROs

42 42 The optimal solution (to the max problem) is - Z = 12, x 2 =4, s 2 =10, x 1 =s 1 =0. Then the optimal solution to the min problem is Z = -12, x 2 =4, s 2 = 10, x 1 =s 1 =0. The min LP objective function confirms this: Z =2x 1 -3x 2 =2(0)–3(4)= -12. BV-zx1x1 x2x2 s1s1 s2s2 RHSRatio z 1503012 x2x2 011104 s2s2 0201110

43 43 Summary Multiply the objective function for the min problem by -1 and solve the problem as a max problem with the objective function –z. The optimal solution to the max problem will be the optimal solution for the min problem. Remember that (optimal z-value for the min problem) = - (optimal z-value for the max problem).

44 44 Method 2 - A simple modification of the simplex algorithm can be used to solve min problems directly. Modify step 3 of the simplex algorithm If all NBV in row 0 have nonpositive coefficients, the current bfs is optimal. If any NBV has a positive coefficient, choose the variable with the “most positive” coefficient in row 0 as the entering variable. This modification of the simplex algorithm works because increasing a NBV with a positive coefficient in row 0 will decrease z. p.150

45 45 Exercise : p.151 #1 BVzx1x1 x2x2 s1s1 s2s2 s3s3 RHSRatio z1 -410000 s1s1 0211008 s2s2 0010105 s3s3 0 10014 Initial Tableau p.151

46 46 BVzx1x1 x2x2 s1s1 s2s2 s3s3 RHSRatio z1 -410000 s1s1 02110088 s2s2 00101055 LV s3s3 0 10014 - EV BVzx1x1 x2x2 s1s1 s2s2 s3s3 RHSRatio z 1-4000-5 s1s1 020103 x2x2 0010105 s3s3 0100119 EROs

47 47 The current tableau is optimal because each variable has a non-positive coefficient in the current tableau. The optimal solution is z = ‑ 5, s 1 = 3, x 2 = 5, s 3 = 9, x 1 = s 2 = 0. Observe that the optimal objective function value for an LP can be negative. BVzx1x1 x2x2 s1s1 s2s2 s3s3 RHSRatio z 1-4000-5 s1s1 020103 x2x2 0010105 s3s3 0 100119

48 48 Exercise :


Download ppt "Chapter 4 The Simplex Algorithm( 單體法 ) and Goal Programming Copyright (c) 2004 Brooks/Cole, a division of Thomson Learning, Inc."

Similar presentations


Ads by Google