pyomo icon indicating copy to clipboard operation
pyomo copied to clipboard

Add API for getting Var bounds that returns floats rather than None for unbounded things

Open emma58 opened this issue 4 months ago • 3 comments

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.

emma58 avatar Oct 17 '25 16:10 emma58

Is this an infomercial?

mrmundt avatar Oct 17 '25 16:10 mrmundt

It turns out informercials fit your template! :P

emma58 avatar Oct 17 '25 17:10 emma58

I support this change.

michaelbynum avatar Oct 21 '25 05:10 michaelbynum