Water pump scheduling Model

Hi,

I have an assignment that aims to minimize costs in the water network. I am trying to minimize the cost, which is the product of the 24-hour electricity price change and the hourly energy consumed by the pumps.

While doing this, I have limitations such as changing the water level in the tanks, keeping the water level in the tank between minimum and maximum values, keeping the pressure between minimum and maximum values.

How can solve this problem via GAMS?
Could you please help me? I need all your help.

Thank you.

My mathematical model is below.
0F169491-B9F9-4EB6-B660-826B5324B522.jpeg

this is part of my GAMS code.

variables
Hpompalanan(p,s) decision variable
z objective function
E(p,s) s time period energy consumption of pump p
dH(s) water difference s time period
H(s) water in tank in s time period;

scalar
Hmin minimum water height /3/
Hmax maximum water height /5.7/
Hilk initial water height /4/;


equations
amac
kisit1 for demand sustainability 
kisit2 water height between min and max
kisit3 pumps max energy consumption
kisit4 for demand response call
;

amac.. z =e= sum((p,s), M(s)*(0.056195*(15000*Hpompalanan(p,s)/6))- Edr(s)*G(s)-Edr(s)*Mdagitim(s));
kisit1.. sum (s, -dH(s)) =l= Hilk-Hmin- sum (s, Htuketim(s));
kisit2(s)..Hmin =l= H(s)=l= Hmax;
kisit3(p,s)..E(p,s) =l= Emax(p);
kisit4..sum (p,s), E(p,s) =g= Edr(s);
E(p,s)..(0.056195*(15000*Hpompalanan(p,s)/6));
dH(s) =e= Hpompalanan(s)- Htuketim(s);
H(s) =e= Hilk+dH(s);

model dr /all/;
option mip=CPLEX;
option optcr=0;
option optca=0;
option intvarup=0;
solve dr using MIP minimizing z;
display Hpompalanan.l;
display Hpompalanan.lo;
display dH(s).l;
display H(s).l;

I have some error how can I correct them?

***** Error 409 in** C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms[ERR:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,175,27][LST:179]
Unrecognizable item - skip to find a new statement
looking for a ‘;’ or a key word to get started again

— DR_model.gms(177) 3 Mb 5 Errors[FIL:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,177,0]
***** Error 148 in** C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms[ERR:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,177,17][LST:184]
Dimension different - The symbol is referenced with more/less
indices as declared
***** Error 653 in** C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms[ERR:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,177,18][LST:184]
The left side of an equation cannot be a set expression
***** Error 37 in** C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms[ERR:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,177,18][LST:184]
‘=l=’ or ‘=e=’ or ‘=g=’ operator expected
***** Error 409 in** C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms[ERR:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,177,18][LST:184]
Unrecognizable item - skip to find a new statement
looking for a ‘;’ or a key word to get started again
— DR_model.gms(178) 3 Mb 9 Errors[FIL:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,178,0]
***** Error 143 in** C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms[ERR:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,178,1][LST:192]
A suffix is missing
***** Error 81 in** C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms[ERR:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,178,8][LST:192]
A ‘=’ expected for assignment statements. Alternative
assignment operators are ‘=' and ':='. *** Error 143 in C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms[ERR:"C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms",178,36][LST:192] A suffix is missing ***** Error 141 in** C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms[ERR:"C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms",178,36][LST:192] Symbol declared but no values have been assigned. Check for missing data definition, assignment, data loading or implicit assignment via a solve statement. A wild shot: You may have spurious commas in the explanatory text of a declaration. Check symbol reference list. --- DR_model.gms(179) 3 Mb 11 Errors[FIL:"C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms",179,0] ***** Error 143 in** C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms[ERR:"C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms",179,2][LST:202] A suffix is missing ***** Error 36 in** C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms[ERR:"C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms",179,9][LST:202] '=' or '..' or ':=' or '=’ operator expected
rest of statement ignored
— DR_model.gms(180) 3 Mb 13 Errors[FIL:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,180,0]
***** Error 143 in** C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms[ERR:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,180,1][LST:207]
A suffix is missing
***** Error 36 in** C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms[ERR:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,180,8][LST:207]
‘=’ or ‘…’ or ‘:=’ or ‘$=’ operator expected
rest of statement ignored
— DR_model.gms(187) 3 Mb 14 Errors[FIL:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,187,0]
***** Error 257 in** C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms[ERR:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,187,32][LST:218]
Solve statement not checked because of previous errors
— DR_model.gms(190) 3 Mb 17 Errors[FIL:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,190,0]
***** Error 143 in** C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms[ERR:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,190,10][LST:223]
A suffix is missing
***** Error 141 in** C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms[ERR:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,190,10][LST:223]
Symbol declared but no values have been assigned. Check for missing
data definition, assignment, data loading or implicit assignment
via a solve statement.
A wild shot: You may have spurious commas in the explanatory
text of a declaration. Check symbol reference list.
***** Error 409 in** C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms[ERR:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,190,11][LST:223]
Unrecognizable item - skip to find a new statement
looking for a ‘;’ or a key word to get started again
— DR_model.gms(191) 3 Mb 20 Errors[FIL:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,191,0]
***** Error 143 in** C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms[ERR:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,191,9][LST:233]
A suffix is missing
***** Error 141 in** C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms[ERR:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,191,9][LST:233]
Symbol declared but no values have been assigned. Check for missing
data definition, assignment, data loading or implicit assignment
via a solve statement.
A wild shot: You may have spurious commas in the explanatory
text of a declaration. Check symbol reference list.
***** Error 409 in** C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms[ERR:“C:\Users\towkins\Documents\GAMS\Studio\workspace\DR_model.gms”,191,10][LST:233]
Unrecognizable item - skip to find a new statement
looking for a ‘;’ or a key word to get started again

