Can someone help me with GAMS error 148. I have attached the code with errors.l

Problems with modeling
Post Reply
Khattack_khan
User
User
Posts: 1
Joined: 5 years ago

Can someone help me with GAMS error 148. I have attached the code with errors.l

Post by Khattack_khan »

1
2
3 * Difinition of the sets ;
4 Sets
5 i Number of buses /1*16/
6 s Reference bus /1/
7 DG Power generated by dispatchable DGs units /2,7,8,14/
8 SG Power generated by stochastic DGs units /13,15/
9 GSP Upstream grid supply points for transaction with the electricity
wholesale market /1,11,16/
10 d day Period /1*28/
11 t Set of hourly time intervals /1*84/
12 SubP Load level/1valley, 2valley, 3valley, 1shoulder, 2shoulder, 3sho
ulder, 1peak, 2peak, 3peak, 1weekend, 2weekend, 3weekend/
13 DR Hourly Load curtailment demand response (unserved energy of cust
omers) /1*24/ ;
14
15 Alias(i,j) ;
16
17 * Difinition of the Parameters ;
18
19 Table Dispatchable_data(DG,*) Characteristics of dispatchable units incl
uded in VPP portfolio
20 Pmin Pmax Generation_cost Rampup Rampdown Startup_cost
Shutdown_cost
21 2 0 4 37 1 1 20
25
22 7 0 5 40 1.25 1.25 20
25
23 8 0 5.5 35 1.375 1.375 50
25
24 14 0 7 45 1.75 1.75 50
25 ;
25
26 Table Stochastic_data(SG,*) Characteristics of stochastic units included
in VPP portfolio
27 Pmin Pmax Generation_cost
28 13 0 9 55
29 15 0 7 65 ;
30
31
32
33 Table GSP_data (GSP,*) The capacity of interconnection of transformers su
bstation in (MW)with the main grid at GSP
34 GSP
35 1 40
36 11 24
37 16 12 ;
38
39
40 Table DR_data(DR,*) Characteristics of the houly load curtailment demand
response for a period of one day
41 DRmin DRmax DR_cost
42 1 0 0.575 50
43 2 0 0.540 30
44 3 0 0.549 35.5
45 4 0 0.551 41
46 5 0 0.575 50
47 6 0 0.610 65
48 7 0 0.626 68
49 8 0 0.645 75
50 9 0 0.663 78
51 10 0 0.666 76
52 11 0 0.628 65
53 12 0 0.682 85
54 13 0 0.698 87
55 14 0 0.663 80
56 15 0 0.628 70
57 16 0 0.593 65
58 17 0 0.600 65
59 18 0 0.596 80
60 19 0 0.654 80
61 22 0 0.652 75
62 23 0 0.584 65
63 24 0 0.580 65 ;
64
65
66 Table Price_DA (d,*) Day ahead demand and market price forecasts for a pe
riod of one day
67 Demand LMP
68 1 40 46.03
69 2 30 45.14
70 3 25 45.50
71 4 20 45.70
72 5 35 55.80
73 6 40 82.28
74 7 15 84.80
75 8 10 83.44
76 9 20 76.95
77 10 15 69.09
78 11 25 65.84
79 12 30 59.47
80 13 35 56.47
81 14 40 53.77
82 15 15 52.90
83 16 10 71.44
84 17 30 108.31
85 18 35 89.54
86 19 20 76.83
87 20 40 73.60
88 21 25 59.59
89 22 30 52.47
90 23 15 47.77
91 24 35 49.17 ;
92
93 table SubP_data(SubP,*) Subperiod load level
94 block min max Cost
95 1valley 1 5 15 39.16
96 2valley 2 5 15 43.19
97 3valley 3 2.5 5 37.31
98 1shoulder 1 2.5 7.5 41.45
99 2shoulder 2 2.5 5 47.18
100 3shoulder 3 2.5 7.5 51.03
101 1peak 1 2.5 5 42.26
102 2peak 2 2.5 7.5 56.39
103 3peak 3 2.5 5 52.12
104 1weekend 1 2.5 7.5 57.16
105 2weekend 2 2.5 5 61.04
106 3weekend 3 2.5 7.5 64.23 ;
107
108 parameters LMP(GSP,d,subP),Charge_DSO(d,subP),Pdemand(d,subP),Pdemand_min
,Pdemand_max, DRmin, DRmax ;
109 scalars a is the first model estimation parameter for distribution networ
k demand /0.07/
110 b is the second model estimation parameter for distribution network deman
d /8/;
111 scalar BM is a positive large number exceeding any max feasible value /10
00/;
112 scalar HD Bilateral hourly tolerance (in *10%) /0.0/;
113
114 parameters alpha1, alpha2, alpha3, alpha4 ;
115 alpha1=0.95 ;
116 alpha2=1.05 ;
117 alpha3=1.00 ;
118 alpha4=1.00 ;
119
120 LMP('1',d,SubP) = alpha1 * Price_DA(d,subP) ;
121 LMP('11',d,SubP)= alpha2 * price_DA(d,subP) ;
122 LMP('16',d,SubP)= alpha3 * price_DA(d,subP) ;
123
124 pdemand(d,subP)= a*price_DA(d,subP)+b ;
125 Charge_DSO(d,SubP)=alpha4*price_DA(d,subP) ;
126
127
128
129
130
131 * Difinition of the variables ;
132
133 Variables
134 Z Value of objective function
135 Pgrid(GSP,d,subP) The capacity of interconnection with the main grid at G
SP
136 Pdg(DG,d,subP) The cost of generatoin from dispatchable units(DG)
137 Psg(SG,d,subP) The cost of generation from stochastic units(SG)
138 Pdl(d,subP) The cost of flexible load to curtail its demand(DR)
;
139
140
141 pdg.lo(DG,d,subP) = Dispatchable_data(DG,"Pmin") ;
142 pdg.up(DG,d,subP) = Dispatchable_data(DG,"Pmax") ;
143 psg.lo(sg,d,subP) = Stochastic_data(SG,"pmin") ;
144 psg.up(sg,d,subP) = Stochastic_data(SG,"Pmax") ;
145 *pdl.lo(d,subP) = DR_data(DR,"DRmin") ;
146 *pdl.up(d,subP) = DR_data(DR,"DRmax") ;
147
148 * Necessary equations ;
149
150 Equations
151
152 eq1 Z
153 * eq2 Interconnection_cap1
154 * eq3 Interconnection_cap2 ;
155 ;
156
157
158
159
160
161 eq1 .. Z=e= (1)*sum(d,SubP),pdemand(d,SubP)*Charge_DSO(d,SubP)
**** $148,409
162 + sum (GSP,Pgrid(GSP,d,SubP)*LMP(GSP,d,SubP))
163 - sum (DG,Pdg(DG,d,subP)*Dispatchable_data(DG,"Generation_cost")) + (Pdg(
DG,d,subP)*Dispatchable_data(DG,"Startup_cost"))+ (Pdg(DG,d,subP)*Dispatch
able_data(DG,"Shutdown_cost"))
164 - sum (SG,psg(SG,d,SubP)*Stochastic_data(SG,"Generation_cost"))
165 - sum (pdl(d,SubP)*DR_data(DR,"DR_cost"));
166
167 * eq2(GSP).. Pgrid(GSP)=l=SS_cap(GSP) ;
168 * eq3(GSP).. Pgrid(GSP)=g=-SS_cap(GSP) ;
169
170
171
172 Model VPP /all/;
173
174 solve VPP using mip maximizing Z;
**** $257

