-
Notifications
You must be signed in to change notification settings - Fork 526
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
TranformationFactory('core.fix_discrete') doesn't work for cloned models #995
Comments
I think this is related to a discrepancy between |
This is a fundamental problem with the current Set system (continuous sets are not first-class This will be addressed by #326. |
What can I do until #326 is fixed? It seems like it might be a while. I don't want to 'hand-code' the functionality again for cloned models. |
I have noticed that the expression var.domain in _discrete_relaxation_map with any(type(var.domain) is type(domain) for domain in _discrete_relaxation_map) This will be slightly slower (although not by that much), but the transformation shouldn't be critical for performance. Additionally, imo it doesn't sacrifice readibility - instead it indicates that we are looking for domains in I can submitt a PR if you think this is acceptable (for now). |
This issue can be seen as a consequence of #165. |
Summary
I have noticed that often times
TransformationFactory('core.fix_discrete')
doesn't work for a model, i.e. it doesn't actually fix the variables. I have found out that it happens to cloned models (whereas 'normal' models work as expected).Minimal working example
yields
Notice that the variable
y
didn't actually get fixed. If theTranformationFactory
is intead applied to modelm
, the behaviour is as expected.Looking into the code
When diving into the code, the problem ends up being when the domain of the variable
y
is checked against a list of domains hereThe expression
var.domain in _discrete_relaxation_map
will yieldFalse
, even thoughvar
is an Integer.The text was updated successfully, but these errors were encountered: