Академический Документы
Профессиональный Документы
Культура Документы
Fall 2010
Assumptions in LP problems
1500
MWa+s
1000
MWa+s
F1
PP1
750
MWa+s
F2
2000
MWa+s
PP2
750
MWa+s
F3
Capacity
Demand
Modeling Examples
F1 F2 F3
PP1 50 100 60
PP2 30 20 35
How should we satisfy the demand of each factory from the two
power plants with minimum total cost?
The unknown values are the amount of electricity supplied from
each power plant to each factory.
Let xij denote the (unknown) # of MWatts of electricity
transmitted from PPi to Fj , i = 1, 2; j = 1, 2, 3.
Modeling Examples
Gas Sales price per barrel Crude oil Purchase price per barrel
1 70 1 45
2 60 2 35
3 50 3 25
Process cost = 4(x11 + x12 + x13 + x21 + x22 + x23 + x31 + x32 + x33 )
Hence the objective is:
max 70(x11 + x21 + x31 ) + 60(x12 + x22 + x32 )
+50(x13 + x23 + x33 ) − 45(x11 + x12 + x13 )
−35(x21 + x22 + x23 ) − 25(x31 + x32 + x33 )
−4(x11 + x12 + x13 + x21 + x22 + x23 + x31 + x32 + x33 )
s.t.
Demand constraints
x11 + x21 + x31 = 4000,
x12 + x22 + x32 = 5000,
x13 + x23 + x33 = 3000,
Modeling Examples
Purchase constraints
x11 + x12 + x13 ≤ 5000,
x21 + x22 + x23 ≤ 5000,
x31 + x32 + x33 ≤ 5000,
Capacity constraint
x11 + x12 + x13 + x21 + x22 + x23 + x31 + x32 + x33 ≤ 14, 000
Octane requirements
12x11 +6x21 +8x31
Gas 1 x11 +x21 +x31 ≥ 10 =⇒
12x11 + 6x21 + 8x31 − 10(x11 + x21 + x31 ) ≥ 0
2x11 − 4x21 − 2x31 ≥ 0
Modeling Examples
2x1 + x2 ≤ 100
x1 + x2 ≤ 80
x1 ≤ 40
x1 ≥ 0
x2 ≥ 0
7x1 + 2x2 ≥ 28
2x1 + 12x2 ≥ 24
x1 , x2 ≥ 0
Graphical Solution of 2-variable LP Problems
x 1 + x2 ≤ 7
−x1 + 2x2 ≤ 8
x1 ≤ 4
x1 ≥ 0
x2 ≥ 0
Note that the total cost increases in this direction. Since we have
a minimization problem, this is, hence, not the direction that we
want to move. We should move in the opposite direction, i.e. in
the direction of
−1
−c =
−2
In other words, for a minimization problem, we go in the opposite
direction of c (i.e. in the direction of −c as much as possible while
still remaining in the feasible region.
Graphical Solution of 2-variable LP problems
7 14
{λ + (1 − λ) : λ ∈ [0, 1]}
2 0
Graphical Solution of 2-variable LP problems
The company must decide how many cars and trucks should be
produced daily.
x1 : # of trucks produced daily.
x2 : # of cars produced daily.
The company maximizes profits. In hundreds of dollars, the
objective function can be written as 3x1 + 2x2 .
There are two constraints based on the capacity of the paint and
body shops. For both departments, the fraction of day allocated to
truck and car production must not exceed 1. Hence the constraints
are:
1 1
40 x1 + 60 x2 ≤1
1 1
50 x1 + 50 x2 ≤1
Graphical Solution of 2-variable LP problems
2x1 + 3x2 + x3 ≤ 5
4x1 + x2 + 2x3 ≤ 11
3x1 + 4x2 + 2x3 ≤ 8
x 1 , x 2 , x3 ≥ 0
The Simplex Method
s1 = 5 − 2x1 − 3x2 − x3
s2 = 11 − 4x1 − x2 − 2x3
s3 = 8 − 3x1 − 4x2 − 2x3
Ratio Test
It makes sense to increase the value of x1 because it offers the
highest amount of increase in z per unit of perturbation. As we
increase x1 , we keep x2 and x3 at their initial values of 0. In doing
so, we need to pay attention to the constraints as well. We cannot
perturb x1 in violation of the constraints. So the question is: How
much can we increase x1 ?
The new solution will still be feasible as long as each of the original
and slack variables is still non-negative. Now, going back to the
first dictionary,
s1 = 5 − 2x1 − 3x2 − x3 = 5 − 2x1 ≥ 0 =⇒ x1 ≤ 5/2
s2 = 11 − 4x1 − x2 − 2x3 = 11 − 4x1 ≥ 0 =⇒ x1 ≤ 11/4
s3 = 8 − 3x1 − 4x2 − 2x3 = 8 − 3x1 ≥ 0 =⇒ x1 ≤ 8/3.
The Simplex Method
Note that the second feasible solution has indeed a larger objective
function value than the first feasible solution.
However, our search for the optimal solution is probably not over!
The Simplex Method
Now, we shall look for an even better solution than the second
feasible solution. Note that, in Dictionary 1, each of the variables
x1 , x2 and x3 was on the RHS and had a value of 0. As such, the
same was true for the objective function.
This enabled us to quickly identify which variables should be
increased from their current value of zero to obtain the largest
increase in the objective function value.
To do the same, we shall rearrange dictionary 1, so that only the
variables which are 0 in the second feasible solution will be on the
RHS. In feasible solution #2, x2 = 0, x3 = 0 and s1 = 0.
The Simplex Method
The same should be repeated for other rows as well. Note that, s2
and s3 are still in the LHS and they should remain so. But x1
should no longer be on the RHS of rows 2 and 3. To this end, we
could substitute (??) in rows 2 and 3 of dictionary #1. In the end,
only x2 , x3 and s1 will appear on the LHS of rows 2 and 3.
The Simplex Method
Substituting,
s2 = 11 − 4x1 − x2 − 2x3
5 3 1 1
= 11 − 4( − x2 − x3 − s1 ) − x2 − 2x3
2 2 2 2
= 1 + 5x2 + 2s1
and
25 7 1 5
Row 0 z = 2
− x
2 2
+ x
2 3
− s
2 1
5 3 1 1
Row 1 x1 = 2
− x
2 2
− x
2 3
− s
2 1
1 1 1 3
Row 3 s3 = 2
+ x
2 2
− x
2 3
+ s
2 1
The Simplex Method
Observe that in dictionary #2, only variables with zero values are
on the RHS of each of the four rows.
By looking at row 0, we see that only increasing x3 from 0 yields
an even larger objective function value. This is not the case for the
other variables. As in the previous case, we first decide how much
x3 can be increased while keeping x2 and s1 at 0.
The Simplex Method
To see this,
5
x1 = 2 − 32 x2 − 12 x3 − 12 s1 = 5
2 − 21 x3 ≥ 0 =⇒ x3 ≤ 5.
s2 = 1 + 5x2 + 2s1 = 1 ≥ 0 =⇒ No restriction!
1
s3 = 2 + 12 x2 − 21 x3 + 32 s1 = 1
2 − 12 x3 ≥ 0 =⇒ x3 ≤ 1
Note that row #2 imposes no restriction on how much x3 can be
increased. Clearly, the most restrictive bound is given by row 3. It
says that you can increase x3 at most by 1 without violating
feasibility. With this in mind, the third feasible solution is:
x1 = 2, x2 = 0, x3 = 1,
s1 = 0, s2 = 1, s3 = 0,
25
with an objective function value of z = 2 + 12 x3 = 13. This is an
improvement!
The Simplex Method
5 3 1 1
Row 1 =⇒ x1 = − x 2 − x3 − s 1
2 2 2 2
5 3 1 1
= − x2 − (1 + x2 + 3s1 − 2s3 ) − s1
2 2 2 2
x1 = 2 − 2x2 − 2s1 + s3 .
The Simplex Method
Row 0 z = 13 − 3x2 − s1 − s3
Row 1 x1 = 2 − 2x2 − 2s1 + s3
Row 2 s2 = 1 + 5x2 + 2s1
Row 3 x3 = 1 + x2 + 3s1 − 2s3
The Simplex Method
The simplex method works only with bfs’s and ignores all other
feasible solutions.
Note that, a basic feasible solution ≡ corner point.
The Simplex Method
Define,
a11 a12 · · · a1n
x1 b1
a21 a22 · · · a2n x2 b2
A= x = b=
................... .. ..
. .
am1 am2 · · · amn xn bm
and,
c= c1 c2 · · · cn
max cx s.t. Ax = b, x ≥ 0
The Simplex Method
Definition (6)
Any basic solution to Ax = b in which all variables are nonnegative
is a basic feasible solution.Two bfs’s are neighbors if they share
m − 1 of their basic variables.
The Simplex Method
Why are basic feasible solutions important? The reason is,
Theorem (1)
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.
Theorem (2)
For any LP, there is a unique extreme point of the LP’s feasible
region corresponding to each basic feasible solution. Also, there is
at least one bfs corresponding to each extreme point of the feasible
region.
min z = x1 + x2
s.t. x1 + 2x2 + x3 = 4,
x2 + x4 = 1,
x 1 , x 2 , x3 , x4 ≥ 0
The Simplex Method
So A matrix in this problem is,
1 2 1 0
A = [a1 , a2 , a3 , a4 ] =
0 1 0 1
Let’s resolve the LP problem using the simplex method. The first
dictionary is:
Our usual test for a max. problem suggests that we can improve
this objective function value further by perturbing x2 in the
positive direction while keeping x1 = 0.
s1 = 2 + x1 − x2 = 2 − x2 ≥ 0 =⇒ x2 ≤ 2
s2 = 4 − x1 − x2 = 4 − x2 ≥ 0 =⇒ x2 ≤ 4
Row 0 z = 4 − 2s1
Row 1 x2 = 2 + x1 − s1
Row 2 s2 = 2 − 2x1 + s1
z = 4 − 2s1
The third dictionary is:
Row 0 z = 4 − 2s1
1 1
Row 1 x2 = 3 − 2 s1 − 2 s2
1 1
Row 2 x1 = 1 + 2 s1 − 2 s2
Note that we have found another bfs with the same optimal value.
Therefore, we have alternate optimal solutions. Feasible solution 2
and 3 are both optimal solutions along with any feasible solution
that lies on the line segment joining them.
In addition, Dictionary 2 or Dictionary 3 can be used to find other
optimal solutions that are not necessarily bfs’s.
Consider Dictionary 2 below:
Row 0 z = 4 − 2s1
Row 1 x2 = 2 + x1 − s1
Row 2 s2 = 2 − 2x1 + s1
The Simplex Method
0 1
2 3
{(1 − α)
0 + α
: α ∈ [0, 1]}
0
2 0
10 1 1 1
Row 1 s1 = 3 + 6 s2 − 6 x2 + x3 − 6 x4
5 1 5 1
Row 2 x1 = 3 − 6 s2 − 6 x2 + 6 x4
Row 2 x1 = 5 − x2 + x3 − s1
The Simplex Method
s3 = 4 − 4x2 ≥ 0 =⇒ x2 ≤ 1
The last constraint is the most restrictive one. x2 enters the basis,
while s3 leaves it. We make the necessary rearrangements,
x2 = 1 + 41 s2 + 34 x1 − 14 s3 + 34 x3
s1 = 9 + s2 − 2(1 + 41 s2 + 34 x1 − 41 s3 + 34 x3 ) − x3
s1 = 7 + 12 s2 − 32 x1 + 21 s3 − 25 x3
The Simplex Method: Two Phase (Stage)
a = 5 + s2 + 2x1 − 3(1 + 14 s2 + 34 x1 − 41 s3 + 43 x3 ) + x3
a = 2 + 14 s2 − 14 x1 + 34 s3 − 45 x3
z = 5 + s2 + 2x1 − 3(1 + 14 s2 + 34 x1 − 41 s3 + 34 x3 ) + x3
z = 2 + 41 s2 − 14 x1 + 34 s3 − 45 x3
The current dictionary is,
1 1 3 5
Row 0 z = 2 + 4 s2 − 4 x1 + 4 s3 − 4 x3
1 3 1 5
Row 1 s1 = 7 + 2 s2 − 2 x1 + 2 s3 − 2 x3
1 1 3 5
Row 2 a = 2 + 4 s2 − 4 x1 + 4 s3 − 4 x3
1 3 1 3
Row 3 x2 = 1 + 4 s2 + 4 x1 − 4 s3 + 4 x3
The Simplex Method: Two Phase (Stage)
The current solution is, s1 = 7, a = 2, x2 = 1 (basic variables)
whereas x1 = x3 = s2 = s3 = 0 (nonbasic variables). The objective
function value is z = 2. We could further increase x3 to decrease
the objective function further. Only the first two rows impose a
constraint on x3 .
s1 = 7 − 52 x3 ≥ 0 =⇒ x3 ≤ 14
5
a = 2 − 54 x3 ≥ 0 =⇒ x3 ≤ 8
5
Rearranging rows,
8
x3 = 5 + 15 s2 − 51 x1 + 35 s3 − 54 a
s1 = 7 + 12 s2 − 23 x1 + 12 s3 − 52 ( 85 + 15 s2 − 15 x1 + 53 s3 − 45 a)
s1 = 3 − x1 − s3 + 2a
x2 = 1 + 14 s2 + 34 x1 − 14 s3 + 34 ( 85 + 15 s2 − 15 x1 + 35 s3 − 45 a)
x2 = 11 2 3 1 3
5 + 5 s 2 + 5 x1 + 5 s 3 − 5 a
The Simplex Method: Two Phase (Stage)
z = 2 + 41 s2 − 14 x1 + 43 s3 − 54 ( 85 + 15 s2 − 51 x1 + 35 s3 − 45 a) = a
The associated dictionary is:
Row 0 z = a
Row 1 s1 = 3 − x1 − s3 + 2a
8 1 1 3 4
Row 2 x3 = 5 + 5 s2 − 5 x1 + 5 s3 − 5a
11 2 3 1 3
Row 3 x2 = 5 + 5 s2 + 5 x1 + 5 s3 − 5a
Row 1 s1 = 3 − x1 − s3
8 1 1 3
Row 2 x3 = 5 + 5 s2 − 5 x1 + 5 s3
11 2 3 1
Row 3 x2 = 5 + 5 s2 + 5 x1 + 5 s3
a = 6 − x2 ≥ 0 =⇒ x2 ≤ 6
14
Therefore, we increase x2 to 3 . Making the necessary
arrangements,
The Simplex Method: Two Phase (Stage)
4 2 1 1
Row 0 z = 3 + 3 s3 − 3 x1 + 3 s2
8 1 5 2
Row 1 s1 = 3 + 3 s3 − 3 x1 + 3 s2
14 1 1 1
Row 2 x2 = 3 + 3 s3 + 3 x1 − 3 s2
4 2 1 1
Row 3 a = 3 + 3 s3 − 3 x1 + 3 s2
4
a= 3 − 13 x1 ≥ 0 =⇒ x1 ≤ 4.
Increasing x1 to 58 and making s1 nonbasic in the process, we
obtain the dictionary,
4 3 1 1
Row 0 z = 5 + 5 s3 + 5 s1 + 5 s2
8 1 3 2
Row 1 x1 = 5 + 5 s3 − 5 s1 + 5 s2
26 2 1 1
Row 2 x2 = 5 + 5 s3 − 5 s1 − 5 s2
4 3 1 1
Row 3 a = 5 + 5 s3 + 5 s1 + 5 s2
The Simplex Method: Two Phase (Stage)