Skip to content

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

@emma58

Description

@emma58

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions