-
Notifications
You must be signed in to change notification settings - Fork 562
GDP: Fix bug transforming Blocks in gdp.mbigm transformation
#3811
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
base: main
Are you sure you want to change the base?
Conversation
… names can be resolved when instance searches for components during M calculations
…into mbigm-resolve-names
gdp.mbigm transformation
emma58
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for fixing the bug, @bammari! Do you have time to add a few assertions about the transformed model to your test?
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3811 +/- ##
==========================================
- Coverage 89.41% 89.23% -0.19%
==========================================
Files 909 909
Lines 105579 105579
==========================================
- Hits 94408 94212 -196
- Misses 11171 11367 +196
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ransformed correctly.
| m.b.dis1.linear = Constraint(expr=m.b.x * 0.5 + 3 == m.b.y) | ||
| m.b.dis2.linear = Constraint(expr=m.b.x * 0.2 + 1 == m.b.y) | ||
| m.b.d = Disjunction(expr=[m.b.dis1, m.b.dis2]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick question: this tests the case where all the variables are defined by the subtree being transformed. What happens if one of the Vars is defined outside the subtree (e.g., on m instead of under m.b)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsiirola In this example, if we defined variable x as m.x instead of m.b.x, the transformed expression would be:
0.5 * m.x + 3 - m.b.y <= 3.5 * m.b.dis2.binary_indicator_var instead of
0.5 * m.b.x + 3 - m.b.y <= 3.5 * m.b.dis2.binary_indicator_var
Do you see any potential issues with this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope - that should be fine. I don't think it will be a huge issue, as the change this PR is making doesn't actually affect Vars (I wasn't thinking clearly last night -- you are only getting relative names for active components [Constraints & Disjuncts] - and not Vars).
BUT, this does raise the question: what do we expect the following to do??
m.d1 = Disjunct()
m.b = Block()
m.b.d2 = Disjunct()
m.b.disj = Disjunction(expr=[m.d1, m.b.d2])
TransformationFactory('gdp.mbigm').apply_to(m.b, threads=2)Thoughts? @emma58?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Spot checking... this update to mbigm leads to an exception. bigm will transform the model (including deactivating m.d1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(@emma58 crawls under a table...)
(From under the table,) we expect the model above to put the transformed constraints on m.b, and to deactivate m.d1 and m.b.d2. Scoping should be determined by the Disjunction and not care about where the Disjuncts are living at all. So basically, the bigm behavior is the desired behavior. I can look at this...
Fixes # .
The multiple big-M transformation fails to transform blocks.
Summary/Motivation:
In many cases, we may want to apply the multiple big-M transformation on blocks rather than an entire model.
For example, prior to this PR the following model would result in a failed transformation:
Changes proposed in this PR:
relative_to=instanceonconstraint.getname()andother_disjunct.getname()when setting up jobs for calculating M parameters.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: