-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make fallback to cp.SolverError
optional/configurable
#185
Comments
Hi, thanks for the suggestion. I think you're missing something there. You can refer to CVXPY documentation for the meaning of those Exceptions. |
Sorry for the confusion. You are right, the SCS rollback is not for infeasible, it's more for other errors. But the point still holds though, sometimes it's good to crash the process or we can define what would be the user-defined downstream operations. |
To be clear: Infeasible/Unbounded are not treated as exceptions in CVXPY, those are valid result statuses. Cvxportfolio instead raises (Cvxportfolio) exceptions for those cases. SolverError is a hopefully very rare exception thrown by CVXPY (not Cvxportfolio) for errors in the underlying numerical solver. What is going on in those clauses you looked at is exception handling for the latter. (It gets confusing, I know.) If you want to use a solver of your choice, just pass it to the constructor of the optimization policy. If the solver you choose never crashes (doesn't throw SolverError) you'll never touch the fallback clause :) |
PS I don't think it's useful to expose the user to crashes of solvers; convex optimization solvers are an active area of research and development, the default ones used by CVXPY work well say in 99.99% of the cases, with tradeoffs between speed, memory usage, and stability. SCS is very stable. |
I see your point. The scenario is that I am using commercial solvers like MOSEK, if it crashed for some weird errors, I would like to capture it and understand it. Any fallbacks to other solvers would best be disabled. In the current setup, I could still check the print logs, capture this SCS fallback message and crash the process in my own downstream. Not a big deal, if this is as intended, I guess this issue can be safely closed. Thanks for your timely response. |
I'm not sure about your application, but you can probably tweak the parameters of your solver to avoid SolverError (increase tolerances, maximum number of iterations, ...). I'll leave this open and think whether to make the fallback optional, probably you're right that it's a valid usecase. Also adding regularization to the risk model typically helps with numerical solver crashes, for example using -> https://www.cvxportfolio.com/en/stable/risks.html#cvxportfolio.RiskForecastError |
cp.SolverError
when optimizing should not default to switch solvercp.SolverError
optional/configurable
Hi,
I notice since version 1.3.1 or 1.3.2, the package changed its default behaviour when optimization infeasible hit. Though changing solver to SCS and retry the problem might be good in some cases. I would suggest this should be a decision to be made by the user. Sometimes it might be fine just to fail the problem instead of having inconsistent results of changing solvers.
At least, there should be an option for the user to turn off the SCS rollback.
Thanks
relevant snippet: https://github.com/cvxgrp/cvxportfolio/blob/master/cvxportfolio/policies.py#L949-L969
The text was updated successfully, but these errors were encountered: