You are on page 1of 5

ISyE 6669 HW 5 Solutions

15 February 2018

1. (a) The feasible region of this LP in (x1 , x2 ) is plotted in Fig 1 (the horizontal axis
is x1 and the vertical x2 ).

0
0 1 2 3 4 5

Figure 1: Feasible region of (x1 , x2 )

(b) The optimal solution is among the three vertices (i.e., “corner points”): (0, 3), ( 34 , 13 ), (2, 0).
Therefore, the optimal solution is (0, 3).
(c) We can write a CVXPY code as follows:
import numpy as np
from cvxpy import *

A = np.matrix([[1, 2], [2, 1]])

1
x = Variable(2)
c = np.array([3, 1])
b = np.array([2, 3])

LP = Problem(Minimize(c.T * x),
[A * x >= b, x >= 0])

LP.solve()
The optimal solution returned is (0, 3).

2. (a) We define xij as the transportation from supplier i to customer j, where (i, j) ∈
{(1, 1), (1, 2), (2, 1), (2, 3), (3, 1), (3, 2), (3, 3), (4, 1), (4, 3)}. Further, we denote (s1 , s2 , s3 , s4 ) =
(10, 25, 18, 15) and (d1 , d2 , d3 ) = (15, 20, 16). Then, the LP can be formulated as
follows:

min cij xij
(i,j)

s.t. xij ≤ si , i = 1, 2, 3, 4,
j

xij ≥ dj , j = 1, 2, 3,
i
xij ≥ 0, ∀(i, j).

(b) We can write a CVXPY code as follows:


import numpy as np
from cvxpy import *

X = Variable(4,3)
c1 = np.array([2,3,0])
c2 = np.array([4,0,5])
c3 = np.array([2,3,4])
c4 = np.array([5,0,3])

obj = X[0,:]*c1 + X[1,:]*c2+ X[2,:]*c3+ X[3,:]*c4


constr = [sum(X[0,:]) <= 10,
sum(X[1,:]) <= 25,
sum(X[2,:]) <= 18,
sum(X[3,:]) <= 15,
sum(X[:,0]) >= 15,
sum(X[:,1]) >= 20,
sum(X[:,2]) >= 16,
X[0,2] == 0, X[1,1]==0, X[3,1]==0, X>= 0]

2
prob = Problem(Minimize(obj),constr)
result = prob.solve()
print "Optimal Objective value: ", result
for i in range(4):
for j in range(3):
print "x_{0}{1}: ".format(i+1,j+1), X[i,j].value
The optimal solution is displayed as follows:
Optimal Objective value: 154.000000004
x_11: 2.8131536909
x_12: 7.18684630891
x_13: 2.32808388587e-12
x_21: 7.00000001243
x_22: 2.11215106234e-12
x_23: 0.999999987735
x_31: 5.18684629718
x_32: 12.8131536905
x_33: 1.23691247274e-08
x_41: -1.02545290848e-09
x_42: 2.16921945471e-12
x_43: 14.9999999991
(c) Changing the inequality to equality, the optimal solution may change to
Optimal Objective value: 154.00000022
x_11: 1.22010251873
x_12: 8.77989746677
x_13: 6.36635713036e-12
x_21: 7.00000006695
x_22: 5.54509116804e-12
x_23: 0.999999996635
x_31: 6.77989740036
x_32: 11.2201025332
x_33: 5.10920207895e-08
x_41: 1.39568706217e-08
x_42: 5.93693181158e-12
x_43: 14.9999999523

3. (a) Using the same notation as in Lesson 2, the power system scheduling problem

3
can be formulated as follows:

min c1 p1 + c2 p2 + c3 p3 = 5p1 + 2p2 + 3p3


s.t. − f61 + f12 = p1 ,
− f23 + f34 = p2 ,
− f45 + f56 = p3 ,
f12 − f23 = d1 = 90,
f34 − f45 = d2 = 100,
f56 − f61 = d3 = 125,
f12 = B12 (θ1 − θ2 ) = 11.6(θ1 − θ2 ),
f23 = B23 (θ2 − θ3 ) = 5.9(θ2 − θ3 ),
f34 = B34 (θ3 − θ4 ) = 13.7(θ3 − θ4 ),
f45 = B45 (θ4 − θ5 ) = 9.8(θ4 − θ5 ),
f56 = B56 (θ5 − θ6 ) = 5.6(θ5 − θ6 ),
f61 = B61 (θ6 − θ1 ) = 10.5(θ6 − θ1 ),
− f12max
= −50 ≤ f12 ≤ f12 max
= 50,
− f23 = −60 ≤ f23 ≤ f23 = 60,
max max

− f34max
= −90 ≤ f34 ≤ f34 max
= 90,
− f45max
= −50 ≤ f45 ≤ f45 max
= 50,
− f56 = −120 ≤ f56 ≤ f56 = 120,
max max

− f61max
= −100 ≤ f61 ≤ f61 max
= 100,
pmin
1 = 10 ≤ p1 ≤ pmax
1 = 250,
pmin
2 = 10 ≤ p2 ≤ pmax
2 = 300,
pmin
3 = 10 ≤ p3 ≤ pmax
3 = 270.

(b) The optimal solution is displayed as follows:


Optimal Objective value: 992.043652938
f_12: 30.0000000483
f_23: -59.9999999517
f_34: 50.0000001281
f_45: -49.9999998719
f_56: 76.4781735396
f_61: -48.5218264604
p_1: 78.5218265088
p_2: 110.00000008
p_3: 126.478173411
theta_1: -2.36685384429
theta_2: -4.95306074501
theta_3: 5.21643077222
theta_4: 1.56679572637

4
theta_5: 6.66883652963
theta_6: -6.98798017386
price_1: 5.62968516351
price_2: 2.53316407289
price_3: 4.30434782811
Note that the optimal solution may not be unique. The answer is correct
as long as the model is correct and has the same optimal objective value.
(c) The electricity price for nodes 2, 4, and 6 are 5.63, 2.53, and 4.30, respectively.
The dual prices may not be unique either. The answer is correct as long as the
model is correct (please pay attention to the signs of the equality constraints, and
make sure there is no redundant constraint that would change the prices.)

You might also like