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?
CVXPY is a Python-embedded modeling language for convex optimization problems. It automatically transforms the problem into standard form, calls a solver, and unpacks the results. The status, which was assigned a value “optimal” by the solve method, tells us the problem was solved successfully.
In cvxopt you have to write your problem in a more standard way for the type of solver you want to use, whereas cvxpy is supposed to adapt your problem based on the structure you use for your problem (they are supposed to select the type of cvxopt solver depending on your problem and pass the variables in an standard ...
CVXPY relies on the open source solvers OSQP, SCS, and ECOS. Additional solvers are supported, but must be installed separately.
Can I use NumPy functions on CVXPY objects? ¶ No, you can only use CVXPY functions on CVXPY objects. If you use a NumPy function on a CVXPY object, it will probably fail in a confusing way.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With