Skip to content

BUG FIXES: Solver Refactor for IDAES Integration #3214

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

Merged
merged 20 commits into from
Apr 3, 2024

Conversation

mrmundt
Copy link
Contributor

@mrmundt mrmundt commented Mar 28, 2024

Fixes

Summary/Motivation:

Working with @andrewlee94 on adding initial support for v2 solvers in IDAES, we discovered some bugs. This PR addresses those bugs.

Changes proposed in this PR:

  • Remove usage of model.nobjectives (etc.) due to them not existing on ScalarBlocks
  • Allow forward compatibility of solver_options and writer_config in LegacySolverWrapper
  • Yell loudly if users try to use both options and solver_options in the same command
  • Add some docs (not a lot, but some) about how both types of option passing are supported

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

Comment on lines 508 to 513
# Something wacky happens in IDAES due to the usage of ScalarBlock
# instead of PyomoModel. This is an attempt to fix that.
from pyomo.core.base.PyomoModel import ModelSolutions

setattr(model, 'solutions', ModelSolutions(model))
model.solutions.add_symbol_map(symbol_map)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems weird to include here. Is this pointing to an edge case that was missed in #110 that should be fixed directly in the Block or _BlockData class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely, yes, it should be. It was something that Andrew ran into while trying to get this working for IDAES, since they inherit from ScalarBlock

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really wacky - and probably not something that should be added to Block (in the new world order, there should never be a reason to attach a symbolmap to the model)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you like to handle this? It causes issues in IDAES if it's not present because they use ScalarBlock.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a commit to @andrewlee94's branch on IDAES to resolve this: andrewlee94/idaes-pse@532d23b

@Robbybp
Copy link
Contributor

Robbybp commented Mar 28, 2024

  • Allow forward compatibility of solver_options and writer_config in LegacySolverWrapper
  • Yell loudly if users try to use both options and solver_options in the same command
  • Add some docs (not a lot, but some) about how both types of option passing are supported

Thanks! I too was confused by this when trying the new interface a few days ago.

@mrmundt mrmundt requested a review from blnicho March 28, 2024 23:03
Comment on lines 508 to 513
# Something wacky happens in IDAES due to the usage of ScalarBlock
# instead of PyomoModel. This is an attempt to fix that.
from pyomo.core.base.PyomoModel import ModelSolutions

setattr(model, 'solutions', ModelSolutions(model))
model.solutions.add_symbol_map(symbol_map)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really wacky - and probably not something that should be added to Block (in the new world order, there should never be a reason to attach a symbolmap to the model)

@mrmundt mrmundt requested a review from jsiirola April 2, 2024 17:30
@jsiirola jsiirola merged commit c68ce66 into Pyomo:main Apr 3, 2024
32 of 33 checks passed
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

Successfully merging this pull request may close these issues.

5 participants