找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 696|回复: 0

[求助] pyomo

1

主题

1

帖子

1

积分

贫民

积分
1
ztj 发表于 2022-12-6 17:01:03 | 显示全部楼层 |阅读模式


def fiveteen_rule(model, m,t):
    return model.F[m, t] == max(model.c[i, 3, t] - (1 - model.gama[i, 3, 5, m, m, t]) * model.G for i in model.N  if (i,3) in model.J[m])
model.m15 = C**traint(model.M,model.T, rule=fiveteen_rule)
为什么会报错
[size=13.0667px]ERROR: Rule failed when generating expression for C**traint m15 with index    (1, 1): PyomoException: Cannot convert non-c**tant Pyomo expression    (c[1,3,1]  <  c[2,3,1]) to bool. This error is usually caused by using a    Var, unit, or mutable Param in a Boolean context such as an "if"    statement, or when checking container membership or equality. For example,        >>> m.x = Var() >>> if m.x >= 1: ...     pass    and        >>> m.y = Var() >>> if m.y in [m.x, m.y]: ...     pass    would both cause this exception.
QQ截图20221206165818.jpg
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表