获取组件调用堆栈

(函数来自 pyomo.util.slices)

pyomo.util.slices.get_component_call_stack(comp, context=None)[source]

获取定位Component所需的调用堆栈

调用堆栈是一个列表,其中包含元组,第一个条目是__getattr____getitem__的代码,使用与IndexedComponent_slice相同的约定。第二个条目是相应函数的参数。从context(或如果context为None,则为顶层模型)开始,按照这个调用序列将生成comp。

参数:

comppyomo.core.base.component.Component

要定位的组件

contextpyomo.core.base.block.Block

用于定位组件的块。如果为None,将使用顶级模型。

返回:

listContains the necessary method calls and their arguments.

请注意,调用应按相反的顺序应用。 这与IndexedComponent_slice中的方向相反。