HW5 Sol
HW5 Sol
HW5 Sol
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
(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 *
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).
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])
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:
− 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.
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.)