I am using C to write my code and solve it with CPLEX optimizer. I want to limit the time on CPLEX so that it stops solving if time is larger than 10 hours. I have search online and I found the timelimit parameter of CPLEX. However, I do not know where to insert it or how to use it. Any help would be much appreciated! Thank you.
Asked
Active
Viewed 5,013 times
3 Answers
3
The parameter for time limit in the C interface is CPX_PARAM_TILIM. It is a double parameters, and the value represents the number of seconds cplex will run before returning the best solution it has so far (unless it finds an optimal solution earlier). You set the parameter with the CPXsetdblparam function. To set a time limit of 10 hours, you would call
CPXsetdblparam(env, CPX_PARAM_TILIM, 36000.0);
By default, cplex uses wall clock time, but if you want 10 hours of CPU time, you can set the integer parameter CPX_PARAM_CLOCKTYPE to value 1.

David Nehme
- 21,379
- 8
- 78
- 117
1
As of CPLEX version 12.9, IloCplex::TiLim
is deprecated. Use IloCplex::Param::TimeLimit
instead:
cplex.setParam(IloCplex::Param::TimeLimit, 7200);

henriquefalc
- 341
- 2
- 3
0
In cplex(12.7.1 version) c++ interface, I use the following code:
cplex.setParam(IloCplex::TiLim, 1);
so cplex has limit running time: 1s.

Dongxu Wang
- 41
- 5