MCPP_visitor
(class from pyomo.contrib.mcpp.pyomo_mcpp)
- class pyomo.contrib.mcpp.pyomo_mcpp.MCPP_visitor(expression, improved_var_bounds=None)[source]
Bases:
StreamBasedExpressionVisitorCreates an MC++ expression from the corresponding Pyomo expression.
This class walks a pyomo expression tree and builds up the corresponding expression of type McCormick.
Note on memory management: The MCPP_visitor will return a pointer to an MC++ interval object that was dynamically allocated within the C interface. It is the caller’s responsibility to call mcpp_lib.release() on that object to prevent a memory leak
Methods
__init__(expression[, improved_var_bounds])acceptChildResult(node, data, child_result, ...)beforeChild(node, child, child_idx)exitNode(node, data)finalizeResult(node_result)register_num(num)Registers a new number: Param, Var, or NumericConstant.
register_var(var, lb, ub)Registers a new variable.
Walk an expression, calling registered callbacks.
Nonrecursively walk an expression, calling registered callbacks.
Attributes
client_methodsMember Documentation
- walk_expression()[source]
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.