PiecewiseLinearToMIP
(class from pyomo.contrib.piecewise.transform.piecewise_to_mip_visitor
)
- class pyomo.contrib.piecewise.transform.piecewise_to_mip_visitor.PiecewiseLinearToMIP(transform_pw_linear_expression, transBlock)[source]
Bases:
StreamBasedExpressionVisitor
Expression walker to replace PiecewiseLinearExpressions when creating equivalent MIP formulations.
- Parameters:
transform_pw_linear_expression (function) – a callback that accepts a PiecewiseLinearExpression, its parent PiecewiseLinearFunction, and a transformation Block. It is expected to convert the PiecewiseLinearExpression to MIP form, and return the Var (or other expression) that will replace it in the expression.
transBlock (Block) – transformation Block to pass to the above callback
Methods
__init__
(transform_pw_linear_expression, ...)beforeChild
(node, child, child_idx)exitNode
(node, data)initializeWalker
(expr)walk_expression
(expr)Walk an expression, calling registered callbacks.
Nonrecursively walk an expression, calling registered callbacks.
Attributes
client_methods
finalizeResult
Member Documentation
- walk_expression(expr)
Walk an expression, calling registered callbacks.
This is the standard interface for running the visitor. It defaults to using an efficient recursive implementation of the visitor, falling back on
walk_expression_nonrecursive()
if the recursion stack gets too deep.
- walk_expression_nonrecursive(expr)
Nonrecursively walk an expression, calling registered callbacks.
This routine is safer than the recursive walkers for deep (or unbalanced) trees. It is, however, slightly slower than the recursive implementations.