substitute_template_expression

(函数来自 pyomo.core.expr.template_expr)

pyomo.core.expr.template_expr.substitute_template_expression(expr, substituter, *args, **kwargs)[source]

在表达式树中替换IndexTemplates。

这是一个通用的实用函数,用于遍历表达式树并替换所有出现的IndexTemplate和GetItemExpression节点。

Parameters:
  • expr (NumericExpression) – 源模板表达式

  • substituter (Callable) – 方法接受 (expression, *args) 并返回新对象

  • *args – 直接传递给替换器的位置参数

Returns:

一个已完成所有替换的新表达式树

Return type:

NumericExpression