Linear Programming: Simplex Method

Mathematical Modeling (STAT 420/620) Spring 2015
Lecture 10 – February 19, 2015
Linear Programming: Simplex Method
Lecture Plan
1. Linear Programming and Simplex Method
a. Family Farm Problem
b. Simplex Method in Maple
c. Dual Problem for Shadow Prices
d. Sensitivity Analysis
Home Work: Chapter 3, Sect. 3.5, Ex. 15 (due on Thursday, Feb. 26)
MATH420/620 – Lecture 10 – 1
1. Linear Programming: Simplex Method
MATH420/620 – Lecture 10 – 2
Lecture 10. The simplex method in linear programming
Maximizing or minimizing a function of many variables on a bounded region (i.e. subject to constraints)
is in general a very difficult problem. There are various schemes which work well on certain types of
problems, but there is no known method that works effectively on all optimization problems. We will
now discuss a method which is tailored to problems where the objective function (to be maximized or
minimized) is linear, and the constraints are linear. The method is called the simplex method. It is part of
a subject called linear programming.
Consider the following problem for an illustration:
f x1, x2, x3, x4, x5 = 5 x1 C 20 x2 C 4 x3 C 4 x4 C 11 x5
Find the maximum value subject to the constraints:
all variables are nonnegative
x1 C 2.4$x2 % 5.1
x1 C x2 % 2.2
x4 C 2.2$x2 % 2.7
x1 C 3.1$x2 C x3 % 4.7
1.2$x2 C 5.2$x4 % 5.6
x5 C 0.2$x1 % 3.4
To solve this by hand, here is how one might approach the problem.
The worst way:
Look for maxima inside by setting all partial derivatives to zero.
The feasibility region has 11 4-dim. faces, each defined by one of the equations
x1=0
...
x5=0
x1+2.4*x2=5.1
...
x5+.2*x1=3.4.
To check for a max on each face, one must do a Lagrange multiplier problem (with one constraint).
There is also the possibility that the max occurs at a point of intersection between two of these faces.
There are 55 combinations to worry about, and each of these requires a 2-constraint Lagrange multiplier
method.
There is also the possibility that 3 constraints hold, and there are 165 possibilities to try here.
4 constraints could hold, and there are 330 possibilities.
5 constraints could hold, and there are 462 possibilities.
Almost as bad of a method:
Because the fact that the gradients of f and all the constraint functions are linear, the gradients are
constant.
You can check that this implies the that max actually occurs at a vertex, i.e. an intersection of 5 faces.
(These are points where 5 of the 11 equalities hold. The reason for the number 5 is that it is the number
of variables in our problem.) There are 11!/(5!*(11-5)!)=462 verticies.
A good way to do it:
The simplex method is a very efficient method for finding the max/min among the vertices. (In fact, the
method avoids checking most vertices, zeroing in quickly on the optimal one.) With 3 lines of Maple and
around 0.5 seconds computing time, you can answer this question with the simplex method.
> with(simplex):
> f:= 5*x1 + 20*x2 + 4*x3 + 4*x4 + 11*x5;
f := 5 x1 C 20 x2 C 4 x3 C 4 x4 C 11 x5
> constraints := {x1+2.4*x2 <= 5.1, x1 + x2<=2.2, x4 + 2.2*x2<=2.7,
x1 + 3.1* x2 + x3<=4.7, 1.2*x2 + 5.2*x4 <= 5.6, x5+ .2*x1<=3.4};
constraints := x1 C x2 % 2.2, x1 C 2.4 x2 % 5.1, 1.2 x2 C 5.2 x4 % 5.6, x4 C 2.2 x2 % 2.7,
x5 C 0.2 x1 % 3.4, x1 C 3.1 x2 C x3 % 4.7
We haven't listed the nonnegativity constraints for the individual variables. Most linear programming
problems are set up so that the feasibility region only involves nonnegative coordinates, so Maple
includes a feature to save us from including these.
> s:=maximize(f, constraints, NONNEGATIVE);
s := x1 = 0., x2 = 0.8242187500, x3 = 2.144921875, x4 = 0.8867187500, x5 = 3.400000000
> assign(s): f;
66.01093750
(1)
(2)
(3)
(4)
Example 3.3 (Farm Problem):
> restart:
W:=3.0*x1+1.0*x2+1.5*x3: L:= 0.8*x1+0.2*x2+0.3*x3: T:=x1+x2+x3:
> z := 400*x1+200*x2+250*x3: #This is the total yield
> with(simplex): maximize(z,{W<=1000, L<=300, T<=625},NONNEGATIVE);
x1 = 187.5000000, x2 = 437.5000000, x3 = 0.
(5)
> assign(%):z;
1.625000000 105
(6)
Slack variables:
In linear programming problems, the term slack variable is used to describe the unutilized portion of a
constrained quantity. In our problem, the constraints have to do with water limitations, labor (man-hour)
limitations, and acreage limitations. We therefore have a slack variable for each of these.
Once we have assigned the optimal values to x1, x2, x3, Maple interprets W, L, and T to be the total
amounts of each of these resources used. The slack variables are simply 1000-W, 300-L, and 625-T.
Here is what they are at the optimal solution.
> 1000-W;300-L;625-T;
0.
62.5000000
0.
(7)
In other words, at these planting levels, all the water available is used, and all the land available is used,
but there 62.5 man-hours per week left unutilized.
Binding versus Non-binding:
Since the slack variables for water and acreage are zero, these constraints are binding. The labor
constraint is non-binding. The limitations on the labor resource are not in fact limiting the profit.
Shadow prices:
We have seen the term shadow price in our earlier discussion of the Lagrange multiplier method. For
each constrained resource (in our example, water, labor, and acreage), there is a shadow price which
reflects the extra yield that could be gained by increasing the quantity of the resource available by one
unit. The three shadow prices are exactly the values of the Lagrange multipliers associated to the three
constraint equations.
The simplex method command in Maple does not output these Lagrange multipliers, but there is a quick
way to get them, based on the dual linear programming problem. In the dual problem, there is a dual
variable associated to each constraint. The values of the dual variables for the solution to the dual
problem are the shadow prices.
We solve for the shadow prices as follows, beginning by unassigning x1, x2, and x3, so they'll be
variables again.
> x1:='x1':x2:='x2':x3:='x3':
> d:=dual(z,{W<=1000, L<=300, T<=625},y);
d := 625 y1 C 300 y2 C 1000 y3, 200 % y1 C 0.2 y2 C 1.0 y3, 250 % y1 C 0.3 y2 C 1.5 y3,
(8)
400 % y1 C 0.8 y2 C 3.0 y3
> minimize(d,NONNEGATIVE);
y1 = 100.0000000, y2 = 0., y3 = 100.
The dual variable y1=100, so the shadow price of water is $100.
(9)
This means that the farmer should be willing to buy additional water, if it is available, for a price of up to
$100/acre-ft. If the farmer pays more than this, the increased profit will not offset the increased cost.
Similarly, the farmer should not be willing to part with any of the existing 1000 acre-feet of water for less
than $100/acre-ft, since each acre-ft of water given up will decrease profit by $100.
The second dual variable y2=0, which means that the shadow price of labor is $0. The farmer would not
be willing to pay anything at all for additional labor. Indeed, some of the existing labor available is going
unutilized.
The third dual variable is y3=100. Thus the shadow price of land is $100/acre. The farmer would be
willing to lease additional land for up to $100 per acre, since each additional acre farmed provides and
additional $100 in the total yield (profit).
More general sensitivity analysis:
The shadow prices tell us the sensitivity of the total yield z with respect to each of the resource constraint
values. There are additional sensitivities we might like to calculate, such as the sensitivities of the planting
levels x1, x2, and x3 with respect to these values. Also, we might want the sensitivities of z, x1, x2, and
x3 with respect to other quantities, like the coefficients in the objective function or in the constraint
functions. These can be analyzed by redoing the problem after making a small change in the parameter in
the model. For example, consider obtaining one additional acre-ft of water.
Sensitivity Analysis -- one additional acre/foot of water (see p. 88)
> x1:='x1':x2:='x2':x3:='x3':
> maximize(z,{W<=1001, L<=300, T<=625},NONNEGATIVE);
x1 = 188.0000000, x2 = 437.0000000, x3 = 0.
(10)
> assign(%):z;1001-W;300-L;625-T;
1.626000000 105
0.
62.2000000
0.
(11)
A one unit change in water available produced a $100 increase in total yield z, as predicted by the shadow
price. The optimal x1 value (corn acreage) increased by 0.5 and the optimal x2 value (wheat acreage)
decreased by 0.5 acres. The optimal x3 value (oats acreage) remained unchanged at zero.
Letting c denote the maximum water resource (currently 1000 acre-ft), the sensitivities are calculated by
S(y,c)=(%change in y)/(% change in c), etc.
> S(y,c):= ((162600 - 162500)/162500 )/((1001 - 1000)/1000);
8
S y, c :=
(12)
13
> evalf(%);
0.6153846154
(13)
Since the sensitivity of z to c is 0.06, a 10% change in water available has about a 6% effect on the profit,
and the profit changes in the same direction as water availability.
For the sensitivity of the corn acreage x1,
> S(x1,c):= ((188 -187.5)/187.5 )/((1001 - 1000)/1000);
S 188.0000000, c := 2.666666667
(14)
Therefore the corn acreage is quite sensitive to the water availability. A 10% decrease in water would
cause around a 25% percent decrease in corn acreage.
Sensitivity Analysis -- higher yield for corn
> x1:='x1':x2:='x2':x3:='x3': z := 450*x1+200*x2+250*x3:
> maximize(z,{W<=1000, L<=300, T<=625},NONNEGATIVE);
x1 = 187.5000000, x2 = 437.5000000, x3 = 0.
> assign(%):z;1000-W;300-L;625-T;
1.718750000 105
0.
62.5000000
0.
> x1:='x1':x2:='x2':x3:='x3':
> d:=dual(z,{W<=1000, L<=300, T<=625},y);
d := 625 y1 C 300 y2 C 1000 y3, 200 % y1 C 0.2 y2 C 1.0 y3, 250 % y1 C 0.3 y2 C 1.5 y3,
450 % y1 C 0.8 y2 C 3.0 y3
> minimize(d,NONNEGATIVE);
y1 = 75.00000000, y2 = 0., y3 = 125.0000000
Sensitivity Analysis -- higher yield for oats
> x1:='x1':x2:='x2':x3:='x3': z := 400*x1+200*x2+260*x3:
> maximize(z,{W<=1000, L<=300, T<=625},NONNEGATIVE);
x1 = 41.66666667, x2 = 0., x3 = 583.3333333
> assign(%):z;1000-W;300-L;625-T;
1.683333334 105
0.
91.6666667
0.
> x1:='x1':x2:='x2':x3:='x3':
> d:=dual(z,{W<=1000, L<=300, T<=625},y);
d := 625 y1 C 300 y2 C 1000 y3, 200 % y1 C 0.2 y2 C 1.0 y3, 260 % y1 C 0.3 y2 C 1.5 y3,
400 % y1 C 0.8 y2 C 3.0 y3
> minimize(d,NONNEGATIVE);
y1 = 120.0000000, y2 = 0., y3 = 93.33333333
(15)
(16)
(17)
(18)
(19)
(20)
(21)
(22)
Sensitivity Analysis -- new variety of corn
> x1:='x1':x2:='x2':x3:='x3':
> W:=2.5*x1+1.0*x2+1.5*x3: z := 400*x1+200*x2+250*x3:
> maximize(z,{W<=1000, L<=300, T<=625},NONNEGATIVE);
x1 = 250.0000000, x2 = 375.0000000, x3 = 0.
> assign(%):z;1000-W;300-L;625-T;
1.750000000 105
0.
25.0000000
0.
> x1:='x1':x2:='x2':x3:='x3':
(23)
(24)
> d:=dual(z,{W<=1000, L<=300, T<=625},y);
d := 625 y1 C 300 y2 C 1000 y3, 200 % y1 C 0.2 y2 C 1.0 y3, 250 % y1 C 0.3 y2 C 1.5 y3,
400 % y1 C 0.8 y2 C 2.5 y3
> minimize(d,NONNEGATIVE);
y1 = 66.66666667, y2 = 0., y3 = 133.3333333
(25)
(26)
Sensitivity Analysis -- new crop, barley
>
>
>
>
x1:='x1':x2:='x2':x3:='x3': W:=3.0*x1+1.0*x2+1.5*x3+1.5*x4:
L:= 0.8*x1+0.2*x2+0.3*x3+0.25*x4: T:=x1+x2+x3+x4:
z := 400*x1+200*x2+250*x3+200*x4:
maximize(z,{W<=1000, L<=300, T<=625},NONNEGATIVE);
x1 = 187.5000000, x2 = 437.5000000, x3 = 0., x4 = 0.
> assign(%):z;1000-W;300-L;625-T;
1.625000000 105
0.
62.5000000
0.
> x1:='x1':x2:='x2':x3:='x3':
> d:=dual(z,{W<=1000, L<=300, T<=625},y);
d := 625 y1 C 300 y2 C 1000 y3, 200 % y1 C 0.2 y2 C 1.0 y3, 250 % y1 C 0.3 y2 C 1.5 y3,
400 % y1 C 0.8 y2 C 3.0 y3
> minimize(d,NONNEGATIVE);
y1 = 100.0000000, y2 = 0., y3 = 100.
(27)
(28)
(29)
(30)