简体   繁体   中英

Accessing pre-defined list for constraints

I am trying to solve a optimization problem with Pyomo. The problem is to minimize an objective function constrained over a pre-defined list.

lambda = [0, 1, 2]

x-> Independent Variable
y = f(x)

Constraints:
y[0] < lambda[0]
y[1] < lambda[1]
y[2] < lambda[2]

Obj = minimize (model.y)

So basically my optimization result will have three elements. While defining constraints for the same, how do i access the list? ie First element of model.y should be less than the first element of lambda. Any guidance is appreciated.

How about like this? Set the lambda as a parameter of Set A:

data:

set A := L1 L2 L3 ;
param Lambda: x y z;

pyomo:
model.A=Set()
model.Lambda = Param(model.A)   
model.Y=Var(model.A)  
      

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM