Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法通过 Param() 函数在 Pyomo 中索引参数而不创建集合?例如,是否可以通过验证来做到这一点?
不可以。您需要创建一个 Set 对象或使用内置容器(如列表)。例如,
m.s = Set(initialize=[1,2,3]) m.p = Param(m.s)
或者
m.p = Param([1,2,3])
如果你用第二种方式,那么 Pyomo 会自动创建一个 Set 对象,并将其添加到你的模型中,名称为p_index。
p_index