pyomo
pyomo copied to clipboard
Add API for getting Var bounds that returns floats rather than None for unbounded things
Summary
Perhaps you have written the following code a few thousand times in your life:
lb, ub = pyomo_var.bounds
if lb is None:
lb = -float("inf")
if ub is None:
ub = float("inf")
If we had an API to just make this conversion for you (that is, ask for the bounds as floating point values), then this time could be the last!
Rationale
A lot of applications need the bounds to be numeric. This most recently came up in the Gurobi MINLP writer. But anytime you want to calculate the tighter of two bounds, you need this as well.
Is this an infomercial?
It turns out informercials fit your template! :P
I support this change.