Hello,
I'm Beginning with GAMS. I would like to know if it's possible to do loop with "sub-set"? For example considering a table with the months of the year /M1*M120/, is it possible to create sub-set as /M1*M12/, /M13*M24/, /M25*M36/ etc.. and do a loop on a statement in order to have the results for each year?
Or do I have to do several tables?
Thank you for your help,
Stan
Read part of a table
Re: Read part of a table
Hi Stan
You can build subsets like this
or loop over all years but constrain the loop to the first half
If you have a table over all years, eg.
You could for example values to a parameter with only values of the first half of years:
Hope this helps
Cheers
Renger
You can build subsets like this
Code: Select all
set
year ' 'Full set of years' /M1*M120/;
year1(year) 'First half of all years' /M1*M12/,
year2(year) 'Second half of all years' /M25*M36/;
loop(year1,
....
);
Code: Select all
loop(year$year1(year),
..
);
Code: Select all
info(year, techn) Table with info on each technology for each year;
Code: Select all
parameter firstech(year1, techn);
firsttech(year1, techn) = info(year1, techn);
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Enjoy modeling even more: Read my blog on modeling at The lazy economist