Hey guys,
We try to optimize the reservoir water supply hedging rule using a long series of runoff data. The rules take the form of reservoir storage corresponding to 24 periods of the year.When the initial reservoir storage is smaller than the corresponding time rule volume, the water supply is the coefficient multiplied by the water demand. When the initial reservoir storage is larger than the reservoir storage of rule corresponding time period, the water supply is the water demand.
I can only write the judgment between the first year reservoir storage and the rule, and when the input data becomes a long series of data for many years, it will not be processed. For example, the reservoir storage storage of the 25th time period in the long series should be compared with the first time period in the rule. The code I tried is as follows, but it reports an error.
Set n nodes
/Res_SH,Res_LW,Res_YNH,
HHK,SLZ,BDHK,CHK,WZD,HYT,
SLZ_pad,BDHK_urruin, BDHK_pad,BDHK_oth,YNH_pad,YNH_oth,YNH_agr,DL_ur/
;
Set Y years
/1956*2017/;
Alias(Y,Y1);
Set M months
*/1*24/
/Jan, Feb, Mar, Apr_first, Apr_mid, Apr_last, May_first, May_mid, May_last,
Jun_first, Jun_mid, Jun_last, Jul_first, Jul_mid, Jul_last, Aug_first, Aug_mid, Aug_last,
Sep_first, Sep_mid, Sep_last, Oct, Nov, Dec/
;
Set t calculation step
/1*1488/
;
Positive variables
D(t,n) Diversions water
R_pad(t,n) Release for pad user
R_ur(t,n) Release for urban user
R_oth(t,n) Release for other user
R_agr(t,n) Release for agricaltire user
R_eco(t,n) Release for ecological quantity
A(t,n) Abandon water quantity
S(t,n)
Rule(M,n)
;
Binary variables
Yp1(t)
Yp2(t)
;
Equations
* Constraints--Water balance for each node
B_ReYNH
B_YNHpad1
B_YNHpad2
B_YNHpad3
B_YNHpad4
;
B_ReYNH(t)..
S(t,'Res_YNH') =e= beg_S('Res_YNH')$(ord(t) EQ 1)
+ S(t-1,'Res_YNH')$(ord(t) GT 1)
+ Inflow(t,'Res_YNH')
- Evaporation(t,'Res_YNH')
- Leaking(t,'Res_YNH')
- R_pad(t,'YNH_pad')
- R_oth(t,'YNH_oth')
- R_agr(t,'YNH_agr')
- R_eco(t,'Res_YNH')
- A(t,'Res_YNH');
B_YNHpad1(t)..
Yp1(t)+Yp2(t)=1;
B_YNHpad2(t)..
R_pad(t,'YNH_pad')=e= Yp1(t)*Demand(t,'YNH_pad')*(1-Dam_dep('YNH_pad'))+Yp2(t)*Demand(t,'YNH_pad');
B_YNHpad3(t)..
S(t,'Res_YNH')=l= Rule(M,'YNH_pad')$(ord(t)=ord(M)+(ord(Y)-1)*24)*Yp1(t)+Vupper(t,'YNH_pad')*Yp2(t);
B_YNHpad4(t)..
S(t,'Res_YNH')=g= Vlower(t,'YNH_pad') * Yp1(t)+(Rule(M,'YNH_pad')$(ord(t)=ord(M)+(ord(Y)-1)*24)+10e-6)*Yp2(t);
where beg_S(‘Res_YNH’), Inflow(t,‘Res_YNH’),Evaporation(t,‘Res_YNH’),Leaking(t,‘Res_YNH’),Demand(t,‘YNH_pad’),Dam_dep(‘YNH_pad’) is the parameter
and Rule(M,n) is the decision variables we want to optimize.
The error is : Set for ‘ord’ is not controlled.
Thanks