0% found this document useful (0 votes)
5 views

Solution 4 1

Uploaded by

maryxyxie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Solution 4 1

Uploaded by

maryxyxie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

MAT3007

Assignment 4 Solution

Problem 1
1. The dual problem is:

min 4⇡1 + 7⇡2


s.t. 2⇡1 + ⇡2 5
3⇡1 + 2⇡2 2
⇡1 + 3⇡2 5
⇡1 , ⇡2 0.

2. The dual problem can be illustrated with the following figure:

The shaded orange area represents the dual feasible region and the purple line is an iso-profit
line (objective function). As the improving direction is pointed out by the arrows, the opti-
mal dual solution is ⇡1⇤ , ⇡2⇤ ) = (2, 1). The optimal value of the dual problem is 15.

3. Both ⇡1⇤ and ⇡2⇤ are positive. The first and third constraints are tight and there is a
slack in the second constraint in the dual problem. According to complementary slackness,

1
both of the primal constraints are tight at the optimal solution and x⇤2 should be zero, i.e.,
we have
2x1 + x3 = 4
x1 + 3x3 = 7

By solving the set of equalities above, we obtain the optimal primal solution (x⇤1 , x⇤2 , x⇤3 ) =
(1, 0, 2).

Problem 2
1. Let xij denote the flow on edge (i, j). Let denote the flow from imaginary node 0 to 1.
The LP formulation of this problem is as follows:
maximize
s.t. x12 x23 x24 = 0
x13 + x23 x34 = 0
x12 x13 = 0
x24 + x34 =0
0  x12  8
0  x13  7
0  x23  2
0  x24  4
0  x34  12
The optimal solutions are x12 = 6, x13 = 7, x23 = 2, x24 = 4, x34 = 9, and the objective value
is 13 at optimal.

The MATLAB code is attached as follows:


cvx_begin quiet
variables d x12 x13 x23 x24 x34
maximize d
subject to
x12-x23-x24==0;
x13+x23-x34==0;
d-x12-x13==0;
x24+x34-d==0;
0<=x12<=8;
0<=x13<=7;
0<=x23<=2;
0<=x24<=4;
0<=x34<=12;
cvx_end
cvx_optval

2
The Python code is attached as follows:

import cvxpy as cp
from cvxopt import *

M = 100
# set of nodes
# s 2 3 t
W = [[0, 8, 7, 0], # s
[0, 0, 2, 4], # 2
[0, 0, 0, 12], # 3
[M, 0, 0, 0]] # t

n = len(W[0]) # number of nodes

# model
e = cp.Variable((n, n))
objective = cp.Maximize(e[3,0])
constraints = [sum(e[:,i]) == sum(e[i,:]) for i in range(n)]
constraints += [e >= 0]
constraints += [e[i,j] <= W[i][j] for i in range(n) for j in range(n)]

prob = cp.Problem(objective, constraints)


result = prob.solve()

2. Dual problem:
minimize 8z12 + 7z13 + 2z23 + 4z24 + 12z34
s.t. z12 y1 y2
z13 y1 y3
z23 y2 y3
z24 y2 y4
z34 y3 y4
y1 y4 = 1
zij 0
Solving the problem using MATLAB, we get y = (1, 1, 0, 0), z = (0, 1, 1, 1, 0) and the optimal
value is 13.

The MATLAB code is attached as follows:

cvx_begin quiet
variables z12 z13 z23 z24 z34 y1 y2 y3 y4
minimize 8.*z12+7.*z13+2.*z23+4.*z24+12.*z34
subject to

3
y3-y4==1;
z12+y1-y3>=0;
z13+y2-y3>=0;
z23-y1+y2>=0;
z24-y1+y4>=0;
z34-y2+y4>=0;
z12>=0;
z13>=0;
z23>=0;
z24>=0;
z34>=0;
cvx_end
cvx_optval

The Python code is attached as follows. Notice that the dual formulation in the code is
derived di↵erently, but it is still valid.

z = cp.Variable((n, n))
y = cp.Variable(n)
E = [] # set of edges
for i in range(n):
for j in range(n):
if (W[i][j] != 0)and(W[i][j] != M):
E.append((i,j))

objective_d = cp.Minimize(sum(W[i][j]*z[i,j] for (i,j) in E))


constraints_d = [z[i,j] >= 0 for (i,j) in E]
constraints_d += [z[i,j] >= y[j] - y[i] for (i,j) in E]
constraints_d += [y[3] - y[0] == 1]

prob_d = cp.Problem(objective_d, constraints_d)


result_d = prob_d.solve()

The zij variables represent whether or not each edge is in the minimum cut. The cut is
shown in the picture below.

4
Problem 3

Dual problem for model (1) is: Dual problem for model (2) is:
>
(D1 ) min b> ⇡ (D2 ) min b0 ⇡
s.t. A> ⇡ c s.t. A> ⇡ c
⇡ 0 ⇡ 0

We can see that (D1 ) and (D2 ) have exactly the same feasible region because they have the
same constraints.

We know model (1) is unbounded, according to the duality theory (D1 ) should be feasi-
ble.

Because (D1 ) and (D2 ) have the same feasible region, (D2 ) is also infeasible. If (D2 ) is
infeasible, and model (2) is feasible, according to the duality theory, model (2) cannot have
a finite optimal solution. Model (2) can only be unbounded.
Problem 4

First, we show that the two systems can’t both have solutions. If so, we have
0 = y > Ax  y > b < 0,
which is a contradiction.
Second, we show that if the second system is infeasible, then the first system must be
feasible. We consider the following pair of linear optimization problems:
min b> y
s.t. A> y = 0
y 0.

5
The dual of this problem is
max 0
s.t. Ax  b
If the second system does not have a solution, then the primal problem can’t attain negative
objective value. In the meantime, y = 0 is always a feasible solution for the primal problem
with objective value 0. Therefore, y = 0 must be an optimal solution to the primal problem.
Then by the strong duality theorem, the dual problem must also be feasible. Thus, the result
is proved.

Problem 5

Since ⇡1⇤ and ⇡3⇤ are strictly positive, according to the complementary slackness, we obtain
that the first and third constraints of the primal problem hold as equalities.

In addition, the formulation of the dual problem is:

min 9⇡1 + 2⇡2 + 4⇡3


s.t. ⇡1 + ⇡2 ⇡3 1 : x1 0
⇡1 + ⇡2 + ⇡3 1 : x2 0
2⇡1 ⇡2 + ⇡3 4 : x3 0
⇡1 , ⇡2 , ⇡3 0.

Plugging in the dual optimal solution, we can find that the second constraint in the dual
problem does not hold at equality. Therefore, x⇤2 = 0, and we can rewrite the first and third
constraints of the primal problem as:

x1 + 2x3 = 9
x1 + x3 = 4.

Solving the set of linear equations above, we obtain the primal optimal solution as:

x⇤1 = 1/3, x⇤2 = 0, x⇤3 = 13/3.

You might also like