value

(function from pyomo.common.numeric_types)

pyomo.common.numeric_types.value(obj, exception=True)[source]

A utility function that returns the value of a Pyomo object or expression.

Parameters:
  • obj – The argument to evaluate. If it is None, a string, or any other primitive numeric type, then this function simply returns the argument. Otherwise, if the argument is a NumericValue then the __call__ method is executed.

  • exception (bool) – If True, then an exception should be raised when instances of NumericValue fail to evaluate due to one or more objects not being initialized to a numeric value (e.g, one or more variables in an algebraic expression having the value None). If False, then the function returns None when an exception occurs. Default is True.

Returns: A numeric value or None.