  We propose a necessary and sufficient test to determine whether a solution
for a general quadratic program with two quadratic constraints (QC2QP) can be
computed from that of a specific convex semidefinite relaxation, in which case
we say that there is no optimality gap. Originally intended to solve a
nonconvex optimal control problem, we consider the case in which the cost and
both constraints of the QC2QP may be nonconvex. We obtained our test, which
also ascertains when strong duality holds, by generalizing a closely-related
method by Ai and Zhang. An extension was necessary because, while the method
proposed by Ai and Zhang also allows for two quadratic constraints, it requires
that at least one is strictly convex. In order to illustrate the usefulness of
our test, we applied it to two examples that do not satisfy the assumptions
required by prior methods. Our test guarantees that there is no optimality gap
for the first example -- a solution is also computed from the relaxation -- and
we used it to establish that an optimality gap exists in the second.

Optimization and Control