使用PYOMO计算两个参数的比率
我有2个参数,例如需求和能力: 我对这些建模如下:
model.Dmem=Param(model.nf,within=NonNegativeIntegers, initialize=1)
model.Cmem=Param(model.ns, within=NonNegativeIntegers, initialize=5)
我想计算这两个参数的比率。 我通过将上述参数划分为:
model.ame = expr(model.cmem/model.dmem)
,
但是我收到的错误是:
typeerror:无支持的操作数类型(s) for /:“ indexedParam”和“ indexedParam” < /strong>
请提供帮助。
问候
I have 2 parameters such as Demand and Capacity:
I have modeled these as follows:
model.Dmem=Param(model.nf,within=NonNegativeIntegers, initialize=1)
model.Cmem=Param(model.ns, within=NonNegativeIntegers, initialize=5)
I want to calculate the ratio of these two parameters.
I did this by dividing the parameters above as:
model.ame=expr(model.Cmem/model.Dmem)
But the error I am receiving is:
TypeError: unsupported operand type(s) for /: 'IndexedParam' and 'IndexedParam'
Please help.
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我正确理解您的问题,并且确实是
model.ame
是一个PYOMO参数,则可以将其初始化为以下内容:这样,Pyomo将通过调用来构建您的
ame
参数每对ns
和nf
的ame_rule
函数。If I understood your question correct and, indeed,
model.ame
is a Pyomo parameter, you can initialize it doing the following:That way Pyomo will construct your
ame
parameter by calling theame_rule
function for every pair ofns
andnf
.