# add the master cut. cut = sum((mstr_inst.time_price[t,s,i] * \ mstr_inst.avail[t]) for t in mstr_inst.TWOPLUSWEEKS for s in mstr_inst.SCEN) cut += sum((mstr_inst.bal2_price[p,s,i] * \ (-mstr_inst.Inv1[p])) for p in mstr_inst.PROD for s in mstr_inst.SCEN) cut += sum((mstr_inst.sell_lim_price[p,t,s,i] * \ mstr_inst.market[p,t]) for p in mstr_inst.PROD for t in mstr_inst.TWOPLUSWEEKS for s in mstr_inst.SCEN) mstr_inst.Cut_Defn.add(mstr_inst.Min_Stage2_Profit <= cut)
I am running a similar script. Now i would like to create a set of new variables in the master problem and use them for the cut:
# my dream
add in master.py
model.x = Var(model.CUTS) # this set has been empty before and has now one element; in the next iteration it can have two and so on
add in runbenders
mstr_inst.Cut_Defn.add(mstr_inst.Min_Stage2_Profit <= summation(model.x))
Can something like this work?
Kind regards,
Fabian
Sure. I have no clue if the modeling concept makes sense, but you can (easily) implement it in Pyomo:
>>> m.cuts = Set(initialize=[])
>>> m.x = Var(m.cuts, initialize=0)
>>> m.pprint()
1 Set Declarations
cuts : Dim=0, Dimen=1, Size=0, Domain=None, Ordered=False, Bounds=(None, None)
[]
1 Var Declarations
x : Size=0, Index=cuts, Domain=Reals
Key : Lower : Value : Upper : Fixed : Stale
2 Declarations: cuts x
Now you can add members to the indexing set…
>>> m.cuts.add(1)
>>> m.pprint()
1 Set Declarations
cuts : Dim=0, Dimen=1, Size=1, Domain=None, Ordered=False, Bounds=(None, None)
[1]
1 Var Declarations
x : Size=0, Index=cuts, Domain=Reals
Key : Lower : Value : Upper : Fixed : Stale
2 Declarations: cuts x
…and when you use the “new” variables, “the right thing happens” (i.e., Pyomo will instantiate the “new” variable and initialize it per the original Var declaration)
>>> print “new variable = “, m.x[1].value
new variable = 0
>>> m.pprint()
1 Set Declarations
cuts : Dim=0, Dimen=1, Size=1, Domain=None, Ordered=False, Bounds=(None, None)
[1]
1 Var Declarations
x : Size=1, Index=cuts, Domain=Reals
Key : Lower : Value : Upper : Fixed : Stale
1 : None : 0 : None : False : False
2 Declarations: cuts x
john
--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
pyomo-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.