Overall program run time/time limit Topic is solved

Problems with modeling
Post Reply
Posts: 8
Joined: 10 months ago

Overall program run time/time limit

Post by Ilya » 10 months ago

I'm implementing sequential solver calls in a benders loop.
It is possible to set the reslim option to limit the solution time of a single solver call.
It is also possible to measure the overall loop time by accumulating the solver time returned in resUsd using a scalar parameter.

Things become more complicated for me if the same setup is implemented using a Python ModelInstance (to avoid repeated model generation in the benders loop).
I simply don't know what will be the ModelInstance property that would return the used time after a call to the solve() method (the Python docs are not so easy to read).

I also wonder if there is an option to set a global time limit for the whole model (not just for a solver call).

User avatar
Posts: 335
Joined: 2 years ago

Re: Overall program run time/time limit

Post by bussieck » 10 months ago

1) You can do time accounting independent of the resUsd (which relies in some way on the fact that the solver returns the correct time). Just do time stamps in GAMS:

Code: Select all

scalar now, accTime 'in seconds' /0/;
now = jnow;
solve mymodel us ...;
accTime = accTime + (jnow-now)*60*60*24;
abort.noerror$(accTime>1000) 'stop after 1000 secs', accTime;
If you do now a solve or a modelinstance solve the time accounting is independent of this.

2) The resLim for the solve method of a GAMSModelInstance is determined when you generate the model instance (instantiate). It cannot be updated (only through a solver option file and the specific option, e.g. tilim in Cplex).

3) There is no option to stop a GAMS run after a given time limit.


Post Reply