dimanche 17 juillet 2016

How to initialize an expression in Pyomo


from pyomo.environ import *
s = [1,2,3,4]
model = ConcreteModel()
model.x=[s,domain=NonNegativeReals]
def constraint1(model,i):
    expr = []
    if i>=2:
        expr += x[i]
    return expr
model.cons = Constraint(s,rule=cosntraint1)

This doesn't work because the initialization of expression expr=[] is not working in Pyomo, then what should I modify the code?


Aucun commentaire:

Enregistrer un commentaire