Skip to content
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

Error using uninitialized mutable Param as constraint bound #13

Closed
ghackebeil opened this issue Jun 26, 2016 · 2 comments
Closed

Error using uninitialized mutable Param as constraint bound #13

ghackebeil opened this issue Jun 26, 2016 · 2 comments

Comments

@ghackebeil
Copy link
Member

When I do something like the following:

from pyomo.core import *
model = ConcreteModel()
model.x = Var()
model.p = Param(mutable=True)
model.c = Constraint(expr= model.x <= model.p)

I immediately run into the following error message:

ValueError: Constraint 'c' created with a -Inf upper bound.

The error message goes away if I initialize the mutable Param to some finite value.

I don't think this kind of logic really belongs here. It would also be very easy to change the mutable Param value to "infinity" later on anyway. This case probably needs to be handled by the solver plugins at run time by either skipping unbounded constraints, throwing an error, or passing the constraint on to the solver as is (which some input formats support).

@ghackebeil ghackebeil changed the title Error using uninitialized mutable Param constraint bounds Error using uninitialized mutable Param as constraint bound Jun 26, 2016
@ghackebeil
Copy link
Member Author

It looks like we are testing for this case (I commented out the code that checks this and noticed that some unit tests for constraint fail).

Perhaps I'll just change things so that the check is only performed if the constraint bound is constant. This would seem like the easiest way to bypass this in the short term. However, it is still debatable whether the the constant, infinite bound case is worthy of an error.

ghackebeil added a commit that referenced this issue Jun 27, 2016
@ghackebeil
Copy link
Member Author

I also want to document here that this did not fully fix the issue in Python3. There is another spot in _ConstraintData.set_value(...) that compares the upper and lower bound (self._lower != self._upper) resulting in

ValueError: No value for uninitialized NumericValue object ...

I'm not sure why this does not happen in Python2.

ghackebeil added a commit that referenced this issue Jul 21, 2016
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

No branches or pull requests

1 participant