Skip to content

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

@emma58

Description

@emma58

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions