Decision Optimization

Decision Optimization

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

 View Only
  • 1.  c++ iloCplex, the importModel() function is very slow

    Posted Tue May 13, 2014 12:15 PM

    Originally posted by: AngelosGeorghiou


    Hi,

    I am currently using CPLEX 12.4 with the c++ interface. I use the function importModel() to read in .lp files containing mixed integer quadratic programs. This function tends to be quite slow, even for problems that are not very big (~1000 variables). In a particular problem instance, it took several minutes to read in the problem and a few seconds to solve the problem to optimality. 

    I have also tried to use the interactive optimizer for the same problem instance, and there the problem was read and solved in a few seconds.

    My code is a modified version of ilomipex4.cpp.

    Is there something I can do to speed up this process?

    Kind regards,

    Angelos


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: c++ iloCplex, the importModel() function is very slow

    Posted Tue May 13, 2014 12:24 PM

    Originally posted by: T_O


    You could try the C callable library instead of Concert. Maybe, there is a huge overhead after reading the file. Still, I am not sure about this.

    Best regards,
    Thomas


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: c++ iloCplex, the importModel() function is very slow

    Posted Wed May 14, 2014 12:48 PM

    I never saw this before. What happens if you just do this:

    IloEnv env;
    IloModel model;
    IloCplex cplex(env);
    cplex.importModel(model, "model.lp");
    cplex.extract(model);
    

    or

    IloEnv env;
    IloModel model(env);
    IloCplex cplex(model);
    cplex.importModel(model, "model.lp");
    

    Does this also take very long? If yes, could you post your LP file here? If it does not take that long, what is different in your code?


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: c++ iloCplex, the importModel() function is very slow

    Posted Wed May 14, 2014 02:25 PM

    Originally posted by: AngelosGeorghiou


    Hi,

    I have now run both version of the proposed code with very similar results. I don't believe that the extract() function is the one causing the trouble. I have run and timed both on the attached problems with the following results

    model1.lp, importModel() takes ~10 seconds, extract() takes ~1second

    model2.lp, importModel() takes ~120 seconds, extract() takes ~1second

    The funny thing is that it takes less than a second to read and solve both problems with the interactive optimizer.

    Is it possible that I am compiling the code with the incorrect flags? I am currently compiling my c++ program with (-m64 -O -fPIC -fexceptions -DIL_STD -lilocplex -lcplex -lconcert -lm -lpthread -Wall -w -O3 -o)

    Thank you for your help

    best wishes,

    Angelos


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: c++ iloCplex, the importModel() function is very slow

    Posted Thu May 15, 2014 02:25 AM

    What you are facing is a known issue with older versions of CPLEX. The problem is fixed in version 12.6. With 12.6 I can importModel() your files in under one second. With 12.5 it takes 9 and 83 seconds (similar to what you reported).

    If you cannot upgrade to 12.6 you can try this:

    env.setNormalizer(IloFalse);
    cplex.importModel(model, ...);
    env.setNormalizer(IloTrue);
    

    In case you do that, please also read the "Normalization: Reducing linear terms" section in the user manual. This explains the effects of the setNormalizer() calls. Unless you have two variables with the same name, disabling the normalizer for importModel() should be fine.


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: c++ iloCplex, the importModel() function is very slow

    Posted Thu May 15, 2014 04:26 AM

    Originally posted by: AngelosGeorghiou


    Many thanks Daniel


    #CPLEXOptimizers
    #DecisionOptimization