Reputation: 11
I'm attempting to use cvxpy. I have installed version 1.1.0a1 into my conda environment using pip and cloned the cvxpy github repository. When trying to run their SVM-example jupyter notebook, prob.solve()
throws the following error message:
SolverError: Solver 'OSQP' failed. Try another solver, or solve with verbose=True for more information.
Setting verbose=True
and adding some print statements reveals that the solver terminates with
status: maximum iterations reached
number of iterations: 10000
run time: 1.07e+00s
optimal rho estimate: 2.03e-01
for regulariation parameter Lambda = 0.010974987654930561
, while parameter Lambda = 0.010476157527896646
gives the result
status: solved inaccurate
number of iterations: 10000
optimal objective: 0.8437
run time: 1.06e+00s
optimal rho estimate: 1.68e-01
Since this is "official" example code, I'm guessing that my problem is in some form of unexpected interaction with other packages, but don't even know where to begin to look.
Upvotes: 1
Views: 9190
Reputation: 937
I ran the SVM example on my machine, and got the same error as you. Looks like we need to update it.
There's nothing wrong with your installation. Solvers (i.e., numerical algorithms that solve problems constructed by CVXPY) can sometimes fail, even when a problem is DCP-compliant. Often, solvers will fail when the numerical data is very large or very small, which can lead to what's known as poorly conditioned problem data. Some solvers are more robust than others.
In this case, I can run the example successfully by using the ECOS solver (prob.solve(solver=cp.ECOS
)) (ECOS version 2.0.4, CVXPY 1.0.25).
More generally, when a solver fails, here are some things you can try:
verbose=True
(prob.solve(verbose=True)
). This should print out a detailed error message, helping you identify why the solver failed.Upvotes: 5