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.
How to add Constraints inside a loop in GAMS
Re: How to add Constraints inside a loop in GAMS
Hi
You could introduce a flag.
Here the idea in code:
Cheers
Renger
You could introduce a flag.
Here the idea in code:
Code: Select all
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 ...
);
Renger