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

Poor use of a SolverFactory? #3220

Closed
whart222 opened this issue Apr 1, 2024 · 2 comments
Closed

Poor use of a SolverFactory? #3220

whart222 opened this issue Apr 1, 2024 · 2 comments
Labels

Comments

@whart222
Copy link
Member

whart222 commented Apr 1, 2024

Summary

The multiple bigM logic creates a solver interface to "gurobi" by default, which seems like a poor coding decision.

Steps to reproduce the issue

The following lines appear in a config declaration in multiple_bigm.py

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

Why does it make sense to hard-code the use of gurobi within pyomo? Do we have a guarantee that this will always work and not use system resources?

Error Message

None. I found this while debugging a different issue.

Additional information

Maybe this is the intended behavior, but it seems safer to store the solver string name than the solver itself.

@whart222 whart222 added the bug label Apr 1, 2024
@jsiirola
Copy link
Member

jsiirola commented Apr 1, 2024

It is less than ideal (as a solver instance is created upon import), but there is actually very little overhead in creating the interface. Ideally, I have wanted to do an overhaul of ConfigDict's implementation of default to defer the processing of the `default value until the first time the value is requested. That would allow something like:

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

...and the actual solver object would not be created until the first time the value was accessed.

The advantage of holding the solver instance as part of the transformation configuration is that a user can both set and configure the solver before calling the transformation and those options will persist through all the solves in the transformation.

@emma58
Copy link
Contributor

emma58 commented Apr 23, 2024

I think John's suggestion is what we need in the long run here. Just opened it as a separate issue in #3244

@emma58 emma58 closed this as completed Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants