Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add option to skip fixing inputs in sequential decomposition #3442

Closed
wants to merge 3 commits into from

Conversation

alma-walmsley
Copy link
Contributor

@alma-walmsley alma-walmsley commented Dec 5, 2024

Summary/Motivation:

I am working on a problem (within IDAES) where pyomo network's sequential decomposition is used to initialize the model. For tear ports, I want to either:

  • Fix the variables on that port directly, or
  • Remove a degree of freedom by adding a constraint for an expression at that port.

For example, if the port has the variables [flow_mol, pressure, enth_mol], and temperature is an expression of pressure and enth_mol, then I want the ability to unfix enth_mol and constrain temperature to some value to determine the enthalpy.

In pyomo network's case, when running sequential decomposition, all the variables at the port get fixed if they are currently unfixed. I assume this is to prevent user error from too many degrees of freedom.

However, in my case, my model gets over-defined, since a constraint is added to remove a degree of freedom when a variable is unfixed, but those variables get fixed anyway when sequential decomposition is run.

Changes proposed in this PR:

  • Add an option in sequential decomposition to skip fixing all the variables at the tear ports. Defaults to False. Variables can be fixed manually or through the set_guesses_for method.

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.

Copy link

codecov bot commented Dec 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.71%. Comparing base (eb8a6b5) to head (6b1ebce).
Report is 19 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3442      +/-   ##
==========================================
- Coverage   88.71%   88.71%   -0.01%     
==========================================
  Files         882      882              
  Lines      100622   100625       +3     
==========================================
+ Hits        89271    89272       +1     
- Misses      11351    11353       +2     
Flag Coverage Δ
linux 86.18% <100.00%> (-0.01%) ⬇️
osx 76.20% <100.00%> (+<0.01%) ⬆️
other 86.67% <100.00%> (-0.01%) ⬇️
win 84.64% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alma-walmsley
Copy link
Contributor Author

Had a review of what I was trying to accomplish here. Constraints can't be applied if the state variable is a "guess" and free to be adjusted by a recycle. They can be applied if the state variable should remain constant (or rather, there is nothing in the recycle loop that can adjust the state variable - flow_mass is a good example: the arc's equality constraint for flow_mol needs to be deactivated, and a constraint for flow_mass at the state block should be added). However, to support guesses from constraints for state variables that should be "recycled," we should first initialize the state block, which actually gives us the correct value for flow_mol, which can be fixed - and all constraints deactivated.

At best we could probably save on initializing one state block, which in the grand scheme of things is not much and probably not worth it.

TL;DR this logic is probably not needed, closing this PR 🙂

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants