EE364a Homework 3 Solutions: 0 N 0 1 N N 1 1 N N 0 0
EE364a Homework 3 Solutions: 0 N 0 1 N N 1 1 N N 0 0
EE364a Homework 3 Solutions: 0 N 0 1 N N 1 1 N N 0 0
Boyd
for all t ∈ [0, α). Therefore the set {x | W (x) ≥ α} is an intersection of infinitely many
halfspaces (two for each t), hence a convex set.
3.54 Log-concavity of Gaussian cumulative distribution function. The cumulative distribu-
tion function of a Gaussian random variable,
1 Z x −t2 /2
f (x) = √ e dt,
2π −∞
is log-concave. This follows from the general result that the convolution of two log-
concave functions is log-concave. In this problem we guide you through a simple
self-contained proof that f is log-concave. Recall that f is log-concave if and only if
f ′′ (x)f (x) ≤ f ′ (x)2 for all x.
(a) Verify that f ′′ (x)f (x) ≤ f ′ (x)2 for x ≥ 0. That leaves us the hard part, which is
to show the inequality for x < 0.
(b) Verify that for any t and x we have t2 /2 ≥ −x2 /2 + xt.
2 /2 2 /2−xt
(c) Using part (b) show that e−t ≤ ex . Conclude that
Z x 2 /2 2 /2
Z x
e−t dt ≤ ex e−xt dt.
−∞ −∞
(d) Use part (c) to verify that f ′′ (x)f (x) ≤ f ′ (x)2 for x ≤ 0.
Solution. The derivatives of f are
2 √ 2 /2 √
f ′ (x) = e−x /2 / 2π, f ′′ (x) = −xe−x / 2π.
1
(a) f ′′ (x) ≤ 0 for x ≥ 0.
(b) Since t2 /2 is convex we have
t2 /2 ≥ x2 /2 + x(t − x) = xt − x2 /2.
which holds for any differentiable convex function, applied to g(t) = t2 /2.
Another (easier?) way to establish t2 /2 ≤ −x2 /2 + xt is to note that
t2 /2 + x2 /2 − xt = (1/2)(x − t)2 ≥ 0.
i.e.,
2
Z x
−t2 /2 e−x /2
e dt ≤ .
−∞ −x
This follows from part (c) because
2
Z x
−xt e−x
e dt = .
−∞ −x
g(X) = v T X −1 v.
minimize f0 (x1 , x2 )
subject to 2x1 + x2 ≥ 1
x1 + 3x2 ≥ 1
x1 ≥ 0, x2 ≥ 0.
Make a sketch of the feasible set. For each of the following objective functions, give
the optimal set and the optimal value.
2
(a) f0 (x1 , x2 ) = x1 + x2 .
(b) f0 (x1 , x2 ) = −x1 − x2 .
(c) f0 (x1 , x2 ) = x1 .
(d) f0 (x1 , x2 ) = max{x1 , x2 }.
(e) f0 (x1 , x2 ) = x21 + 9x22 .
(0, 1)
(2/5, 1/5)
x1
(1, 0)
(a) x⋆ = (2/5, 1/5).
(b) Unbounded below.
(c) Xopt = {(0, x2 ) | x2 ≥ 1}.
(d) x⋆ = (1/3, 1/3).
(e) x⋆ = (1/2, 1/6). This is optimal because it satisfies 2x1 +x2 = 7/6 > 1, x1 +3x2 =
1, and
∇f0 (x⋆ ) = (1, 3)
is perpendicular to the line x1 + 3x2 = 1.
4.4 [P. Parrilo] Symmetries and convex optimization. Suppose G = {Q1 , . . . , Qk } ⊆ Rn×n is
a group, i.e., closed under products and inverse. We say that the function f : Rn → R
is G-invariant, or symmetric with respect to G, if f (Qi x) = f (x) holds for all x and
i = 1, . . . , k. We define x = (1/k) ki=1 Qi x, which is the average of x over its G-orbit.
P
F = {x | Qi x = x, i = 1, . . . , k}.
3
(c) We say the optimization problem
minimize f0 (x)
subject to fi (x) ≤ 0, i = 1, . . . , m
for i = 1, . . . , k. Show that if the problem is convex and G-invariant, and there
exists an optimal point, then there exists an optimal point in F. In other words,
we can adjoin the equality constraints x ∈ F to the problem, without loss of
generality.
(d) As an example, suppose f is convex and symmetric, i.e., f (P x) = f (x) for every
permutation P . Show that if f has a minimizer, then it has a minimizer of the
form α1. (This means to minimize f over x ∈ Rn , we can just as well minimize
f (t1) over t ∈ R.)
Solution.
(a) We first observe that when you multiply each Qi by some fixed Qj , you get a
permutation of the Qi ’s:
Qj Qi = Qσ(i) , i = 1, . . . , k,
where σ is a permutation. This is a basic result in group theory, but it’s easy
enough for us to show it. First we note that by closedness, each Qj Qi is equal
to some Qs . Now suppose that Qj Qi = Qk Qi = Qs . Multiplying by Q−1 i on the
right, we see that Qj = Qk . Thus the mapping from the index i to the index s is
one-to-one, i.e., a permutation.
Now we have
k
X k
X k
X
Qj x = (1/k) Qj Qi x = (1/k) Qσ(i) x = (1/k) Qi x = x.
i=1 i=1 i=1
4
(c) Suppose x⋆ is an optimal solution. Then x⋆ is feasible, with
k
X
f0 (x⋆ ) = f0 ((1/k) Qi x)
i=1
k
X
≤ (1/k) f0 (Qi x)
i=1
= f0 (x⋆ ).
f (P x⋆ ) = f (x⋆ ),
X
f (x) ≤ (1/n!)
P
4.8 Some simple LPs. Give an explicit solution of each of the following LPs.
minimize cT x
subject to Ax = b.
cT x = λT Ax + ĉT x = λT b.
5
(b) Minimizing a linear function over a halfspace.
minimize cT x
subject to aT x ≤ b,
where a 6= 0.
Solution. This problem is always feasible. The vector c can be decomposed into
a component parallel to a and a component orthogonal to a:
c = aλ + ĉ,
with aT ĉ = 0.
• If λ > 0, the problem is unbounded below. Choose x = −ta, and let t go to
infinity:
cT x = −tcT a = −tλaT a → −∞
and
aT x − b = −taT a − b ≤ 0
for large t, so x is feasible for large t. Intuitively, by going very far in the
direction −a, we find feasible points with arbitrarily negative objective values.
• If ĉ 6= 0, the problem is unbounded below. Choose x = ba − tĉ and let t go
to infinity.
• If c = aλ for some λ ≤ 0, the optimal value is cT ab = λb.
In summary, the optimal value is
(
⋆ λb c = aλ for some λ ≤ 0
p =
−∞ otherwise.
minimize cT x
subject to l x u,
6
(d) Minimizing a linear function over the probability simplex.
minimize cT x
subject to 1T x = 1, x 0.
c1 = c2 = · · · = ck < ck+1 ≤ · · · ≤ cn .
We have
cT x ≥ c1 (1T x) = cmin
for all feasible x, with equality if and only if
x1 + · · · + xk = 1, x1 ≥ 0, . . . , xk ≥ 0, xk+1 = · · · = xn = 0.
p⋆ = min{0, cmin }.
(If cmin ≤ 0, we make the same choice for x as above. Otherwise, we choose
x = 0.)
(e) Minimizing a linear function over a unit box with a total budget constraint.
minimize cT x
subject to 1T x = α, 0 x 1,
7
i.e., the sum of the smallest α elements of c. x is optimal if and only if
x1 = · · · = xi−1 = 1, xi + · · · + xk = α − i + 1, xk+1 = · · · = xn = 0.
4.17 Optimal activity levels. We consider the selection of n nonnegative activity levels,
denoted x1 , . . . , xn . These activities consume m resources, which are limited. Activity
j consumes Aij xj of resource i, where Aij are given. The total resource consumption
is additive, so the total of resource i consumed is ci = nj=1 Aij xj . (Ordinarily we
P
have Aij ≥ 0, i.e., activity j consumes resource i. But we allow the possibility that
Aij < 0, which means that activity j actually generates resource i as a by-product.)
Each resource consumption is limited: we must have ci ≤ cmax i , where cmax
i are given.
Each activity generates revenue, which is a piecewise-linear concave function of the
activity level: (
p j xj 0 ≤ xj ≤ qj
rj (xj ) = disc
pj qj + pj (xj − qj ) xj ≥ qj .
Here pj > 0 is the basic price, qj > 0 is the quantity discount level, and pdiscj is the
disc
quantity discount price, for (the product of) activity j. (We have 0 < pj < pj .) The
total revenue is the sum of the revenues associated with each activity, i.e., nj=1 rj (xj ).
P
The goal is to choose activity levels that maximize the total revenue while respecting
the resource limits. Show how to formulate this problem as an LP.
Solution. The basic problem can be expressed as
n
maximize j=1 rj (xj )
P
subject to x 0
Ax cmax .
This is a convex optimization problem since the objective is concave and the constraints
are a set of linear inequalities. To transform it to an equivalent LP, we first express
the revenue functions as
p j x j ≥ uj , pj qj + pdisc
j (xj − qj ) ≥ uj .
8
We can form an LP as
maximize 1T u
subject to x 0
Ax cmax
p j x j ≥ uj , pj qj + pdisc
j (xj − qj ) ≥ uj , j = 1, . . . , n,
9
Solutions to additional exercises
1. Optimal activity levels. Solve the optimal activity level problem described in exercise
4.17 in Convex Optimization, for the instance with problem data
1 2 0 1 100
3 2 4
0 0 3 1 100
2 1 10
cmax pdisc =
A= 0 3 1 1 , = 100 , p=
,
,
q=
.
7 4 5
2 1 2 5 100
6 2 10
1 0 3 2 100
You can do this by forming the LP you found in your solution of exercise 4.17, or
more directly, using cvx. Give the optimal activity levels, the revenue generated by
each one, and the total revenue generated by the optimal solution. Also, give the
average price per unit for each activity level, i.e., the ratio of the revenue associated
with an activity, to the activity level. (These numbers should be between the basic
and discounted prices for each activity.) Give a very brief story explaining, or at least
commenting on, the solution you find.
Solution. The following Matlab/CVX code solves the problem. (Here we write the
problem in a form close to its original statement, and let CVX do the work of refor-
mulating it as an LP!)
A=[ 1 2 0 1;
0 0 3 1;
0 3 1 1;
2 1 2 5;
1 0 3 2];
cmax=[100;100;100;100;100];
p=[3;2;7;6];
pdisc=[2;1;4;2];
q=[4; 10 ;5; 10];
cvx_begin
variable x(4)
maximize( sum(min(p.*x,p.*q+pdisc.*(x-q))) )
subject to
x >= 0;
A*x <= cmax
cvx_end
x
r=min(p.*x,p.*q+pdisc.*(x-q))
10
totr=sum(r)
avgPrice=r./x
x =
4.0000
22.5000
31.0000
1.5000
r =
12.0000
32.5000
139.0000
9.0000
totr =
192.5000
avgPrice =
3.0000
1.4444
4.4839
6.0000
We notice that the 3rd activity level is the highest and is also the one with the highest
basic price. Since it also has a high discounted price its activity level is higher than the
discount quantity level and it produces the highest contribution to the total revenue.
The 4th activity has a discounted price which is substantially lower then the basic price
and its activity is therefore lower that the discount quantity level. Moreover it require
the use of a lot of resources and therefore its activity level is low.
2. Reformulating constraints in cvx. Each of the following cvx code fragments describes
a convex constraint on the scalar variables x, y, and z, but violates the cvx rule set,
11
and so is invalid. Briefly explain why each fragment is invalid. Then, rewrite each one
in an equivalent form that conforms to the cvx rule set. In your reformulations, you
can use linear equality and inequality constraints, and inequalities constructed using
cvx functions. You can also introduce additional variables, or use LMIs. Be sure to
explain (briefly) why your reformulation is equivalent to the original constraint, if it is
not obvious.
Check your reformulations by creating a small problem that includes these constraints,
and solving it using cvx. Your test problem doesn’t have to be feasible; it’s enough to
verify that cvx processes your constraints without error.
Remark. This looks like a problem about ‘how to use cvx software’, or ‘tricks for
using cvx’. But it really checks whether you understand the various composition rules,
convex analysis, and constraint reformulation rules.
Solution.
(a) The lefthand side is correctly identified as convex, but equality constraints are only
valid with affine left and right hand sides. Since the norm of a vector is zero if and
only if the vector is zero, we can express the constraint as x+2*y==0; x-y==0, or
simply x==0; y==0.
(b) The problem is that square() can only accept affine arguments, because it is
convex, but not increasing. To correct this use square_pos() instead:
square_pos( square( x + y ) ) <= x - y
We can also reformulate this constraint by introducing an additional variable.
variable t
square( x+y ) <= t
square( t ) <= x - y
Note that, in general, decomposing the objective by introducing new variables
doesn’t need to work. It works in this case because the outer square function is
convex and monotonic over R+ .
Alternatively, we can rewrite the constraint as
12
( x + y )^4 <= x - y
(c) 1/x isn’t convex, unless you restrict the domain to R++ . We can write this one
as inv_pos(x)+inv_pos(y)<=1. The inv_pos function has domain R++ so the
constraints x > 0, y > 0 are (implicitly) included.
(d) The problem is that norm() can only accept affine argument since it is convex
but not increasing. One way to correct this is to introduce new variables u and v:
norm( [ u , v ] ) <= 3*x + y
max( x , 1 ) <= u
max( y , 2 ) <= v
Decomposing the objective by introducing new variables work here because norm
is convex and monotonic over R2+ , and in particular over (1, ∞) × (2, ∞).
(e) xy isn’t concave, so this isn’t going to work as stated. But we can express the
constraint as x>=inv_pos(y). (You can switch around x and y here.) Another
solution is to write the constraint as geomean([x,y])>=1. We can also give an
LMI representation:
[ x 1; 1 y ] == semidefinite(2)
(f) This fails when we attempt to divide a convex function by a concave one. We can
write this as
quad_over_lin(x+y,sqrt(y)) <= x-y+5
This works because quad_over_lin is monotone descreasing in the second argu-
ment, so it can accept a concave function here, and sqrt is concave.
(g) The function x3 + y 3 is convex for x ≥ 0, y ≥ 0. But x3 isn’t convex for x < 0, so
cvx is going to reject this statement. One way to rewrite this constraint is
quad_pos_over_lin(square(x),x) + quad_pos_over_lin(square(y),y) <= 1
This works because quad_pos_over_lin is convex and increasing in its first ar-
gument, hence accepts a convex function in its first argument. (The function
quad_over_lin, however, is not increasing in its first argument, and so won’t
work.)
Alternatively, and more simply, we can rewrite the constraint as
pow_pos(x,3) + pow_pos(y,3) <= 1
(h) The problem here is that xy isn’t concave, which causes cvx to reject the state-
ment. To correct this, notice that
q q
xy − z2 = y(x − z 2 /y),
13
x+z <= 1+geomean([x-quad_over_lin(z,y),y])
This works, since geomean is concave and nondecreasing in each argument. It
therefore accepts a concave function in its first argument.
We can check our reformulations by writing the following feasibility problem in cvx
(which is obviously infeasible)
cvx_begin
variables x y u v z
x == 0;
y == 0;
( x + y )^4 <= x - y;
inv_pos(x) + inv_pos(y) <= 1;
norm( [ u ; v ] ) <= 3*x + y;
max( x , 1 ) <= u;
max( y , 2 ) <= v;
x >= inv_pos(y);
x >= 0;
y >= 0;
quad_over_lin(x + y , sqrt(y)) <= x - y + 5;
pow_pos(x,3) + pow_pos(y,3) <= 1;
x+z <= 1+geomean([x-quad_over_lin(z,y),y])
cvx_end
3. The illumination problem. This exercise concerns the illumination problem described
in lecture 1 (pages 9–11). We’ll take Ides = 1 and pmax = 1, so the problem is
with variable p ∈ Rn . You will compute several approximate solutions, and compare
the results to the exact solution, for a specific problem instance.
As mentioned in the lecture, the problem is equivalent to
where h(u) = max{u, 1/u} for u > 0. The function h, shown in the figure below, is
nonlinear, nondifferentiable, and convex. To see the equivalence between (1) and (2),
we note that
14
= log max max{aTk p, 1/aTk p}
k=1,...,n
3
h(u)
0
0 1 2 3 4
u
The problem instance. The specific problem data are for the geometry shown
below, using the formula
−2
akj = rkj max{cos θkj , 0}
from the lecture. There are 10 lamps (m = 10) and 20 patches (n = 20). We take
Ides = 1 and pmax = 1. The problem data are given in the file illum_data.m on the
course website. Running this script will construct the matrix A (which has rows aTk ),
and plot the lamp/patch geometry as shown below.
1.5
0.5
0
0 0.2 0.4 0.6 0.8 1
15
Equal lamp powers. Take pj = γ for j = 1, . . . , m. Plot f0 (p) versus γ over
the interval [0, 1]. Graphically determine the optimal value of γ, and the associated
objective value.
You can evaluate the objective function f0 (p) in Matlab as max(abs(log(A*p))).
If the solution has negative values for some pi , set them to zero; if some values are
greater than 1, set them to 1. Give the resulting value of f0 (p).
Least-squares solutions can be computed using the Matlab backslash operator: A\b
returns the solution of the least-squares problem
where ρ > 0 is a parameter. Increase ρ until all coefficients of p are in the interval
[0, 1]. Give the resulting value of f0 (p).
You can use the backslash operator in Matlab to solve the regularized least-squares
problem.
16
4
3.5
|u − 1| + 1
2.5
1.5
0.5
0
0 0.5 1 1.5 2
u
You can solve the Chebyshev approximation problem using cvx. The (convex) function
kAp − 1k∞ can be expressed in cvx as norm(A*p-ones(n,1),inf). Give the resulting
value of f0 (p).
exactly. You may find the inv_pos() function useful. Give the resulting (optimal)
value of f0 (p).
Solution: The following Matlab script finds the approximate solutions using the
heuristic methods proposed, as well as the exact solution.
clear all;
17
end;
[val_equal,imin] = min(f);
p_equal = p(imin)*ones(m,1);
% exact solution:
% ---------------
cvx_begin
variable p_exact(m)
minimize(max([A*p_exact; inv_pos(A*p_exact)]))
subject to
p_exact >= 0
18
p_exact <= 1
cvx_end
val_exact = max(abs(log(A*p_exact)));
% Results
% -------
[p_equal p_ls_sat p_ls_reg p_cheb p_exact]
[val_equal val_ls_sat val_ls_reg val_cheb val_exact]
19