Hello,
I am currently creating an optimization model that maximizes entropy with respect to a varying population. I'll be doing a lot of scenarios and was wondering if there is a way to make GAMS stop at an infeasible solution while in the loop.
I noticed there are some answers about this with modelstat, but I don't fully understand the syntax of that. Can someone please help? Thank you!
$offorder
Model selfsufficiency /all/ ;
file results /results_entropy.res/ ;
put results ;
loop(Pop,
varying_population = (ord(Pop))*130000 ;
Solve selfsufficiency using NLP maximize TotalEntropy ;
put @5, varying_population, @15, TotalEntropy.l/;
);
putclose results;
How to iterate/loop until GAMS solution is infeasible
-
- User
- Posts: 2
- Joined: 7 years ago
Re: How to iterate/loop until GAMS solution is infeasible
Code: Select all
scalar stopped /0/;
loop(Pop$(not stopped),
varying_population = (ord(Pop))*130000 ;
Solve selfsufficiency using NLP maximize TotalEntropy ;
if (selfsufficiency.modelstat=1 or selfsufficiency.modelstat=2,
put @5, varying_population, @15, TotalEntropy.l/;
else
put @5, varying_population, @15, "Not optimal anymore. Model status: ", selfsufficiency.modelstat:0:0 /;
stopped = 1;
);
);
putclose results;
-Michael
Re: How to iterate/loop until GAMS solution is infeasible
Maybe you can try "abort" command. Good luck