A utility function that can be used to declare inequality and
ranged inequality expressions.
Note
Pyomo does not support constructing
RangedExpression objects using Python’s chained
comparison syntax (lb <= body <= ub).
Python relies on the pairwise comparisons returning intermediates
that are convertible to bool, which is incompatible with
Pyomo’s operator overloading. Instead, RangedExpression
objects should be created using this function.
- No arguments are
None If lower, body, and upper are all non-None, then the
function will return a RangedExpression, unless two
adjacent arguments (either lower and body, or body and
upper) are both constants (e.g., native numeric types or
immutable Param objects). If there are two adjacent
constant values, then that pair is evaluated. If the result is
False, then the constraint is known to be trivially
infeasible and inequality() will return False. If the
result is True, then the return value is as if the “outer”
(lower or upper) argument had been None (see the following).
- One argument is
None If one of lower, body, or upper is None, then
inequality() will return an InequalityExpression
object, unless both arguments are constants (e.g., native numeric
types or immutable Param objects), in which case the
expression will be evaluated and the resulting bool
returned.
- Two arguments are
None If two of lower, body, or upper are None, then the
remaining argument is returned from inequality().
- All None
If all arguments are None, then None is returned