I am new to Pyomo (and Python). I have implemented a problem in GAMS and would like to do the same using Pyomo. I have a problem with an equation, which is depending on two consecutive time steps. More specifically, I define two equations: one which is true when the time steps are strictly greater than 1 (ramp) and another if not (ramp0). Below you can find the problem formulated in GAMS. It is there possible to define only one set and for each equation to define the range for which the equation is true, using “ord”. What would be the correct way to do this using Pyomo? I attached a possible approach I thought about but would be pleased to hear from experts. Thank you very much for your help.
Set t time periods /1*150/ (..) Variable p(t) ; Equation ramp(t) ramp0(t) ; ramp(t) $ ( ord(t) gt 1)..-RD*DeltaT=l=p(t)-p(t-1), ramp0(t) $ ( ord(t) le 1)..-RD*DeltaT=l=p(t)-p0, ---------------------- # Creation of a Concrete Model VRB = ConcreteModel() # Sets VRB.t=RangeSet(1,88,1) VRB.t0=Set(VRB.t & RangeSet(1,1,1), within=VRB.t) VRB.t1=Set(within=VRB.t) VRB.p=Var(VRB.t,bounds=(0.0, 1.0)) VRB.limits=ConstraintList() for t in VRB.t : (…) For t in VRB.t1 VRB.limits.add (-RD*DeltaT <=p[t]-p[t-1]) For t in VRB.t0 VRB.limits.add (-RD*DeltaT <=p[t]-p0)