错误:“无法将标量组件'PVtoB'视为索引组件”

时间:2019-11-02 10:28:01

标签: numpy optimization solver pyomo

变量不被视为索引组件。 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)

1 个答案:

答案 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)