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

Serialize (and deserialize) SolverOptions #20967

Open
jwnimmer-tri opened this issue Feb 17, 2024 · 1 comment · May be fixed by #22078
Open

Serialize (and deserialize) SolverOptions #20967

jwnimmer-tri opened this issue Feb 17, 2024 · 1 comment · May be fixed by #22078
Assignees
Labels
component: mathematical program Formulating and solving mathematical programs; our autodiff and symbolic libraries priority: medium type: feature request

Comments

@jwnimmer-tri
Copy link
Collaborator

jwnimmer-tri commented Feb 17, 2024

Is your feature request related to a problem? Please describe.

When solving mathematical programs, we offer users the ability to provide a SolverOptions object that customizes various tuning and debugging parameters. A typical use would be turning on debug printing, or adjusting a certain kind of solve tolerance to be looser or tighter, or setting a cap on the max number of iterations / steps.

The options are conceptually a list of tuples, typed as (solver_id : SovlerId, option_name : str, option_value : Union[float,int,str]) that disallows duplicates of the same (solver_id, option_name). The API to access the data implements this as as a map of maps (keyed on solver_id and then option_name).

At the moment, the only way that users can set these options is by calling solver_options.SetOption(...). when the user has a set of typical options they would like to use, they currently need to consolidate that set into a piece of common code (i.e., a helper function). This ends up being klunky, at scale.

There is also no structured way to "dump" the list of options for offline inspection. There is a to_string feature but it's intended for console debugging, and so is not well-structured.

Describe the solution you'd like

Add the Serialize() capability to SolverOptions, so that (like other pure-data classes in Drake) they can be loaded from JSON and YAML, and dumped to JSON and YAML.

Describe alternatives you've considered

None.

Additional context

This will probably involve changing/deprecating some of the API that SolverInterface implementations use to access the data, but hopefully will not deprecate an user-facing API for setting up their programs. The goal is to offer more capability to users, hopefully without disrupting anything.

This also means that we're going to need to make the SolverId::name() result become a load-bearing part of our Stable API. We'll be saving the solver names in the JSON/YAML, so they need to become a durable promise. We might need to change up some of the names before stabilizing them.

This will also require formulating a solver "name" for Drake's "common" solver options, along with conventional string names for each of the options.

@jwnimmer-tri jwnimmer-tri added type: feature request component: mathematical program Formulating and solving mathematical programs; our autodiff and symbolic libraries labels Feb 17, 2024
@jwnimmer-tri jwnimmer-tri self-assigned this Feb 17, 2024
@jwnimmer-tri
Copy link
Collaborator Author

I've started working on this. We need to land some of the Focal-removal stuff before I'll be able to merge it, but hopefully within the next maybe ~2 weeks this can get finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: mathematical program Formulating and solving mathematical programs; our autodiff and symbolic libraries priority: medium type: feature request
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

1 participant