Quadratically-Constrained Quadratic Programming, Strong Duality, and the S-Lemma
In this post we are going to look at quadratically-constrained quadratic
programs (QCQPs). In particular, we will examine the interesting result that
strong duality holds (in most cases) for QCQPs with a single constraint, even
when the problem is not convex. We made use of this fact previously when we
looked at the convexity of the maximum eigenvalue of a symmetric
matrix, and it is useful in
many other areas like trust region optimization and control theory. This post
is quite technical and assumes some familiarity with convex optimization; the
standard (and freely available online) reference is Convex
Optimization by Boyd and
Vandenberghe.
Quadratically-Constrained Quadratic Programs
A general QCQP is an optimization problem with the form
is a quadratic function with Qi=QiT∈Rn×n,
pi∈Rn, and ri∈R for all i=0,…,m. The form shown in the second line of (2) is called the homogeneous form of fi.
If Qi≽0 (that is, Qi is positive
semidefinite), then fi is convex.
If fi is convex for all i=0,…,m, then (1) is a
convex problem; however, we are interested in the general case when we need not
make such convexity assumptions. Note that quadratic equality constraints
(which are always non-convex if Qi=0) can be represented in
(1) as two-sided inequalities.
Many interesting problems in robotics can be expressed as QCQPs. Notably, the
set of valid 3D rotations can be defined using non-convex quadratic
constraints, allowing various state estimation problems to be cast as QCQPs.
See e.g. (Holmes & Barfoot, 2023) for more
information and examples.
with dual variable λ≥0 (the inequality is taken
elementwise). The dual function is
d(λ)=xinfL(x,λ);
that is, it is the greatest lower
bound on L.
There are two possibilities: either L is unbounded below or it has
a finite minimum, depending on the value of λ. A finite minimum is
clearly the greater lower bound, which is obtained when λ satisfies
Q~(λ)≽0 and
p~(λ)∈C(Q~(λ)) (i.e.,
p~ lives in the column
space of
Q~). In this case, a point x~∈Rn is a
minimizer of L if and only if
∂x∂L=2Q~(λ)x~+2p~(λ)=0,
which we can rearrange to obtain x~=−Q~(λ)+p~(λ), where (⋅)+ denotes the Moore-Penrose pseudoinverse. Note that if Q~(λ) is strictly positive definite, then Q~(λ)+=Q~(λ)−1 and p~(λ)∈C(Q~(λ)) is always true.
Substituting the expression for x~ back into L, we
obtain the dual function
The dual problem is always convex, but the convexity of (4) is
not obvious in this form. To rewrite the problem, first
notice that maximizing d(λ) is equivalent to maximizing a scalar
γ with the constraint γ≤d(λ), so we can express
the dual problem as
which can be solved efficiently with software like
Clarabel or MOSEK.
Note that if any of the constraints in (1) is an equality
rather than an inequality, then the dual remains the same except that the
corresponding dual variable λi is no longer constrained to be
non-negative.
QC1QP
A QCQP with only a single constraint is known as a QC1QP. We can write an
inequality-constrained QC1QP in the form
The duality gap is the difference
p⋆−d⋆ between the primal and dual optimal values. When the duality
gap is exactly zero (i.e., d⋆=p⋆), we say that strong duality
holds. In this section we review some background on strong duality.
Feasibility and Slater’s Condition
Recall that we say that an optimization problem is feasible when there exists some point
x~ satisfying all the constraints; such a point x~
is called a feasible point. A problem is strictly feasible (also known as
Slater’s condition) when
a solution exists in the interior of the feasible set. For example, the
problem (1) is feasible if and only if there
exists some point x~∈Rn such that
fi(x~)≤0,i=1,…,m,
and is strictly feasible if and only if there exists such a point
satisfying
fi(x~)<0,i=1,…,m
(that is, all of the constraints are satisfied with strict inequality).
Weak Duality
Notice that any feasible pair of primal variable x and dual variable
λ (for (1), that is any pair (x,λ) satisfying fi(x)≤0, i=1,…,m, and λ≥0) is such that ∑i=1mλifi(x)≤0, which
means the Lagrangian (3) satisfies
L(x,λ)≤f0(x). This implies that the dual
function satisfies
d(λ)=xinfL(x,λ)≤f0(x)
for all primal-dual feasible pairs (x,λ). Since the dual
optimum d⋆ is just one particular value of d(λ) and the
primal optimum p⋆ is just one particular value of f0(x), this
relationship tells us that
d⋆≤p⋆,
a result known as weak duality.
Weak duality always holds regardless of whether the primal problem is convex.
It tells us that the duality gap is always non-negative and that d⋆ acts
as a lower bound on the solution to the original problem.
Strong Duality
As mentioned above, when d⋆=p⋆, we say that strong duality holds.
Strong duality always holds when the primal problem is convex and Slater’s
condition is satisfied, but interestingly it occasionally also holds for
non-convex problems, allowing us to obtain the exact solution by solving the
(convex) dual instead. A notable example is the inequality-constrained QC1QP,
which is the main topic of this post.
S-Lemma
To prove that strong duality always holds for an inequality-constrained QC1QP (even when it is not
convex), we will make use of the
S-lemma (also known as the
S-procedure; see Appendix B.2 of Convex
Optimization for more information),
which states the following:
Suppose we have two quadratic functions f0(x) and f1(x), defined
as in (2), and assume there exists some x~∈Rn
such that f1(x~)<0. Then the implication
f1(x)≤0⟹f0(x)≤0∀x∈Rn
holds if and only if there exists some λ≥0 such that
λ[Q1p1Tp1r1]≽[Q0p0Tp0r0].
Discussion and Interpretation
Before using the S-lemma to prove strong duality, let’s take a moment to
consider what it means. The S-lemma is a type of result known as a (strong)
theorem of alternatives, because it states that exactly one of
(8) and (9) is true. The most
famous theorem of alternatives is Farkas’
lemma, which applies to systems
of linear equations rather than quadratic ones.
The existence of a non-negative real number λ satisfying
(9) serves as a certificate of the implication (8);
that is, the existence of such a number certifies that the inequality
f0(x)≤0 holds over the entire set {x∈Rn∣f1(x)≤0} (conversely, if we can find a point x~∈Rn such that f1(x~)≤0 but f0(x~)>0, then we know there is no λ≥0 that satisfies (9)).
As we will see below, requiring only a single value to prove a set-wise
inequality is a powerful tool.
If you are familiar with sum-of-squares
polynomials, you may immediately
recognize the equivalence. However, we can also show this from first
principles. Writing the two functions in their homogeneous forms and rearranging
(10), we get
which is equivalent to (9).
There are two cases. If ζ=0, we can substitute
x=(1/ζ)z into (11) and multiply both
sides by ζ2 to obtain (12). Alternatively, if
ζ=0, then (12) simplifies to
zT(λQ1−Q0)z≥0.
Since (11) is a quadratic function of
x that is bounded below (by zero), it must be convex, implying
λQ1−Q0≽0 and thus (13)
holds for all z∈Rn. We conclude that (11)
implies (12) and therefore (9), as desired.
Example
To gain some intuition about the S-lemma, let’s consider a simple
one-dimensional example. Let
Two (non-convex) quadratic functions f0 and f1 for which f1(x)≤0 implies
f0(x)≤0 for all x∈R. As stated by the S-lemma, we can
thus find a value λ≥0 such that λf1(x)≥f0(x) for
all x∈R.
As we can see (both from the figure and the fact that the signs of the x2
terms are negative), both of the functions are concave. The roots of f1 are
x=−1 and x=3, so f1(x)≤0 for any x≤−1 or x≥3 (notice that
this is a non-convex, disjoint set). The roots of f0 are x=−0.5 and x=2;
as these are both located between the roots of f1, we have
f1(x)≤0⟹f0(x)≤0∀x∈R.
The S-lemma tells us that there is therefore some λ≥0 such that
λf1(x)≥f0(x)∀x∈R.
Multiplying f1 by a non-negative scalar λ does not change its roots or
convexity, just scales its value, as can be seen in the figure above.
We just need to find a λ large enough so that (14) is satisfied. From
the figure, we see that λ=1 is too small while λ=1.5 is larger
than needed. Solving the small SDP
we find that the smallest λ satisfying (14) is
λ⋆≈1.203. The code used to generate the figure and solve the
SDP can be found here.
Proof of Strong Duality for the QC1QP
Let us now prove that strong duality holds for the inequality-constrained
QC1QP; that is, the optimal values of the primal problem
(6) and dual problem (7) are equal.
By weak duality, we always have d⋆≤p⋆; we will make use of the
S-lemma to show that this inequality is in fact always tight.
From the primal problem, we know that
f1(x)≤0⟹p⋆−f0(x)≤0∀x∈Rn,
since p⋆≤f0(x) everywhere in the feasible set
{x∈Rn∣f1(x)≤0}, by definition. Assuming the
primal problem is strictly feasible (i.e., there exists some
x~∈Rn such that f1(x~)<0), the S-lemma
tells us that there exists some λ~≥0 satisfying
λ~[Q1p1Tp1r1]≽[−Q0−p0T−p0p⋆−r0].
Pre- and post-multiplying both sides of the above expression by
[x1]T and [x1],
respectively, and rearranging a little, we obtain
f0(x)+λ~f1(x)≥p⋆,
which holds for all x∈Rn. Noticing that the left hand side
is equal to L(x,λ~), we have
d(λ~)=xinfL(x,λ~)≥p⋆.
Recalling that
d⋆=λ≥0maxd(λ)≥d(λ~),
we get d⋆≥p⋆.
Combined with weak duality, this reveals that
d⋆≥p⋆≥d⋆,
which of course implies d⋆=p⋆, and therefore strong duality holds.
This means that we can obtain the exact optimal value of the non-convex problem
(6) by instead solving the convex dual problem
(7).
To prove strong duality holds, the standard S-lemma is no longer useful. Instead, we
must turn to the S-lemma with equality, which is characterized in (Xia,
Wang, & Sheu, 2014). It states the following:
S-Lemma with Equality
Suppose we have two quadratic functions f0(x) and f1(x), defined
as in (2), and assume certain technical conditions hold (see
below). Then the implication
f1(x)=0⟹f0(x)≤0∀x∈Rn
holds if and only if there exists some λ∈R such that
λ[Q1p1Tp1r1]≽[Q0p0Tp0r0].
Technical Conditions
Notice the similarity to the standard S-lemma, except that the left hand side
of the implication (15) is now an equality, λ is
unconstrained, and we have assumed some as-yet-unstated technical conditions.
The full set of these conditions is provided in the paper linked above but is
fairly complicated, so we will only state two sufficient ones here:
there exist points x~1,x~2∈Rn such
that f1(x~1)<0 and f1(x~2)>0 (this is
sometimes called the two-sided Slater’s condition) andQ1=0; or
Q1 is strictly positive or negative definite.
The second of these conditions holds in the extremal eigenvalue
problem we looked at
previously, in which
Q1=1n≻0, with 1n denoting the n×n
identity matrix. An example using the first condition is given in (Bishop, Gerding, &
Tran-Thanh,
2020),
where it is applied to an optimal learning problem.
Strong Duality
Assuming at least one of the sets of conditions required for the S-lemma with
equality holds, the proof of strong duality for the equality-constrained QC1QP
is essentially the same as that of the inequality-constrained case, so we won’t
bother repeating it here (consider it an “exercise for the reader”). However,
we will note that we can construct equality-constrained QC1QPs in which the
technical conditions of the S-lemma with equality do not hold and as a
consequence neither does strong duality. For example, consider the QC1QP
p⋆=x∈R2minsubject tox1x2x22=0,
the constraint of which implies x2⋆=0 and therefore the optimal value is
p⋆=0. The Lagrangian is
L(x,λ)=x1x2+λx22=xTQ~(λ)[01/21/2λ]x.
However, since there is no value of λ∈R for which
Q~(λ)≽0 (one way to see this is to recall
that the determinant of a positive semidefinite matrix must be non-negative, but
detQ~(λ)=−1/4 for all λ), the
Lagrangian is unbounded below and the dual optimal value is thus
d⋆=−∞, so there is an infinite duality gap.
Thanks to Connor Holmes for reading a draft of this post.