clone_without_expression_components
(function from pyomo.gdp.util
)
- pyomo.gdp.util.clone_without_expression_components(expr, substitute=None)[source]
A function that is used to clone an expression.
Cloning is roughly equivalent to calling
copy.deepcopy
. However, theclone_leaves
argument can be used to clone only interior (i.e. non-leaf) nodes in the expression tree. Note that named expression objects are treated as leaves whenclone_leaves
isTrue
, and hence those subexpressions are not cloned.This function uses a non-recursive logic, which makes it more scalable than the logic in
copy.deepcopy
.- Parameters:
expr – The expression that will be cloned.
substitute (dict) – A dictionary mapping object ids to objects. This dictionary has the same semantics as the memo object used with
copy.deepcopy
. Defaults to None, which indicates that no user-defined dictionary is used.
- Returns:
The cloned expression.