Page 1 of 1

Two queries

Posted: Thu Apr 25, 2019 7:12 am
by qli091
Hi GAMS friends,

I am running a programme with a loop on 25 years. I want the programme to stop whenever an infeasible solution is found. That will save time from running over all the 25 years. I think $exit or $stop will help. But I don't know how to add the condition. Please help.

Another problem is that I found it's very difficult to make progress on the iteration of 25 years. Problems keep poping up in nearly every year. It taks a long time to fix the programme for the 1st year, and then a long time to pass the 2nd year, and so on. Is there any technic of how to smoothly run long-time iterations?

Many thanks,

Re: Two queries

Posted: Mon Apr 29, 2019 1:19 pm
by Fred

$exit and $stop are compile time commands and won't help to interrupt a run at execution time.

Model attributes solveStat and modelStat allow to check the Status of your solves during execution time: ... Omodelstat ... Osolvestat

Then you can for example abort the execution if something unexpected (like model infeasible) happens

Code: Select all

if(mymodel.modelstat=4, abort 'model is infeasible;);
Not sure for what kind of "technic" you are looking to run your program "smoothly".
Maybe option savepoint is helpful. It let's you easily store the solution points of solve statements in GDX files such that that theoretically you don't have to repeatedly solve he same model instance again and again but could instead simply load the solution from the corresponding GDX file: ... Osavepoint

I hope this helps!