LPexercisesCorrection
LPexercisesCorrection
CORRECTION
This week the company has to produce 1050 assembled products, but up
to 1200 assembled products can be produced if necessary. During the week,
department 1 has 100 working hours available, but department 2 has 110 working
hours available. The storage space of the company can only store at most 200
unassembled production parts of all types at the end of the week. Any fractional
parts are accepted. Formulate the problem of minimizing the cost of producing
the assembled products needed this week as a linear program.
Solution
Obviously, we may not need to use of all the available working time. Therefore
we need to decide the amount of time given over to the production of parts in
each department. Let
1
2
Note that 22x1 + 22x2 is the total amout of production parts produced (i.e.,
(7x1 + 6x2 ) + (6x1 + 11x2 ) + (9x1 + 5x2 )).
Workstation
W1 W2 W3 W4
Production 1 5 7 4 10
Production 2 6 12 8 15
Production 3 7 12 9 11
The profit contribution (in USD) per unit varies from workstation to workstation
as given in Table 3.
Workstation
W1 W2 W3 W4
Production 1 10 8 6 9
Production 2 16 15 18 20
Production 3 13 16 19 10
In this week there are 35 working hours available at each workstation. The
customers need at least 100 units of product 1, 150 units of product 2, and
100 units of product 3, but they promise buying all produced products. Any
product fractions are accepted. Formulate the problem of maximizing the profit
of producing the products needed this week as a linear program.
Solution
One might think that the variables should be the amount of each product to
make. However, on closer inspection, it is clear that we need to decide how much
of each product to make at each workstation. Hence we let
M1 M2
P1 10 25
P2 13 20
P3 15 27
P4 9 33
The profit per unit for each product P1, P2, P3, P4 is 10, 12, 17, and 8 (USD)
respectively. Product P1 must be produced on both machines M1 and M2, but
the other products can be produced on either machine M1 or machine M2.
The factory is very small and this means that floor space is very limited. Only
one week’s production is stored in 50 square metres of floor space where the floor
space taken up by each product is 0.1, 0.15, 0.5 and 0.05 (square metres) for
products P1, P2, P3, and P4 respectively.
Customer requirements mean that the amount of product P3 produced should
be related to the amount of product P2 produced. Over a week exactly twice as
many units of product P2 should be produced as product P3.
Machine M1 is out of action for maintenance 5% of the time and machine M2
7% of the time.
Assuming a working week 35 hours long, formulate the problem of how to
manufacture these products to maximize total profit as a linear program.
Solution
4
min x1 − x2 + x3
s.t. x1 + 2x2 − x3 ≤3
−x1 + x2 + x3 ≥2
x1 − x2 = 10
x1 ≥0
x2 ≤0
Solution
−
By setting y2 = −x2 we get non-negative variable y2 . By setting x3 = x+
3 − x3
−
with x3 , x3 ≥ 0 we replace the unrestricted variable x3 by two non-negative
+
−
variables x+
3 , x3 . The formulation after transforming is as follows.
−
max −x1 − y2 − x+ 3 − x3
−
s.t. x1 − 2y2 − x+ 3 + x3 ≤3
−
x1 + y 2 − x+ 3 − x3 ≤ −2
x1 + y 2 ≤ 10
−x1 − y2 ≤ −10
−
x1 , y 2 , x +
3 , x3 ≥0
Exercise 6. (a) Transform the following LP into maximizing problem with un-
restricted variables.
s.t. x1 + 2x2 ≥4
x1 − x3 ≤5
x1 ≤0
x2 , x 3 ∈R
(b) Transform the LP in part (a) into minimizing problem with equality con-
straints.
Solution
(a) By setting x1 = y1 − z1 and replacing constraint x1 ≤ 0 by y1 − z1 ≤ 0,
we get rid of sign constraint on x1 . We come up with the following formulation.
(b) Adding slack variables to inequality constraints and change the sign of
objective function, we get the desired formulation as follows.
2D linear programs
Exercise 7. Solve the following linear program with a graphical representation.
max x1 + 2x2
s.t. 2x1 + 3x2 ≤ 12
6x1 + 5x2 ≤ 30
x2 ≤3
x1 , x 2 ≥0
Solution
Optimal solution is (1.5, 3) and optimal objective value is 7.5.
x2
6x1 + 5x2 = 30
opt = (1.5, 3)
x2 = 3
x1 + 2x2 = 7.5
x1
0 2x1 + 3x2 = 12
x1 + 2x2 = 0
min x1 + 3x2
s.t. x1 + x2 ≥3
−x1 + x2 ≤ −1
x1 + 2x2 ≤6
x1 , x 2 ≥0
Solution
Optimal solution is (3, 0) and optimal objective value is 3.
8
x2
−x1 + x2 = −1
x1 + 3x2 = 0
x1
0
x1 + 2x2 = 6
x1 + x2 = 3
max x1 + 3x2
s.t. x1 + x2 ≥ 3
−x1 + x2 ≤ −1
x1 , x 2 ≥ 0
Solution
The feasible set is unbounded and the objective value tends to +∞.
x2
−x1 + x2 = −1
x1 + 3x2 → +∞
x1 + 3x2 = 0
x1
0
x1 + x2 = 3
Simplex method
Exercise 10. Solve the following LP by using simplex method.
Solution
The first step is to transform the inequalities into equalities by introducing
non-negative slack variables x4 , x5 , x6 ≥ 0:
max z
s.t. x4 = 5 − 2x1 − 3x2 − x3 ←
x5 = 11 − 4x1 − x2 − 2x3
x6 = 8 − 3x1 − 4x2 − 2x3 (2)
z = 5x1 + 4x2 + 3x3
↑
x1 , x 2 , x 3 , x 4 , x 5 , x 6 ≥0
x4 = 5 − 2x1 ≥ 0 x1 ≤ 5
2
x5 = 11 − 4x1 ≥ 0 or equivalently x1 ≤ 11
4
x6 = 8 − 3x1 ≥ 0 x1 ≤ 8
3
max z
s.t. x3 = 9 − x1 − 3x2 ←
x4 = 12 − 2x1 − 3x2
z= x1 + 2x2
↑
x1 , x 2 , x 3 , x 4 ≥ 0
In this dictionary, x3 and x4 are basic variables, while x1 and x2 are non-basic
ones. If we set zero value to the non-basic variables, then we get a feasible solution
(x1 , x2 , x3 , x4 ) = (0, 0, 9, 12) with objective value z = 0. We can increase objective
value z by increasing x2 while keeping x1 = 0 and as long as x3 , x4 remain non-
negative. By that principle we can increase x2 up to x2 = min{ 39 , 12 3
} = 3, and
then get the new feasible solution (x1 , x2 , x3 , x4 ) = (0, 3, 0, 3) with better objective
value z = 6. In the dictionary, the left arrow means that x3 will decrease to 0
(leaving variable, hence becomes a non-basic variable in the next step), and the
up arrow means that x2 will increase (entering variable, hence becomes a basic
variable in the next step).
In the next step we express the basic variables x2 and x4 in term of the
non-basic variables x1 and x3 , and get the second dictionary as follows.
max z
s.t. x2 = 3 − 13 x1 − 13 x3
x4 = 3 − x1 + x3 ←
z = 6 + 13 x1 − 23 x3
↑
x1 , x 2 , x 3 , x 4 ≥ 0
We now see that the only way to increase objective value z is to increase x1 ,
while keeping x3 = 0. To keep the non-negativity of x2 and x4 , we can increase
x1 only up to 3, and then get x2 = 2. So we obtain a new feasible solution
(x1 , x2 , x3 , x4 ) = (3, 2, 0, 0) with better objective value z = 7. In the second
dictionary, the arrows mean that x1 is the entering variable and x4 is the leaving
variable. After this step, x3 and x4 becomes non-basis variables while x1 and x2
become basis variables.
We continue to the next step by expressing the basic variables x1 and x2 in
term of the non-basic variables x3 and x4 , and get the third dictionary as follows.
max z
s.t. x1 = 3 + x3 − x4
x2 = 2 − 32 x3 + 13 x4
z = 7 − 13 x3 − 31 x4
x1 , x 2 , x 3 , x 4 ≥ 0
12
We now see that there is no way to improve z due to the negativity of coef-
ficients of variables in the expression of z. Hence the current feasible solution
(x1 , x2 , x3 , x4 ) = (3, 2, 0, 0) is an optimal solution, and the optimal objective value
is z = 7.
min − x1 − 3x2
s.t. x1 + 3x2 ≥ 3
− x1 + x2 ≤ −1
x1 , x 2 ≥ 0
Solution
We record here the key steps in the solution progress.
Firstly, we transform the given LP to get maximizing problem with equality
constraints and non-negative variables.
max x1 + 3x2
s.t. x1 + 3x2 − x3 = 3
− x1 + x2 + x4 = −1
x1 , x 2 , x 3 , x 4 ≥ 0
max z
s.t. x3 = −3 + x1 + 3x2
x4 = −1 + x1 − x2
z= x1 + 3x2
x1 , x 2 , x 3 , x 4 ≥ 0
max − x1 + 2x2 + x3
s.t. x1 + x2 − 2x3 ≤2
x1 − x2 + x3 ≤1
x2 + x3 ≤5
2x1 − x2 ≤2
x1 , x 2 , x 3 ≥0
Given the fact that (1, 1, 2, 0) is a feasible solution of the dual problem. Use the
weak duality theorem to derive an upper bound for the objective value of the
given LP problem.
Solution
The objective function of the dual problem is 2y1 +y2 +5y3 +2y4 . The objective
value of the dual problem at (1, 1, 2, 0) is 13. By weak duality theorem, this value
is an upper bound for the objective value of the primal problem.
Solution
(i) The dual problem is
(ii) It is not hard to see that, after visualizing the feasible set of the dual
problem in 2D plane, the dual problem is infeasible.
(iii) By weak duality theorem, it follows from part (ii) that the primal problem
is unbounded (i.e., the objective value of the primal problem can tend to +∞).
15
Using the strong duality theorem, indicate whether (0, 0, 1, 0) and (1, 0, 2) are
optimal solutions of the given linear program and its dual problem, respectively.
Solution
The objective value of the primal problem at (0, 0, 1, 0) is 2. The objective
function of the dual problem is y1 − y2 + y3 , therefore the objective value of the
dual problem at (1, 0, 2) is 3. We do not have the strong duality in this case, so
the given solutions are not optimal.
16
Complementary slackness
Exercise 19. Consider the following linear program.
max x1 + 2x2 + 3x3 − 4x4
s.t. x1 − x2 + x3 ≤ 1
x1 − x3 − x4 ≤ −1
x2 + x3 + x4 ≤ 1
x1 , x 2 , x 3 , x 4 ≥ 0
Using the complementary slackness theorem, indicate whether (0, 1, 0, 0) and
(1, 0, 2) are optimal solutions of the given linear program and its dual problem,
respectively.
Solution
The dual problem is
min y1 − y2 + y3
s.t. y1 + y2 ≥ 1
− y1 + y3 ≥ 2
y1 − y2 + y3 ≥ 3
− y2 + y3 ≥ −4
y1 , y 2 , y 3 ≥ 0
The pair of primal-dual solution (x1 , x2 , x3 , x4 ) = (0, 1, 0, 0) and (y1 , y2 , y3 ) =
(1, 0, 2) does not satisfy the complementary slackness condition
x2 (−y1 + y3 − 2) = 0.
Therefore these solutions are not optimal solutions of the primal and dual prob-
lems.
Exercise 20. Use the complementary slackness theorem to prove that ( 15
4 2
, 3 ) is
not an optimal solution to the following linear program:
max x1 + 2x2
s.t. 2x1 + 3x2 ≤ 12
6x1 + 5x2 ≤ 30
x2 ≤ 3
x1 , x 2 ≥ 0
Solution
The dual problem is
min 12y1 + 30y2 + 3y3
s.t. 2y1 + 6y2 ≥1
3y1 + 5y2 + y3 ≥ 2
y1 , y2 , y3 ≥ 0
Since x = (x1 , x2 ) = ( 15 , 3 ) satisfies constraints of the primal problem, it is a
4 2
feasible solution of the primal problem. We construct the dual solution y =
(y1 , y2 , y3 ) associated with this x by using complementary slackness theorem as
follows.
17
15
• x1 = 4
> 0 =⇒ 2y1 + 6y2 = 1;
3
• x2 = 2
> 0 =⇒ 3y1 + 5y2 + y3 = 2;
3
• x2 = 2
< 3 =⇒ y3 = 0.
These equations leads to the dual solution y = ( 87 , − 18 , 0). This is not a feasible
solution of the dual problem. Therefore, the given point x = ( 15 , 3 ) is not an
4 2
optimal solution of the primal problem.
It is known that (1, 0, 1) is an optimal solution of the dual problem. Use the
complementary slackness theorem to find an optimal solution of the given LP
problem.
Solution
The dual problem is
Since this dual problem has an optimal solution, by strong duality theorem we
know that the given primal LP problem has an optimal solution. Let x∗ =
(x∗1 , x∗2 , x∗3 , x∗4 ) be the optimal solution of the primal problem.
Since y∗ = (1, 0, 1) is known as an optimal solution of this dual problem, we
observe by complementary slackness theorem that
• y2 = 0 > −1 =⇒ x∗4 = 0.
It follows from these four obtained equations that x∗ = (x∗1 , x∗2 , x∗3 , x∗4 ) = (3, 1, 0, 0).
It is obvious that this x∗ is a feasible solution (and hence an optimal solution, by
the complementary slackness theorem) of the given primal LP problem.