I made some changes for debugging. Now I have no error. but my objection value is not as expected.

What is wrong with my model and code? I think I couldn’t write the correct code for functions and limits.

Could you please help?
model_equation.JPG

$title dr model

sets p pumps /1*3/
     s hours /0*23/ ;

parameter
    M(s) s period energy cost (dollars per kWh)
 /0 0.390587262
1 0.390587262
2 0.390587262
3 0.390587262
4 0.390587262
5 0.390587262
6 0.687495016
7 0.687495016
8 0.687495016
9 0.687495016
10 0.687495016
11 0.687495016
12 0.687495016
13 0.687495016
14 0.687495016
15 0.687495016
16 0.687495016
17 1.058738057
18 1.058738057
19 1.058738057
20 1.058738057
21 1.058738057
22 0.390587262
23 0.390587262
/;

parameter
    Edr(s) s period demand response call (kWh)
 /0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
10 0
11 0
12 50
13 0
14 0
15 0
16 0
17 0
18 0
19 0
20 0
21 0
22 0
23 0
/;

parameter
    Mdagitim(s) s period distribution payment (dollars per kWh)
 /0 0.0120172
1 0.0120172
2 0.0120172
3 0.0120172
4 0.0120172
5 0.0120172
6 0.0120172
7 0.0120172
8 0.0120172
9 0.0120172
10 0.0120172
11 0.0120172
12 0.0120172
13 0.0120172
14 0.0120172
15 0.0120172
16 0.0120172
17 0.0120172
18 0.0120172
19 0.0120172
20 0.0120172
21 0.0120172
22 0.0120172
23 0.0120172
/;
parameter
    Htuketim(s) s period consumed water height (m)
 /0 0.504
1 0.324
2 0.2304
3 0.2232
4 0.288
5 0.7344
6 0.8352
7 0.8928
8 1.0368
9 1.2672
10 1.3968
11 1.4256
12 1.3968
13 1.152
14 1.008
15 1.008
16 1.0512
17 1.1232
18 1.2816
19 1.3104
20 1.1232
21 1.08
22 1.08
23 0.8928
/;

parameter
    G(s) s period gain from demand response (dollars per kWh)
 /0 0.030899
1 0.023399
2 0.023399
3 0.025812
4 0.025932
5 0.0299
6 0.026299
7 0.025812
8 0.025812
9 0.020761
10 0.022571
11 0.022646
12 0.022571
13 0.022649
14 0.023398
15 0.022613
16 0.022672
17 0.0263
18 0.031105
19 0.031186
20 0.029662
21 0.025
22 0.027098
23 0.025813
/;

parameter
    Emax(p) max power cumsumption of pump p (kWh)
 /1 84.2925
2 84.2925
3 84.2925
/;

variables
z objective function;

positive variables

Hpompalanan(p,s) decision variable
E(p,s) s time period energy consumption of pump p
dH(s) water difference s time period
H(s) water in tank in s time period;

scalar
Hmin minimum water height /3/
Hmax maximum water height /5.7/
Hilk initial water height /4/;


equations
amac
kisit1 for demand sustainability 
kisit2 water height bigger than min 
kisit3 water height smaller than max
kisit4 pumps max energy consumption
kisit5 for demand response call
;

amac.. z =e= sum((p,s), M(s)*(0.056195*(15000*Hpompalanan(p,s)/6))- Edr(s)*G(s)-Edr(s)*Mdagitim(s));
kisit1.. sum (s, -dH(s)) =l= Hilk-Hmin- sum (s, Htuketim(s));
kisit2(s)..Hmin =l= H(s);
kisit3 (s)..H(s) =l= Hmax;
kisit4(p,s)..E(p,s) =l= Emax(p);
kisit5.. sum((p,s), E(p,s)) =g= sum((s),Edr(s));

model dr /all/;
option mip=CPLEX;
option optcr=0;
option optca=0;
option intvarup=0;
solve dr using lp minimizing z;
display Hpompalanan.l;
display Hpompalanan.lo;

Your GAMS program compiles and executes. It creates an LP that even solves to optimality. You say that the objective does not make sense. You are the only one who can debug this. What do you expect? Why does the model not give you the answers you want. This is called model debugging and requires a deep understanding of model logic and data. GAMS support exploring a model is many different ways. I like to often fix variables and see what happens with the rest of the system. There is no simple and free lunch when it comes to model debugging. Good luck.

-Michael

Thank you Michael.

amac.. z =e= sum((p,s), M(s)*(0.056195*(15000*Hpompalanan(p,s)/6))- Edr(s)*G(s)-Edr(s)*Mdagitim(s));

Is this coding is true when you check my objection function?

I know it’s not simple. I m trying to do my best. :frowning:

I think the second term in the objective needs a set of ():

amac.. z =e= sum((p,s), M(s)*(0.056195*(15000*Hpompalanan(p,s)/6))- (Edr(s)*G(s)-Edr(s)*Mdagitim(s)));

-Michael