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?
Then you can for example abort the execution if something unexpected (like model infeasible) happens
...
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: https://www.gams.com/latest/docs/UG_GamsCall.html#GAMSAOsavepoint