Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Problem with setParam(IloCplex::TiLim, <>)

    Posted 08/11/16 02:54 PM

    Originally posted by: sana_


    Hi,

    I have a problem when I call the setParam(IloCplex::TiLim, <>) many times in the optimizing process.

    I have an IP to solve. I use a column generation to solve the LP, convert all variables and use Cplex to solve the IP.

     

    cplex.setParam(IloCplex::TiLim, 600); //I use a column generation but I not necessary wait it to converge to the LP optimal solution. I set the problem to terminate if an elapsed time is reached.

    clock_t start = clock(); // In the same time I use the clock library c++ to compute the time elapsed to run the column generation. 

        run_gencol();
    time_gencol += (clock() - start)/(double)CLOCKS_PER_SEC;

    for(IloInt i=0; i<varX.getSize(); ++i) // I convert all variables considered  in the master problem.
    {
           model.add(IloConversion(env, varX[i], ILOBOOL)); 
    }

    cplex.setParam(IloCplex::TiLim, 1200-time_gencol ); //I set the time limit at 1200-time_gencol  (I want to limit the total time (time of column generation+time of BB at root node) at 1220 seconds)

    cplex.solve(); //I optimize the IP

    The problem that when I check the file log I see that the time elapsed exceeds the time limit :(

    For example, for a specific instance I get
    Total (root+branch&cut) = 3273.73 sec. (848714.01 ticks)

    First, the 3273.73 includes the column generation run or only the last call to cplex.solve();

    Second, when I set the time limit at 600 second for the column generation, Cplex applies this time limit to each call of the LP optimization call in each iteration ''cplex.solve();'' or it cumulates all the calls. I think that I did a mistake here and that the time limit is considered in each call :(

    Third, I want to know what Cplex does if the time limit is negative ?

    Last, any suggestion to allow me to implement my procedure? A column generation then a BB at the root node with time_limit(column generation)=600 seconds and time_limit(column generation + BB at the root node)=1200

    Thanks a lot for your reply!

    SD

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Problem with setParam(IloCplex::TiLim, <>)

    Posted 08/11/16 03:45 PM

    First of all, clock() measures CPU time while CPLEX by default measure wallclock time. Did you change the clock type parameter to make CPLEX measure CPU time? If not you need to synchronize these two measurements. I suggest to use wallclock time everywhere and instead of clock() use either gettimeofday() or clock_gettime().

    Second, can you just print out the value to which you are setting the time limit, i.e., 1200 - time_gencol and double check it is reasonable (in particular that it is smaller than 1200).

    Third, a time limit set via TiLim applies to each call of solve(). The time is not accumulated across multiple calls to solve().

    Finally, if you attempt to set a negative time limit then CPLEX should throw an exception.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Problem with setParam(IloCplex::TiLim, <>)

    Posted 08/11/16 04:00 PM

    Originally posted by: sana_


    Hi Mr. Daniel,

    thanks for your clarifications.

    It's more clear now. I have only one point that I did not understrand. What do you mean by ''Did you change the clock type parameter to make CPLEX measure CPU time?''

    You mean that there is an explicit instruction that I must add to the c++ code to allow me the use of the time limit parameter.

    Thanks again,

    Sana

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Problem with setParam(IloCplex::TiLim, <>)

    Posted 08/11/16 06:12 PM

    In addition to the TiLim parameter, which tells CPLEX how much time to allow, there is a second parameter (ClockType) which tells CPLEX how to measure that time. The default value (2) is "wall clock time" -- how much of your life ticked away while you were waiting for an answer. The other possible values for it are 0 (let CPLEX decide) or 1 (actual CPU time). If you want to use wall clock time, you do not need to set this parameter, just TiLim. If you want to use CPU time (or you want to let CPLEX decide, although I have no idea why anyone would choose that), you need to set both.


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Problem with setParam(IloCplex::TiLim, <>)

    Posted 08/11/16 06:17 PM

    Originally posted by: sana_


    OK! Thanks for your answer Mr. Paul :) 


    #CPLEXOptimizers
    #DecisionOptimization