Skip to content
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

Recommended solver presets #2324

Open
SteveDiamond opened this issue Jan 15, 2024 · 7 comments
Open

Recommended solver presets #2324

SteveDiamond opened this issue Jan 15, 2024 · 7 comments

Comments

@SteveDiamond
Copy link
Collaborator

SteveDiamond commented Jan 15, 2024

Quoting from @knicklux on discord:
on that topic, I was thinking that some presets in CVXPY. Like cp.SOLVER_AUTO.{LARGE_SCLAE, FAST, ACCURATE, MULTIPRECISION} would make life a lot easier in cases, where one wants to run the solver again with a higher accuracy or switch from a second-order to a first-order method because of memory issues
For example, here is a preset with solver options for SDPA-multiprecision:

settings_sdpa = {
    "gammaStar": 0.5,
    "lambdaStar": 1e5,
    "lowerBound": -1e10,
    "upperBound": 1e10,
    "maxIteration": 200,
    "warm_start": True,
}
@knicklux
Copy link

knicklux commented Jan 15, 2024

For semidefinite programs:

FAST: solver CLARABEL with default options
LARGE_SCALE: solver SCS with default options
LARGE_SCALE_ACCURATE: SCS with

    options_scs = {
        "max_iters": 1000000,
        "verbose": True,
        "use_indirect": True,
        "eps": 1e-8,
        "eps_abs": 1e-8,
        "eps_rel": 1e-8,
        "eps_infeas": 1e-8,
        "acceleration_lookback": 0,
    }

ACCURATE: solver CVXOPT with options

    options_cvxopt = {
        "max_iters": 5000,
        "verbose": True,
        "abstol": 1e-8,
        "reltol": 1e-8,
    }

ROBUST: solver CVXOPT with options

    options_cvxopt = {
        "max_iters": 5000,
        "verbose": True,
        "abstol": 1e-21,
        "reltol": 1e-11,
        "refinement": 2, # higher number seemed to make things worse
        "kktsolver": "robust"
    }

MULTIPRECISION: solver SDPA-multiprecision with options

settings_sdpa = {
    "epsilonStar": 1e-30, # check, if this is always a good idea
    "epsilonDash": 1e-30, # # check, if this is always a good idea
    "gammaStar": 0.5,
    "lambdaStar": 1e5,
    "lowerBound": -1e10,
    "upperBound": 1e10,
    "maxIteration": 200
}

@SteveDiamond is CLARABEL feature-complete or going to be feature-complete soon?

@SteveDiamond
Copy link
Collaborator Author

What do you mean by feature complete? Clarabel is actively developed, so there are continuous improvements.

@knicklux
Copy link

I get an error when minimizing log_det with CLARABEL:

thread '<unnamed>' panicked at 'not implemented: Mixed PSD and Exponential/Power cones are not yet supported', src/solver/core/cones/psdtrianglecone.rs:292:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

so maybe, for now we stick with the default (which would be SCS with default settings) or wrap the call to CLARABEL in a try-catch

@SteveDiamond
Copy link
Collaborator Author

SteveDiamond commented Jan 15, 2024

I get an error when minimizing log_det with CLARABEL:

thread '<unnamed>' panicked at 'not implemented: Mixed PSD and Exponential/Power cones are not yet supported', src/solver/core/cones/psdtrianglecone.rs:292:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

so maybe, for now we stick with the default (which would be SCS with default settings) or wrap the call to CLARABEL in a try-catch

Ah ok. Yeah this combination is not fully supported yet. @goulart-paul what's the current time frame for adding more support for PSD + exponential/power?

@rileyjmurray
Copy link
Collaborator

rileyjmurray commented Jan 15, 2024 via email

@phschiele
Copy link
Collaborator

In principle, I think such qualitative keywords would be a nice addition. It could be great for users who have issues with the results of the 0 argument form of .solve() but don't want to get into all of the details of the solver options.

However, I also have some doubts about hard coding specific configurations of solver options into CVXPY, as it also creates some maintenance overhead. Also, I think we would need to have at least some process for how we determine such recommended settings, as they may very well depend on the problem domain.

Going in the direction that @rileyjmurray mentioned, I think we should distinguish between solver settings given the solver, and solver dispatch. We could have, per-solver groupings of settings, similar to the unified eps keyword recently introduced for the Mosek interface. For example, Clarabel has Full Accuracy and Reduced Accuracy parameters, although AFAIK they are currently not exposed to the user: Docs.

We could improve the information content of this table, e.g., by adding what type of algorithm is used:
https://www.cvxpy.org/tutorial/advanced/index.html#choosing-a-solver
We can then add some high-level guidance about accuracy vs. speed and memory usage, and which are the most common parameters to tweak.

TL;DR: A first approach could be to improve docs to guide solver choice + add solver-specific default groups.

@knicklux
Copy link

First, thank you for letting me know on the state of CLARABEL :)

Right now, the issue at core is that numerous users are heading to the discord to ask for solver settings, especially for SDPs. They all would benefit massively from either improving the documentation with tuning suggestions or providing solver presets; I agree with @phschiele that the first is more practical in the long run and I could help by providing tuning suggestions for SDPs and QPs. Is there already an open issue to add this to the documentation?

About groupings of settings, it could make the definition of automatic settings easier. And thinking about issue #434 , it would be tremendously useful, if the resulting metrics of infeasibility in that check are less than the user-specified epsilon. I was recently revisiting snapvx and thinking about issues in a distributed implementation and one major issue is that a solver may return a wrong solution, which could be avoided by having the workers (or a subset of trusted workers) verify each other's solution.

Maybe, a better wording would be cp.SOLVER_PRESET.{...} instead of auto, that would make it clearer to the user that the settings are hard-coded and may or may not work. Like @phschiele pointed out, that there should be a process to test the presets and maybe it would be a good idea, to implement those first and then revisit the issue of providing presets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants