|
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.
|
|