Loop for objective function

Problems with syntax of GAMS
Luqman Hakeem
User
User
Posts: 21
Joined: 2 months ago

Re: Loop for objective function

Post by Luqman Hakeem » 1 month ago

Renger wrote:
1 month ago
Same procedure:
replace the parameter or variable with one without the index t, remove the sum and, if it is a parameter, initialize it in the loop with the value for period t
Cheers
Renger
It is basically a constraint over a binary variable 'h' as;
retro(i) .. sum(tc, h(i,tc)) =l= 1;
It should run only once (means 'sum of h < 1'). Summation is working but this summation appears in every loop for "t" which is not required.

Luqman Hakeem
User
User
Posts: 21
Joined: 2 months ago

Re: Loop for objective function

Post by Luqman Hakeem » 1 month ago

Renger wrote:
1 month ago
Same procedure:
replace the parameter or variable with one without the index t, remove the sum and, if it is a parameter, initialize it in the loop with the value for period t
Cheers
Renger
Hi Renger!

In the attached file "HGDPwFS", 'h(i,tc)' is a binary variable for fuel switching retrofitting. Retrofitting should only be done only once in the time horizon. But it appears for every loop on "t".
HGDPwFS.gms
(9.48 KiB) Downloaded 9 times
input2.xlsx
(351.99 KiB) Downloaded 14 times

User avatar
Renger
Posts: 550
Joined: 3 years ago

Re: Loop for objective function

Post by Renger » 1 month ago

Hi

I think you could do without t in H(i,t). Then, if in year x, H(i) becomes 1, you fix it to that level and it will stay like this in all t afterwards.

Code: Select all

if(h(i) = 1; h.FX(i)  = 1;);
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist

Luqman Hakeem
User
User
Posts: 21
Joined: 2 months ago

Re: Loop for objective function

Post by Luqman Hakeem » 1 month ago

Renger wrote:
1 month ago
Hi

I think you could do without t in H(i,t). Then, if in year x, H(i) becomes 1, you fix it to that level and it will stay like this in all t afterwards.

Code: Select all

if(h(i) = 1; h.FX(i)  = 1;);
Cheers
Renger
Hi Renger,
Your idea is good as always. But it is showing following errors.
input2.xlsx
(351.86 KiB) Downloaded 10 times
141 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.
143 A suffix is missing
149 Uncontrolled set entered as constant
257 Solve statement not checked because of previous errors
HGDPwFSPangy.gms
(9.58 KiB) Downloaded 11 times

User avatar
Renger
Posts: 550
Joined: 3 years ago

Re: Loop for objective function

Post by Renger » 1 month ago

Hi Hakeem
I am not sure if this is what you are looking for
HGDPwFSPangy.gms
(9.64 KiB) Downloaded 13 times
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist

Post Reply