Professional Documents
Culture Documents
Boyd
y = θ1 x1 + (1 − θ1 )(µ2 x2 + µ3 x3 )
θ2 + θ 3 1 − θ1
µ1 + µ2 = = = 1.
1 − θ1 1 − θ1
Since C is convex and x2 , x3 ∈ C, we conclude that µ2 x2 + µ3 x3 ∈ C. Since this point
and x1 are in C, y ∈ C.
2.2 Show that a set is convex if and only if its intersection with any line is convex. Show
that a set is affine if and only if its intersection with any line is affine.
Solution. We prove the first part. The intersection of two convex sets is convex.
Therefore if S is a convex set, the intersection of S with a line is convex.
Conversely, suppose the intersection of S with any line is convex. Take any two distinct
points x1 and x2 ∈ S. The intersection of S with the line through x1 and x2 is convex.
Therefore convex combinations of x1 and x2 belong to the intersection, hence also to
S.
1
x2 = (b2 /kak2 )a
a x1 = (b1 /kak2 )a
aT x = b 2
aT x = b 1
The distance between the two hyperplanes is also the distance between the two points
x1 and x2 where the hyperplane intersects the line through the origin and parallel to
the normal vector a. These points are given by
2.7 Voronoi description of halfspace. Let a and b be distinct points in Rn . Show that the
set of all points that are closer (in Euclidean norm) to a than b, i.e., {x | kx − ak2 ≤
kx − bk2 }, is a halfspace. Describe it explicitly as an inequality of the form cT x ≤ d.
Draw a picture.
Solution. Since a norm is always nonnegative, we have kx − ak2 ≤ kx − bk2 if and
only if kx − ak22 ≤ kx − bk22 , so
2.8 Which of the following sets S are polyhedra? If possible, express S in the form S =
{x | Ax b, F x = g}.
2
(c) S = {x ∈ Rn | x 0, xT y ≤ 1 for all y with kyk2 = 1}.
(d) S = {x ∈ Rn | x 0, xT y ≤ 1 for all y with
Pn
i=1 |yi | = 1}.
Solution.
c2 a2
a1
c1
vkT x = 0, k = 1, . . . , n − 2
aT1 a2
c 1 = a1 − a2 .
ka2 k22
3
• Similarly, let c2 be a vector in the plane defined by a1 and a2 , and orthogonal
to a1 , e.g.,
aT a1
c 2 = a 2 − 2 2 a1 .
ka1 k2
Then x ∈ S3 if and only if
Putting it all together, we can describe S as the solution set of 2n linear inequal-
ities
vkT x ≤ 0, k = 1, . . . , n − 2
−vkT x ≤ 0, k = 1, . . . , n − 2
cT1 x ≤ |cT1 a1 |
−cT1 x ≤ |cT1 a1 |
cT2 x ≤ |cT2 a2 |
−cT2 x ≤ |cT2 a2 |.
(b) S is a polyhedron, defined by linear inequalities xk ≥ 0 and three equality con-
straints.
(c) S is not a polyhedron. It is the intersection of the unit ball {x | kxk2 ≤ 1} and
the nonnegative orthant Rn+ . This follows from the following fact, which follows
from the Cauchy-Schwarz inequality:
We can prove this as follows. First suppose that |xi | ≤ 1 for all i. Then
xT y =
X X X
xi yi ≤ |xi ||yi | ≤ |yi | = 1
i i i
if i |yi | = 1.
P
an index for which |xk | = maxi |xi |, and take yk = 1 if xk > 0, yk = −1 if xk < 0,
and yi = 0 for i 6= k. With this choice of y we have
xT y =
X
xi yi = yk xk = |xk | = max |xi |.
i
i
4
Therefore we must have maxi |xi | ≤ 1.
All this implies that we can describe S by a finite number of linear inequalities:
it is the intersection of the nonnegative orthant with the set {x | − 1 x 1},
i.e., the solution of 2n linear inequalities
−xi ≤ 0, i = 1, . . . , n
xi ≤ 1, i = 1, . . . , n.
Note that as in part (c) the set S was given as an intersection of an infinite
number of halfspaces. The difference is that here most of the linear inequalities
are redundant, and only a finite number are needed to characterize S.
None of these sets are affine sets or subspaces, except in some trivial cases. For example,
the set defined in part (a) is a subspace (hence an affine set), if a1 = a2 = 0; the set
defined in part (b) is an affine set if n = 1 and S = {1}; etc.
2.11 Hyperbolic sets. Show that the hyperbolic set {x ∈ R2+ | x1 x2 ≥ 1} is convex. As a
generalization, show that {x ∈ Rn+ | ni=1 xi ≥ 1} is convex. Hint. If a, b ≥ 0 and
Q
(a) We prove the first part without using the hint. Consider a convex combination z
of two points (x1 , x2 ) and (y1 , y2 ) in the set. If x y, then z = θx + (1 − θ)y y
and obviously z1 z2 ≥ y1 y2 ≥ 1. Similar proof if y x.
Suppose y 6 x and x 6 y, i.e., (y1 − x1 )(y2 − x2 ) < 0. Then
(b) Assume that xi ≥ 1 and yi ≥ 1. Using the inequality in the hint, we have
Q Q
i i
xθi yi1−θ = ( xi )θ (
Y Y Y Y
(θxi + (1 − θ)yi ) ≥ yi )1−θ ≥ 1.
i i i
5
(d) The set of points closer to a given point than a given set, i.e.,
where S ⊆ Rn .
(e) The set of points closer to one set than another, i.e.,
where S, T ⊆ Rn , and
Solution.
(a) A slab is an intersection of two halfspaces, hence it is a convex set and a polyhe-
dron.
(b) As in part (a), a rectangle is a convex set and a polyhedron because it is a finite
intersection of halfspaces.
(c) A wedge is an intersection of two halfspaces, so it is convex and a polyhedron. It
is a cone if b1 = 0 and b2 = 0.
(d) This set is convex because it can be expressed as
\
{x | kx − x0 k2 ≤ kx − yk2 },
y∈S
i.e., an intersection of halfspaces. (Recall from exercise 2.7 that, for fixed y, the
set
{x | kx − x0 k2 ≤ kx − yk2 }
is a halfspace.)
(e) In general this set is not convex, as the following example in R shows. With
S = {−1, 1} and T = {0}, we have
6
(f) This set is convex. x + S2 ⊆ S1 if x + y ∈ S1 for all y ∈ S2 . Therefore
\ \
{x | x + S2 ⊆ S1 } = {x | x + y ∈ S1 } = (S1 − y),
y∈S2 y∈S2
{x | (x − x0 )T (x − x0 ) ≤ R2 },
2.15 Some sets of probability distributions. Let x be a real-valued random variable with
prob(x = ai ) = pi , i = 1, . . . , n, where a1 < a2 < · · · < an . Of course p ∈ Rn lies in
the standard probability simplex P = {p | 1T p = 1, p 0}. Which of the following
conditions are convex in p? (That is, for which of the following conditions is the set of
p ∈ P that satisfy the condition convex?)
(a) α ≤ E f (x) ≤ β, where E f (x) is the expected value of f (x), i.e., E f (x) =
Pn
i=1 pi f (ai ). (The function f : R → R is given.)
The first five constraints are, in fact, linear inequalities in the probabilities pi .
7
Pn
(a) E f (x) = i=1 pi f (ai ), so the constraint is equivalent to two linear inequalities
n
X
α≤ pi f (ai ) ≤ β.
i=1
where bi = a2i and A = aaT . This defines a convex set, since the matrix aaT is
positive semidefinite.
8
prob(x ≤ β)
1
p1 + p2 + · · · + pn−1
p1 + p2
0.25
p1
a1 a2 an β
Here, let us define k = max{i | ai ≤ α}. Again, this is a fixed integer, independent
of p. The constraint f (p) ≤ α holds if and only if
k
X
prob(x ≤ ak ) = pi ≥ 0.25.
i=1
9
EE364a, Winter 2007-08 Prof. S. Boyd
x1 ≥ 0, x3 ≥ 0, x1 x3 − x22 ≥ 0.
and
x1 x4 x6 + 2x2 x3 x5 − x1 x25 − x6 x22 − x4 x23 ≥ 0,
i.e., all principal minors must be nonnegative.
We give the proof for n = 3, assuming the result is true for n = 2. The matrix
x1 x2 x3
X = x2 x4 x5
x3 x5 x6
for all z.
If x1 = 0, we must have x2 = x3 = 0, so X 0 if and only if
" #
x4 x5
0.
x5 x6
Applying the result for the 2 × 2-case, we conclude that if x1 = 0, X 0 if and only if
x2 = x3 = 0, x4 ≥ 0, x6 ≥ 0, x4 x6 − x25 ≥ 0.
z T Xz = x1 (z1 +(x2 /x1 )z2 +(x3 /x1 )z3 )2 +(x4 −x22 /x1 )z22 +(x6 −x23 /x1 )z32 +2(x5 −x2 x3 /x1 )z2 z3 ,
1
so it is clear that we must have x1 > 0 and
" #
x4 − x22 /x1 x5 − x2 x3 /x1
0.
x5 − x2 x3 /x1 x6 − x23 /x1
By the result for 2 × 2-case studied above, this is equivalent to
x1 x4 − x22 ≥ 0, x1 x6 − x23 ≥ 0, (x4 − x22 /x1 )(x6 − x23 /x1 ) − (x5 − x2 x3 /x1 )2 ≥ 0.
The third inequality simplifies to
(x1 x4 x6 + 2x2 x3 x5 − x1 x25 − x6 x22 − x4 x23 )/x1 ≥ 0.
Therefore, if x1 > 0, then X 0 if and only if
x1 x4 − x22 ≥ 0, x1 x6 − x23 ≥ 0, (x1 x4 x6 + 2x2 x3 x5 − x1 x25 − x6 x22 − x4 x23 )/x1 ≥ 0.
We can combine the conditions for x1 = 0 and x1 > 0 by saying that all 7 principal
minors must be nonnegative.
2.33 The monotone nonnegative cone. We define the monotone nonnegative cone as
Km+ = {x ∈ Rn | x1 ≥ x2 ≥ · · · ≥ xn ≥ 0}.
i.e., all nonnegative vectors with components sorted in nonincreasing order.
(a) Show that Km+ is a proper cone.
(b) Find the dual cone Km+
∗
. Hint. Use the identity
n
X
xi yi = (x1 − x2 )y1 + (x2 − x3 )(y1 + y2 ) + (x3 − x4 )(y1 + y2 + y3 ) + · · ·
i=1
+ (xn−1 − xn )(y1 + · · · + yn−1 ) + xn (y1 + · · · + yn ).
Solution.
(a) The set Km+ is defined by n homogeneous linear inequalities, hence it is a closed
(polyhedral) cone.
The interior of Km+ is nonempty, because there are points that satisfy the in-
equalities with strict inequality, for example, x = (n, n − 1, n − 2, . . . , 1).
To show that Km+ is pointed, we note that if x ∈ Km+ , then −x ∈ Km+ only if
x = 0. This implies that the cone does not contain an entire line.
(b) Using the hint, we see that y T x ≥ 0 for all x ∈ Km+ if and only if
y1 ≥ 0, y1 + y2 ≥ 0, . . . , y1 + y2 + · · · + yn ≥ 0.
Therefore
k
X
∗
Km+ = {y | yi ≥ 0, k = 1, . . . , n}.
i=1
2
3.2 Level sets of convex, concave, quasiconvex, and quasiconcave functions. Some level sets
of a function f are shown below. The curve labeled 1 shows {x | f (x) = 1}, etc.
3
2
1
1 2 3 4 5 6
Solution. The first function could be quasiconvex because the sublevel sets appear to
be convex. It is definitely not concave or quasiconcave because the superlevel sets are
not convex.
It is also not convex, for the following reason. We plot the function values along the
dashed line labeled I.
3
3
2
1
I
II
Along this line the function passes through the points marked as black dots in the
figure below. Clearly along this line segment, the function is not convex.
If we repeat the same analysis for the second function, we see that it could be concave
(and therefore it could be quasiconcave). It cannot be convex or quasiconvex, because
the sublevel sets are not convex.
4
Z x
F ′′ (x) = (2/x3 ) f (t) dt − 2f (x)/x2 + f ′ (x)/x
0
Z x
3
= (2/x ) (f (t) − f (x) − f ′ (x)(t − x)) dt.
0
3.6 Functions and epigraphs. When is the epigraph of a function a halfspace? When is the
epigraph of a function a convex cone? When is the epigraph of a function a polyhedron?
Solution. If the function is convex, and it is affine, positively homogeneous (f (αx) =
αf (x) for α ≥ 0), and piecewise-affine, respectively.
These functions are often used in economics to model the benefit or utility of some
quantity of goods or money. Concavity of uα means that the marginal utility (i.e., the
increase in utility obtained for a fixed increase in the goods) decreases as the amount
of goods increases. In other words, concavity models the effect of satiation.
Solution.
(a) In this limit, both the numerator and denominator go to zero, so we use l’Hopital’s
rule:
(d/dα)(xα − 1) xα log x
lim uα (x) = lim = lim = log x.
α→0 α→0 (d/dα)α α→0 1
5
(b) By inspection we have
1α − 1
uα (1) = = 0.
α
The derivative is given by
u′α (x) = xα−1 ,
which is positive for all x (since 0 < α < 1), so these functions are increasing. To
show concavity, we examine the second derivative:
3.16 For each of the following functions determine whether it is convex, concave, quasicon-
vex, or quasiconcave.
{(x1 , x2 ) ∈ R2++ | x1 x2 ≥ α}
6
(e) f (x1 , x2 ) = x21 /x2 on R × R++ .
Solution. f is convex, as mentioned on page 72. (See also figure 3.3). This is
easily verified by working out the Hessian:
" # " #
2 2/x2 −2x1 /x22 1 h i
∇ f (x) = = (2/x2 ) 1 −x1 /x2 0.
−2x1 /x22 2x21 /x32 −x1 /x2
where λi , i = 1, . . . , n, are the eigenvalues of Z −1/2 V Z −1/2 . From the last equality
we see that g is a concave function of t on {t | Z + tV ≻ 0}, since det Z > 0 and
the geometric mean ( ni=1 xi )1/n is concave on Rn++ .
Q
3.24 Some functions on the probability simplex. Let x be a real-valued random variable
which takes values in {a1 , . . . , an } where a1 < a2 < · · · < an , with prob(x = ai ) = pi ,
i = 1, . . . , n. For each of the following functions of p (on the probability simplex
{p ∈ Rn+ | 1T p = 1}), determine if the function is convex, concave, quasiconvex, or
quasiconcave.
7
f is quasiconcave because its superlevel sets are convex. We have f (p) ≥ α if and
only if
k
X
p[i] < 0.9,
i=1
where k = max{i = 1, . . . , n | i < α} is the largest integer less than α, and p[i] is
the ith largest component of p. We know that ki=1 p[i] is a convex function of p,
P
Solution. The minimum width interval that contains 90% of the probability
must be of the form [ai , aj ] with 1 ≤ i ≤ j ≤ n, because
j
X
prob(α ≤ x ≤ β) = pk = prob(ai ≤ x ≤ aj )
k=i
8
so y is not in dom f ∗ . Next, assume y 0 but 1T y > 1. We choose x = t1 and
let t go to infinity, to show that
xT y − max xi = t1T y − t
i
xT y ≤ max xi
i
for all x, and therefore xT y − maxi xi ≤ 0 for all x, with equality for x = 0.
Therefore f ∗ (y) = 0.
(d) Power function. f (x) = xp on R++ , where p > 1. Repeat for p < 0.
Solution. We’ll use standard notation: we define q by the equation 1/p+1/q = 1,
i.e., q = p/(p − 1).
We start with the case p > 1. Then xp is strictly convex on R+ . For y < 0 the
function yx − xp achieves its maximum for x > 0 at x = 0, so f ∗ (y) = 0. For
y > 0 the function achieves its maximum at x = (y/p)1/(p−1) , where it has value
Therefore we have (
∗ 0 y≤0
f (y) = q
(p − 1)(y/p) y > 0.
For p < 0 similar arguments show that dom f ∗ = −R+ and f ∗ (y) = pq (y/p)q .
9
EE364a, Winter 2007-08 Prof. S. 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