Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Examples of linear programming problems: single source shortest paths, maximum flow,
minimum flow, multicommodity path.
For example:
i=1
Linear constraints are linear inequalities and/or linear equalities. For example, a-b 4.
We saw them in ch.24, when we were solving the difference constraint problems.
All solutions to this set of inequalities lie in the area bounded by the above inequalities.
(Draw it). The optimal solution is the highest point of that area that intersects with the
line a+b=z. The value of z should be as high as possible.
When there are more variables, then each inequality forms a shape in space. The
intersection of the area bounded by those spaces is called a simplex. The objective
function is now a multi-dimensional plane The intersection of the simplex and the
objective function is again through multiple points, however, one point has the highest
value for the objective function. The simplex algorithm starts with some feasible
solution and optimizes it until it finds the highest value of the objective function. In this
case, that local maximum is also the global maximum.
Simplex algorithm requires that the linear programming problem be set up in slack form.
Linear program can be converted from any form into standard form, and then into slack
form.
ax b
ij j i is equivalent to -a x -b
ij j i
Linear program in slack form uses only equalities for constraints, except for the
non-negativity constraints.
The basic solution to a linear program is obtained by setting all non-basic variables to 0
and calculating basic variables.
Simplex(L) {
while the objective value for the basic solution can be increased {
reformulate lin.prog. so that the basic solution has greater objective value
}
return the basic solution
}
Simplex(L) {
while there are variables to pivot {
pivot
}
return the basic solution
}
//assume that L is a linear program in slack form
Simplex(L) {
//while there are variables to pivot
while objective function has positive coefficients{
//pivot
//select non-basic variable x whose coefficient in the
objective function is positive
//increase its value without violating any constraints
find basic solution, find how much we can increase,
pick the equation that allows that increase
//swap x with another basic variable: set x as basic, and
make the other variable non-basic
//rewrite all constraints with x as basic
}
return the basic solution
}
Example p.791:
Maximize z = 3a + b + 2c
Subject to: 1. a + b + 3c 30
2. 2a + 2b + 5c 24
3. 4a + b + 2c 36
4. a,b,c 0
In slack form:
Maximize z = 3a + b + 2c
Subject to: d = 30 a b - 3c
e = 24 - 2a - 2b - 5c
f = 36 - 4a - b - 2c
a,b,c, d,e,f 0
1. Pivot using a.
When we substitute the basic solution into inequality 1, a 30. From 2., a 24/2
= 12. From 3., a 9. Therefore, we can increase a only by 9. So we swap a and f by
rewriting 4. as a = 9 b/4 c/2 f/4 and substituting it into all other constraints.
Maximize z = 3(9-b/4 c/2 f/4) + b + 2c
Subject to: d = 30 (9-b/4 c/2 f/4) b - 3c
e = 24 - 2(9-b/4 c/2 f/4) - 2b - 5c
a = 9 -b/4 c/2 f/4
a,b,c, d,e,f 0
The basic solution is b = 0, c = 0, f=0, a = 9, d = 21, e = 6 i.e. (9,0,0, 21, 6,0). z = 27.
The basic solution is b = 0, e = 0, f=0, a = 33/4, c = 3/2, d=69/4 i.e. (33/4,0,3/2, 69/4, 0).
z = 111/4.
1. Pivot using b.
The three constraints give bounds of 132,4, and infinity (because d increases as b
increases). Therefore rewrite 2 and swap b and c.
Since the objective function has no non-negative coefficients, this is the optimal solution.
Issues:
1. how do we determine if a linear program is feasible
2. what if the linear program is feasible but the initial basic solution is not feasible
3. how do we determine if a linear program is unbounded (i.e. optimal objective
value is infinity)
4. how do we chose which variables to swap.
Some answers:
The initial basic solution is a=b=0, but it violates the second constraint, so it is not a
feasible solution.
Maximize -x0
Subject to: N
ax ij j - x0 bi and all xj 0 for all j
j=1
The original linear problem is feasible iff the optimal objective value of the auxiliary
problem is 0.
Maximize x0
Subject to 2a b -x0 2
a 5b -x0 -4
a,b, x0 0
z = x0
Subject to c = 2 - 2a + b + x0
d = -4 - a + 5b + x0
a,b, x0, c, d 0
2. find an initial basic solution that is feasible by swapping x0 with the basic variable
whose value in the basic solution is most negative.
In this case, d:
z = -4 a + 5b d
x0 = 4 +a -5b + d
c = 6 a 4b + d
a,b, x0, c, d 0
Basic solution: a=b=d=0, z=4, c=6, which is feasible. So, keep on running PIVOT until
the optimal solution to the auxiliary problem is found.
Swap x0 and b:
z = -x0
b = 4/5 x0/5 + a/5 + d/5
c = 14/5 + 4x0/5 9a/5 + d/5
a,b, x0, c, d 0
No more swaps, so this is the optimal solution, z=0. Therefore, the initial linear problem
was feasible.
So, now go back to the original linear problem, but using only non-basic variables from
the auxiliary problem:
The basic solution is a=d =0, b=4/5, c=14/5, z=4/5, which is feasible, so then keep on
running the SIMPLEX.
The book continues with this example for one more iteration, which has a feasible basic
solution.
The next iteration does not have a feasible basic solution, so the whole process of
formulating an auxiliary problem has to be repeated
If we draw the problem, we can see that there is no finite solution anyways:
Maximize 2a b
Subject to 2a b The acceptable region is above or on the blue line
2
a 5b -4 the acceptable region is above or on the purple line
a,b 0 and only in the first quadrant
a 2a-b=2 a-5b=-4
0 -2 0.8
1 0 1
2 2 1.2
3 4 1.4
4 6 1.6
5 8 1.8
6 10 2
7 12 2.2
8 14 2.4
10 18 2.8
20 38 4.8
Therefore, there is no finite solution to this problem. The solution is on the blue line as the blue line reaches infinity.
Why? Because there are only two inequalities, and then do not define an area that is bounded.
If the second constraint was such that the lines formed a bounded area, then there would be a finite optimal solution.
ANOTHER EXAMPLE:
Solve the following linear program using SIMPLEX algorithm:
Minimize z = a + b + c
Maximize z = -a - b - c
Subject to: 1. a-b-c 0
2. -a - b - c -4
3. a+b-c2
-a-b+c -2
4. a, b 0
5. c = d-f
6. d, e 0
In slack form:
Maximize z = -a - b d + f
Subject to: 1. g = -a + b + d - f
2. h = -4 + a + b + d - f
3. j=2-a-b+d-f
4. k = -2 + a + b - d + f
5. a, b, d, f , g, h, j, k 0
Basic solution: a=0, b=0, d=0, f=0, z=0; g=0, h=-4, j=2, k=-2
This is not possible, because all variables have to be non-negative. So, we
cannot do anything starting with the basic solution of all 0s. We would
have to start with another basic solution.
So, this is as far as we would get with the high-level pseudocode of Simplex
algorithm. In order to fully solve it, we would have to actually trace the
pseudocode in detail.
Maximize x0
Subject to: 1. a - b d + f x0 0
2. -a - b d + f -x0 -4
3. a + b d + f x0 2
4. -a-b+ d - f x0 -2
5. a, b, d, f, x0 0
In slack form:
Maximize z = -x0
Subject to: 1. g = -a + b + d - f +x0
2. h = -4 + a + b + d - f + x0
3. j = 2 - a - b + d - f + x0
4. k = -2 + a + b - d + f + x0
5. a, b, d, f , g, h, j, k, x0 0
Switch x0 and h:
x0 = 4-a-b-d+f +h
Basic solution: a=b=d=f=h=0, x0=4, g=4, j=2, k=2. This solution is feasible.
Maximize z = -4+a+b+d-f-h
Subject to: 1. g = -a + b + d - f + 4-a-b-d+f +h = 4-2a +h
2. x0 = 4-a-b-d+f +h
3. j = 2 - a - b + d - f + 4-a-b-d+f +h = 6-2a 2b +h
4. k = -2 + a + b - d + f + 4-a-b-d+f +h = 6 2d +2f +h
5. a, b, d, f , g, h, j, k, x0 0
>About the example from p.791: How are different iterations of while loop
>different?
Now we have equalities, and the left side is the slack. That slack can be
varied. The goal is to have that slack as low as possible, ideally 0, i.e. to
come as close as possible to the = side of the original inequalities. In fact,
slack=0 is ideal, that is the maximum, but then other constraints will limit how
much we can "creep up".
So, you plug in on the right side, set slack to 0, and see how much you can
"creep up":
So that's why we do constraint 1 as:
Since we are trying to get the slack to be as close to 0 as possible, taking into
account all constraints, the next step is to determine which equation allows us
to reduce slack as much as possible without violating any other constraints.
So, we pick the smallest increase in c.
In summary: the procedure for every iteration of while loop is the same. The
main idea is to creep up towards reducing the slack and thus keep on
coming to the edge, i.e. the equality part, of the original inequalities. This is a
very commonly used approach: start from some solution, and try to come
closer and closer to the optimal solution.