**** LIST OF STRAY NAMES - CHECK DECLARATIONS FOR SPURIOUS COMMAS
**** STRAY NAME Pdemand_min OF TYPE PARAM
**** STRAY NAME Pdemand_max OF TYPE PARAM
**** STRAY NAME DRmin OF TYPE PARAM
**** STRAY NAME DRmax OF TYPE PARAM
GAMS Rev 240 WEX-WEI 24.0.2 x86_64/MS Windows 09/12/18 13:29:22 Page 2
G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m
Error Messages


148 Dimension different - The symbol is referenced with more/less
indices as declared
257 Solve statement not checked because of previous errors
409 Unrecognizable item - skip to find a new statement
looking for a ';' or a key word to get started again

**** 3 ERROR(S) 0 WARNING(S)
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: Can someone help me with GAMS error 148. I have attached the code with errors.l

Post by bussieck »

You should use a code section to display code or better attach the model and listing. Because of that I did not run the model. Nevertheless, some sums in eq1 look suspicious:

Code: Select all

sum(d,SubP),pdemand(d,SubP)*...
should read

Code: Select all

sum((d,SubP),pdemand(d,SubP)*...
No idea what you try to say with this sum: sum (pdl(d,SubP)*DR_data(DR,"DR_cost")). Parenthesis also seem not to match.

-Michael
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Can someone help me with GAMS error 148. I have attached the code with errors.l

Post by Renger »

Hi

Michael was faster with replying.
Another hint:
Have a look at https://www.gams.com/latest/docs/UG_FixingErrors.html and search for "errmsg". If you use the trick described there, the error messages will appear in your listing file directly below the error itself.

Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
ullah_zahid
User
User
Posts: 2
Joined: 5 years ago

Re: Can someone help me with GAMS error 148. I have attached the code with errors.l

Post by ullah_zahid »

Error 148 is disappeared, but unfortunately 5 more errors appeared which are 149 GAMS. It looks like syntax errors. Can you please help me in sorting these errors. GAMS code is attached.
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Can someone help me with GAMS error 148. I have attached the code with errors.l

Post by Renger »

Hi

Take a good look at the error messages. They appear right where you made an error.

Code: Select all

 163   eq1..  Z =e=(1)*sum((d,dl),pdemand(d,dl)*Charge_DSO(d,dl))
 164   + sum  (GSP,Pgrid(GSP,d,dl)*LMP(GSP,d,dl))
****                          $149,149      $149,149
**** 149  Uncontrolled set entered as constant
Gams tells you what went wrong: You used a set that is uncontrolled. You sum this expression over GSP, but don't give information on what to do with the sets d and dl, so Gams doesn't know waht do with these sets (they are "uncontrolled").
Either the equation is meant to be over the set d and dl (e.g. eq1(d, dl) and at the same time remove the summing over d and dl in the first set) or you want to sum over GSP,d, and dl in the second term.

Hope this helps
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
ullah_zahid
User
User
Posts: 2
Joined: 5 years ago

Cost calculation

Post by ullah_zahid »

Hello everybody,
I am trying to maximize profit. The objective function for profit maximization is given Profit = (Revenue - Cost). Equation for profit and revenue both are working , but the main problem is with the cost equation. Cost equation output is zero. Although it gives feasible objective value which is wrong. Can you please help me to sort out this problem.
Code file is attached.
Kind regards.
Attachments
OPF_9bus_06_12_2018.gms
(7.3 KiB) Downloaded 177 times
Post Reply