What are the specific reasons for CVXPY to throw `SolverError` exception?
Asked Answered
M

1

8

I am using CVXPY (version 1.0) to solve a quadratic program (QP) and I often get this exception:

SolverError: Solver 'xxx' failed. Try another solver.

which makes my program really fragile. I have tried different solvers, including CVXOPT, OSQP, ECOS, ECOS_BB, SCS. They all have more or less the same problem. I noticed that when I make the stopping criteria of the solver more strict (e.g., decrease the absolute error tolerance), I get SolverError more frequently, and when I make it less strict, the SolverError problem is attenuated and even disappears. I also find that the way that CVXPY throws SolverError is stochastic: if I run the same program many times, there are some runs having SolverError and others get the optimal result.

Although I can avoid SolverError just by trying more times and lowering the stopping criteria, I really want to understand the real specific reasons behind the exception

SolverError: Solver 'xxx' failed. Try another solver.

This error is not really informative and I have no clues on what to do to improve the problem solving robustness. Are its causes specific to a solver? Is this exception thrown for a set of well-defined situations? Or is it just a way of saying "something goes wrong for unknown reasons"? What reasons might those be?

Marquis answered 13/4, 2018 at 8:51 Comment(4)
(1) While the core-reason is the same, this is solver-specific (2) This boils down to limited-memory floating-point computations (3) There is a big difference between theory (of interior-point solvers) and practice (4) This should not be indeterministic (stochastic is the wrong word here), but i already pointed you to the reason in your other question. (5) Things get more tough when high-accuracy is needed: theory implies diverging for some values in those systems to solve; this will lead to an error at some time(6)If possible, use commercial solvers (no /trivial preprocessing in your solvers)Tomy
(Just to be clear: i explicitly mentioned IPM-methods like used in cvxopt, ecos, ecos_bb; but osqp and scs are based on a different theory)Tomy
You may want to ask on scicomp.stackexchange.com too.Pollie
As far as I know, you are correct that SolverError is very generic and not very helpful. Did you try setting verbose=True for the solve method (documetation here)? Maybe looking at the solver output will give you some better hints.Critter
D
7

If you have a solver error, you need to either debug by calling the solve method with verbose=True to see the detailed error message or use a more robust commercial solver like MOSEK. The specific reasons for solver errors depend on the solver used. A common cause is having too tight a numerical tolerance or having badly scaled data (i.e., the dynamic range of the floats in your program is too large). I will modify the SolverError message to mention using verbose=True.

Dissonance answered 21/5, 2018 at 23:16 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.