CVPR的PYOMO-约束
我正在尝试创建一个约束
def rest1(modelo, i):
return sum(sum(modelo.M[r, i, j] for j in modelo.j) for r in modelo.r if i!=j)==1
modelo.restr1 = pyenv.constraint(modero.i,rule = rets1)
,但我会得到此错误:
valueerror:无效约束表达式。约束表达式解决了琐碎的布尔(false)而不是pyomo对象。请修改您的规则以返回约束。不可行而不是false。
modelo.m是var
I'm trying to create a constraint
def rest1(modelo, i):
return sum(sum(modelo.M[r, i, j] for j in modelo.j) for r in modelo.r if i!=j)==1
modelo.restr1 = pyEnv.Constraint(modelo.i, rule= rest1)
but i get this error:
ValueError: Invalid constraint expression. The constraint expression resolved to a trivial Boolean (False) instead of a Pyomo object. Please modify your rule to return Constraint.Infeasible instead of False.
modelo.M is a Var
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
提供最小的工作示例是最好的做法,以便社区成员可以尝试产生您的错误。
我认为问题源于两个原因之一:
modelo.m
是param
,指定索引上的总和是一个不等于1的常数必需的。It is best practice to provide a minimal working example so that community members can attempt to produce your error.
I imagine the issue stems from one of two reasons:
modelo.M
is aParam
and the sum over the specified indices is a constant that is not equal to 1 as required.