How to add Constraints inside a loop in GAMS

Dear All,

According to the GAMS manual, one cannot make declarations or define equations inside a loop.

I need to add constraints to the mathematical model inside a loop and execute the solve statement. Is there any other way to add constraints to a model inside a loop?

Thanks in advance.

Hi
You could introduce a flag.

Here the idea in code:

set lnr /1*10/;

parameter flag(lnr);

flag(lnr) = 0;
flag("1") = 1;

equations
   constrflagged   'The constraint you want to be flagged',
   ....
 
 constrflagged$flag(lnr)..
   ...
   
 model mymodel /all/;
 
 loop(lnr,
   solve mymodel ...
 );

Cheers
Renger