The CVX Users’ Guide, Release 2.1
In rare cases, users have discovered that certain models were rejected with Disciplined convex
programming error messages even though they satisﬁed theDCPruleset. We have not received a
bug report of this type in quite a long time, however, so we suspect our users have helped us iron out these
10.4 Handling numerical issues
No developer likes to tell their customers that their software may not work for them. Alas, we have no
choice. The fact is that we cannot guarantee that CVX will be able to solve your problem, even if it is
formulated properly, even if it avoids the use of integer or binary variables, even if it is of reasonable size,
even if it avoids the use of our experimentalexponentialconesupport.
We blame the solvers—but we must come to their defense, too. Even the best and mostmature solvers will
struggle with a particular problem that seems straightforward. Another solver may have no difﬁculty with
that one, but fail to ﬁnd an accurate solution on another. While sometimes these challenges are due to bugs
inthesolver’simplementation,quite oftenit issimplyduetolimits imposedby thenature of ﬁnite numerical
precision computation. And different problems push those limits to different degrees. So the fact is thatno
solver is perfect, but no solver can be.
When we considermixed-integerproblems, the situation is even worse. Solvers must perform what is
effectively an exhaustivesearch among the integer variables todetermine the correct solution. Yes, there are
some intelligent and innovative ways to speed up that search, and the performance of mixed-integer solvers
has improved dramatically over the years. But there will always be models for which the exhaustive search
willsimply take toolong.
None of this is much comfortif itis your model the solver is struggling with. Here are some practical tips if
youencounter this problem:
Try a different solver. Use the cvx_solver command for this. If youare using Gurobior MOSEK, don’t
hesitate to try one of the free solvers if they are compatible with your problem.
Reduce the precision. Consider inserting cvx_precision medium or even cvx_precision low
into your problem to see if that allows the solver to exit successfully. Of course, if it does succeed,
make sure to check the results to see if they are acceptable for your application. If they are not,
consider some of the other advice here to see if the solvability of your modelmay be improved.
Remove constraints. If you think thatone or more of the constraints might not be active atthe solution, try
removing them. If the solver terminates, you can conﬁrm that your guess was correct by examining
the solution to the modiﬁed problem.
Add constraints. Consider adding simple bounds to the constraints to reduce the size of the feasible set.
This will sometimes improve the numerical conditioning of the problem. Make them as tight as you
can without impinging on the optimal set. If this modiﬁed problem is successfully solved, check the
solution to see if any of the added bounds are active. If they are, relaxthem, andtry again.
Watch for scaling issues. Scaling issues are the most vexing problems for numerical solvers to deal with.
Solvers will often re-scale the problem to reduce the dynamic range of the numerical coefﬁcients, but
doing so sometimes leads to undesirable effects on the solution. It is better to avoid scaling issues
during the modeling process. Don’t mix values of wildly different magnitudes, such as 1e-3 and
10.4. Handling numerical issues