-
Notifications
You must be signed in to change notification settings - Fork 529
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
Correct calculation of Constraint.equality for RangedExpression with constant bounds #2097
Conversation
This feels like a move in the wrong direction. The use of two inequalities to express a constraint may be intentional, for reasons outside of Pyomo. |
Codecov Report
@@ Coverage Diff @@
## main #2097 +/- ##
=======================================
Coverage 82.87% 82.88%
=======================================
Files 619 619
Lines 76848 76852 +4
=======================================
+ Hits 63689 63696 +7
+ Misses 13159 13156 -3
Continue to review full report at Codecov.
|
@ghackebeil I spent some time thinking about exactly this. Some discussion points included should we relax this more (that is, allow an 'equality tolerance'), or leave it more strict (leaning toward a very narrow relaxation of the
|
I'm simply saying that ranged inequality expressions may be important in whatever form the Pyomo model is translated into, whether or not the upper and lower bounds are constant, equal, parameters, or whatever. A user may want that structure retained (in, say, the LP or NL file). It seems inconsistent to turn a constraint into equality form, simply because the bound types or mutability changes. My vote is for the entire |
Should we have an explicit mechanism for users to have control over this behavior? This could be done a few different ways. We could have special constraint types or we could have functions that construct "the right thing" based on user input. I think it is best to make the default behavior something reasonable (probably what is implemented in this PR) but also allow users to have greater control if necessary. |
@blnicho and I were talking about this, too. I think there are three possible interpretations of
Looking through the code base, there is not real consistency ... some places assume We should probably document which one |
Closing this PR and replacing it with PEP #2105 |
Fixes #2093
Summary/Motivation:
As was documented in #2093, the new implementation of
ConstraintData.equality
would occasionally fail to identify equality constraints forRangedExpression
objects where the bounds were constants. This resolves that issue by using==
instead ofis
when both bounds are constants (native types or constant expressions).Changes proposed in this PR:
==
instead ofis
to compare constraint bounds and determineequality
when both bounds are constants.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: