piecewise

(function from pyomo.core.kernel.piecewise_library.transforms)

pyomo.core.kernel.piecewise_library.transforms.piecewise(breakpoints, values, input=None, output=None, bound='eq', repn='sos2', validate=True, simplify=True, equal_slopes_tolerance=1e-06, require_bounded_input_variable=True, require_variable_domain_coverage=True)[source]

Models a single-variate piecewise linear function.

This function takes a list breakpoints and function values describing a piecewise linear function and transforms this input data into a block of variables and constraints that enforce a piecewise linear relationship between an input variable and an output variable. In the general case, this transformation requires the use of discrete decision variables.

Parameters:
  • breakpoints (list) – The list of breakpoints of the piecewise linear function. This can be a list of numbers or a list of objects that store mutable data (e.g., mutable parameters). If mutable data is used validation might need to be disabled by setting the validate keyword to False. The list of breakpoints must be in non-decreasing order.

  • values (list) – The values of the piecewise linear function corresponding to the breakpoints.

  • 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)

  • repn (str) –

    The type of piecewise representation to use. Choices are shown below (+ means step functions are supported)

    • ’sos2’: standard representation using sos2 constraints (+)

    • ’dcc’: disaggregated convex combination (+)

    • ’dlog’: logarithmic disaggregated convex combination (+)

    • ’cc’: convex combination (+)

    • ’log’: logarithmic branching convex combination (+)

    • ’mc’: multiple choice

    • ’inc’: incremental method (+)

  • validate (bool) – Indicates whether or not to perform validation of the input data. The default is True. Validation can be performed manually after the piecewise object is created by calling the validate() method. Validation should be performed any time the inputs are changed (e.g., when using mutable parameters in the breakpoints list or when the input variable changes).

  • simplify (bool) – Indicates whether or not to attempt to simplify the piecewise representation to avoid using discrete variables. This can be done when the feasible region for the output variable, with respect to the piecewise function and the bound type, is a convex set. Default is True. Validation is required to perform simplification, so this keyword is ignored when the validate keyword is False.

  • equal_slopes_tolerance (float) – Tolerance used check if consecutive slopes are nearly equal. If any are found, validation will fail. Default is 1e-6. This keyword is ignored when the validate keyword is False.

  • require_bounded_input_variable (bool) – Indicates if the input variable is required to have finite upper and lower bounds. Default is True. Setting this keyword to False can be used to allow general expressions to be used as the input in place of a variable. This keyword is ignored when the validate keyword is False.

  • require_variable_domain_coverage (bool) – Indicates if the function domain (defined by the endpoints of the breakpoints list) needs to cover the entire domain of the input variable. Default is True. Ignored for any bounds of variables that are not finite, or when the input is not assigned a variable. This keyword is ignored when the validate keyword is False.

Returns:

a block that

stores any new variables, constraints, and other modeling objects used by the piecewise representation

Return type:

TransformedPiecewiseLinearFunction