Multi-variate Piecewise Functions

Summary

pyomo.core.kernel.piecewise_library.transforms_nd.piecewise_nd(...) Models a multi-variate piecewise linear function.
pyomo.core.kernel.piecewise_library.transforms_nd.PiecewiseLinearFunctionND(...) A multi-variate piecewise linear function
pyomo.core.kernel.piecewise_library.transforms_nd.TransformedPiecewiseLinearFunctionND(f) Base class for transformed multi-variate piecewise linear functions
pyomo.core.kernel.piecewise_library.transforms_nd.piecewise_nd_cc(...) Discrete CC multi-variate piecewise representation

Member Documentation

pyomo.core.kernel.piecewise_library.transforms_nd.piecewise_nd(tri, values, input=None, output=None, bound='eq', repn='cc')[source]

Models a multi-variate piecewise linear function.

This function takes a D-dimensional triangulation and a list of function values associated with the points of the triangulation and transforms this input data into a block of variables and constraints that enforce a piecewise linear relationship between an D-dimensional vector of input variable and a single output variable. In the general case, this transformation requires the use of discrete decision variables.

Parameters:
  • tri (scipy.spatial.Delaunay) –

    A triangulation over the discretized variable domain. Can be generated using a list of variables using the utility function util.generate_delaunay(). Required attributes:

    • points: An (npoints, D) shaped array listing the D-dimensional coordinates of the discretization points.
    • simplices: An (nsimplices, D+1) shaped array of integers specifying the D+1 indices of the points vector that define each simplex of the triangulation.
  • values (numpy.array) – An (npoints,) shaped array of the values of the piecewise function at each of coordinates in the triangulation points array.
  • input – A D-length list of variables or expressions bound as the inputs of the piecewise function.
  • output – The variable constrained to be the output of the piecewise linear function.
  • bound (str) –

    The type of bound to impose on the output expression. Can be one of:

    • ’lb’: y <= f(x)
    • ’eq’: y = f(x)
    • ’ub’: y >= f(x)
  • repn (str) –

    The type of piecewise representation to use. Can be one of:

    • ’cc’: convex combination
Returns:

a block containing any new variables, constraints, and other components used by the piecewise representation

Return type:

TransformedPiecewiseLinearFunctionND

class pyomo.core.kernel.piecewise_library.transforms_nd.PiecewiseLinearFunctionND(tri, values, validate=True, **kwds)[source]

Bases: object

A multi-variate piecewise linear function

Multi-varite piecewise linear functions are defined by a triangulation over a finite domain and a list of function values associated with the points of the triangulation. The function value between points in the triangulation is implied through linear interpolation.

Parameters:
  • tri (scipy.spatial.Delaunay) –

    A triangulation over the discretized variable domain. Can be generated using a list of variables using the utility function util.generate_delaunay(). Required attributes:

    • points: An (npoints, D) shaped array listing the D-dimensional coordinates of the discretization points.
    • simplices: An (nsimplices, D+1) shaped array of integers specifying the D+1 indices of the points vector that define each simplex of the triangulation.
  • values (numpy.array) – An (npoints,) shaped array of the values of the piecewise function at each of coordinates in the triangulation points array.
__call__(x)[source]

Evaluates the piecewise linear function using interpolation. This method supports vectorized function calls as the interpolation process can be expensive for high dimensional data.

For the case when a single point is provided, the argument x should be a (D,) shaped numpy array or list, where D is the dimension of points in the triangulation.

For the vectorized case, the argument x should be a (n,D)-shaped numpy array.

property triangulation

The triangulation over the domain of this function

property values

The set of values used to defined this function

class pyomo.core.kernel.piecewise_library.transforms_nd.TransformedPiecewiseLinearFunctionND(f, input=None, output=None, bound='eq')[source]

Bases: block

Base class for transformed multi-variate piecewise linear functions

A transformed multi-variate piecewise linear functions is a block of variables and constraints that enforce a piecewise linear relationship between an vector input variables and a single output variable.

Parameters:
  • f (PiecewiseLinearFunctionND) – The multi-variate piecewise linear function to transform.
  • input – The variable constrained to be the input of the piecewise linear function.
  • output – The variable constrained to be the output of the piecewise linear function.
  • bound (str) –

    The type of bound to impose on the output expression. Can be one of:

    • ’lb’: y <= f(x)
    • ’eq’: y = f(x)
    • ’ub’: y >= f(x)
__call__(x)[source]

Evaluates the piecewise linear function using interpolation. This method supports vectorized function calls as the interpolation process can be expensive for high dimensional data.

For the case when a single point is provided, the argument x should be a (D,) shaped numpy array or list, where D is the dimension of points in the triangulation.

For the vectorized case, the argument x should be a (n,D)-shaped numpy array.

property bound

The bound type assigned to the piecewise relationship (‘lb’,’ub’,’eq’).

property input

The tuple of expressions that store the inputs to the piecewise function. The returned objects can be updated by assigning to their expr attribute.

property output

The expression that stores the output of the piecewise function. The returned object can be updated by assigning to its expr attribute.

property triangulation

The triangulation over the domain of this function

property values

The set of values used to defined this function

class pyomo.core.kernel.piecewise_library.transforms_nd.piecewise_nd_cc(*args, **kwds)[source]

Bases: TransformedPiecewiseLinearFunctionND

Discrete CC multi-variate piecewise representation

Expresses a multi-variate piecewise linear function using the CC formulation.