在Pyomo中创建具有不同名称的相同集

时间:2017-03-10 09:58:54

标签: pyomo

我正在尝试使用不同的名称创建多个相等的集合。我尝试过类似的东西:

model.j=model.i

我在操作章节(4.2)中的Pyomo文档中看到的东西,但是当我运行程序时,我收到以下错误:

RuntimeError: Attempting to re-assign the component 'i' to the same
block under a different name (j).

This behavior is not supported by Pyomo; components must have a
single owning block (or model), and a component may not appear
multiple times in a block.  If you want to re-name or move this
component, use the block del_component() and add_component() methods.

1 个答案:

答案 0 :(得分:0)

这样做的方法是用另一个

初始化一个Set
model.j = Set(initialize=model.i)