Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Cplex time limit

    Posted 05/16/12 09:37 AM

    Originally posted by: Rommelds


    Hello members,

    We are experiencing a problem using the time-limit parameter.

    In particular, we have verified that sometimes the CPLEX solver doesn't stop the search process at the desired time-limit. In particular, we fixed a time limit of 120 seconds but CPLEX stops the search at 300+ seconds.

    To control the time, I'm using

    execute  {
     cplex.tilim = 120;
    }
    


    How can I solve this problem?

    Thanks!

    Rommel.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Cplex time limit

    Posted 05/17/12 03:45 AM

    Originally posted by: SystemAdmin


    That is weird. What version of CPLEX do you use?
    Could you post the engine log for the offending example?
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Cplex time limit

    Posted 05/17/12 05:56 PM

    Originally posted by: Rommelds


    Daniel,

    I'm using the version 12.4

    I have a project in Java which calls the .mod file. The Java project contains the data to solve the model. I use de handler to get the data from the project.

    However, I also consider a matrix with 60.000 lines and 5 columns!!! This data is uploaded in the .mod from a .txt file.

    I use the time limit because sometimes the matrix is too big. So, I stop the model.

    I use the following code:

    
    
    
    double result = 0.0; IloOplFactory.setDebugMode(
    
    true); IloOplFactory oplF = 
    
    new IloOplFactory(); IloOplErrorHandler errHandler = oplF.createOplErrorHandler(System.out); IloOplModelSource modelSource = oplF.createOplModelSource(DATADIR + 
    "/3D.mod"); IloCplex cplex = 
    
    null; 
    
    try 
    { cplex = oplF.createCplex(); 
    } 
    
    catch (IloException e) 
    { e.printStackTrace(); 
    } IloOplSettings settings = oplF.createOplSettings(errHandler); IloOplModelDefinition def=oplF.createOplModelDefinition(modelSource,settings); IloOplModel opl=oplF.createOplModel(def,cplex); IloCustomOplDataSource dataSource = 
    
    new MyCustomDataSource(oplF,cromossomo,numeroDeTipos,numeroDeCortes,quantidade,base,cuts,X,Y,Z); opl.addDataSource(dataSource); opl.generate(); 
    
    try 
    { 
    
    if (cplex.solve())    
    {         
    //time limit < 120 seconds result = opl.getCplex().getObjValue(); 
    } 
    
    else    
    {                       
    //time limit > 120 seconds result = 0.0; 
    } ...
    

    The tilim parameter is written in the 3D.mod
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Cplex time limit

    Posted 05/17/12 05:59 PM

    Originally posted by: Rommelds


    Sometimes the matrix has few lines and the model uploads it fast...
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Cplex time limit

    Posted 05/18/12 03:26 AM
    Hi,

    in the 120 s do you include

    opl.generate();
    


    ?

    The time limit only applies to the cplex.solve();

    Regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Cplex time limit

    Posted 05/18/12 07:39 AM

    Originally posted by: Rommelds


    Alex,

    Thanks for the answer.

    I thought the tilim was applied for all the steps to solve the model.

    How can I verify if the data is loaded in 120 sec?

    My model is solved very fast! But my variable matrix][, which data is taken from a .txt file, when it is too big, takes a long time to be calculated. So, if it gets 120 sec or more, I want to stop the model and return 0.0 as result.

    Thanks.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Cplex time limit

    Posted 05/18/12 09:36 AM
    Hi,

    well,

    before and after

    opl.generate();
    

    you could measure the time and check whether the difference is more than 120s.
    If you want the generation itself to stop if it takes too long, you could check the time in execute blocks with

    execute
    {
    d=new Date();
    }
    


    and if the time is too big then you do fail() in order to stop the execution.

    Regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: Cplex time limit

    Posted 05/18/12 11:42 AM

    Originally posted by: Rommelds


    Alex,

    Thanks for the answer!

    It will solve my problem.

    Rommel.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer