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

Defer processing ConfigDict's handling of default values until they are needed #3244

Open
emma58 opened this issue Apr 23, 2024 · 0 comments

Comments

@emma58
Copy link
Contributor

emma58 commented Apr 23, 2024

Summary

We lack an elegant way to pass configured solvers as config arguments, as is pointed out in #3220.

Rationale

Many transformations rely on the user being able to pass a configured solver as an argument so that that configuration will persist wherever it is used in the transformation (or meta algorithm). Right now we often do that by passing a solver instance, but this is suboptimal since those solver instances will be created on import. (Alternatively, some parts of code take the solver name as the argument and pass an options dictionary separately, but this is rather clunky and difficult to validate.)

Description

As suggested by @jsiirola, allow this syntax:

CONFIG.declare(
    'solver',
    ConfigValue(
        domain=SolverFactory,
        default='gurobi',
        description="A solver to use to solve the continuous subproblems for "
        "calculating the M values",
    ),
)

and don't process the default value until the first time it is needed.

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

No branches or pull requests

1 participant