变量不被视为索引组件。 Numpy
超载?
model.PVtoB = Param(initialize=df.PVGeneration.tolist(), doc='PV Generation')
def market_constraintx1(model, t):
return (model.Charge[t]<= model.PVtoB[t])
model.market_rulex1 = Constraint(model.T, rule=market_constraintx1)
答案 0 :(得分:1)
我认为是因为您的案例中的Pyomo参数PVtoB没有给出Set作为索引。
尝试:
model.PVtoB = Param(model.T, initialize=df.PVGeneration.tolist(), doc='PV Generation')
def market_constraintx1(model, t):
return (model.Charge[t]<= model.PVtoB[t])
model.market_rulex1 = Constraint(model.T, rule=market_constraintx1)