find_close_to_bounds

(function from pyomo.util.infeasible)

pyomo.util.infeasible.find_close_to_bounds(m, tol=1e-06)[source]

Find variables and constraints whose values are close to their bounds.

Uses the current model state. Variables with no values and constraints with evaluation errors are returned as if they were close to their bounds.

Note

This will omit variables and constraints in several situations:
  • Equality constraints are omitted (as they should always be close to their bounds!).

  • Range constraints where both the upper and lower bounds are close are omitted (these are basically equality constraints).

  • Fixed variables are omitted (this is analogous to an equality constraint).

  • Variables where both the upper and lower bounds are close are omitted (these are basically fixed variables).

Parameters:
  • m (Block) – Pyomo block or model to check

  • tol (float) – absolute feasibility tolerance: values within tol of the bound will be returned.

Yields:
  • var (ComponentData) – The variable or constraint that is close to its bounds

  • val (float) – The value of the variable or constraint body

  • close (int) – A bitmask indicating which bound(s) the value was close to (1 for the lower bound or 2 for the upper bound; 0 indicates the variable or constraint had no value or evaluating the constraint generated an error)