Decision Optimization

Decision Optimization

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

 View Only
  • 1.  c++ IloCplex ImportModel Function is to slow, compared with read problem from cplex console application (v 12.6)

    Posted Mon August 04, 2014 09:41 AM

    Originally posted by: lmalbino


    Hello, i'm trying to run a model(39054 Variables and 2159478 constraints) from a lp file with importModel function (c++ IloCplex), and the function takes about 30000 seconds to read the model. If I try to read the model from the cplex console with the read command, the model is loaded in 7 seconds. Any justification for this difference? I've seen some earlyer topic about this function and what I understand, was that in version 12.5.* exists some problem and that version 12.6 already solve that problem. Probabily I don't understand the user or the problem was different.
    Any help about his issue?
    Thank you for the attention.

     Luis Albino


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: c++ IloCplex ImportModel Function is to slow, compared with read problem from cplex console application (v 12.6)

    Posted Tue August 05, 2014 01:56 AM

    Does your model include any quadratic terms, either in the objective or in constraints?

    Does it help to call IloEnv::setNormalizer(false) before calling IloCplex::importModel()?

    Could you post your model here?


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: c++ IloCplex ImportModel Function is to slow, compared with read problem from cplex console application (v 12.6)

    Posted Tue August 05, 2014 04:23 AM

    Originally posted by: lmalbino


    Hello,

    No quadratic terms.

    Doesn't help, I already have tried that with version 12.5.1, and it was in the implemented code. So the loading times that I present are with that parameter defined.

    I' ve upload the model file.

    Thank you for the help

    Best regards

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: c++ IloCplex ImportModel Function is to slow, compared with read problem from cplex console application (v 12.6)

    Posted Tue August 05, 2014 08:08 AM

    Thanks for the file.

    I could reproduce the problem here. I have not figured out yet what the problem is but I found a simple workaround: Use much shorter names. When I rename the variables to x1 through xN and the constraints to c1 and cN then importModel() runs much faster. Is it an option to use shorter names? If so, then you should not create an .lp file but an .rlp file. That will store those generic names instead of the original names. Or even better, export as a .sav file without any names.

    We will try to figure out why import with longer names is so slow.


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: c++ IloCplex ImportModel Function is to slow, compared with read problem from cplex console application (v 12.6)

    Posted Wed August 06, 2014 07:24 AM

    Originally posted by: lmalbino


    Hello, thank you for your help.

    For now the problem is solved, we have reading times of 9 seconds with .rlp files.

    Thank you

    Best Regards

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: c++ IloCplex ImportModel Function is to slow, compared with read problem from cplex console application (v 12.6)

    Posted Wed August 06, 2014 04:49 PM

    We have found (and fixed) what causes this performance problem. A workaround that allows you to keep the long names is to replace code like

    IloModel model(env);
    IloCplex cplex(model);
    cplex.importModel(model, ....);

    by

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

    The point here is that at the time you call importModel() cplex does not yet have the model extracted. You could also do

    IloModel model = cplex.getModel();
    cplex.clear();
    cplex.importModel(model, ...);
    cplex.extract(model);

    With any of the two rearranged code, reading the file should be almost as fast as in the interactive.


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: c++ IloCplex ImportModel Function is to slow, compared with read problem from cplex console application (v 12.6)

    Posted Fri November 22, 2019 02:45 PM

    Originally posted by: Nadere


    Hello,

    I have SOCP model, when the program reaches the line "cplex.extract(model)",  it takes several minutes to pass it. here are some constraints in the model:

    linear constraints;

        for (p = 0; p < m; p++)
                    for (d = 0; d < n; d++)
                        for (i = 0; i < o; i++)
                            for (j = 0; j < adj_list[i].size(); j++)
                                model.add(ca1[p][d][i][j] * ca1[p][d][i][j] + ca2[p][d][i][j] * ca2[p][d][i][j] <= ca3[p][d][i][j] * ca3[p][d][i][j]);

                for (p = 0; p < m; p++)
                    for (d = 0; d < n; d++)
                        for (i = 0; i < o; i++)
                            for (j = 0; j < adj_list[i].size(); j++)
                                model.add(ca4[p][d][i][j] * ca4[p][d][i][j] + ca5[p][d][i][j] * ca5[p][d][i][j] <= ca6[p][d][i][j] * ca6[p][d][i][j]);
                for (p = 0; p < m; p++)
                    for (d = 0; d < n; d++)
                        for (i = 0; i < o; i++)
                            for (j = 0; j < adj_list[i].size(); j++)
                                model.add(ca7[p][d][i][j] * ca7[p][d][i][j] + ca8[p][d][i][j] * ca8[p][d][i][j] <= ca9[p][d][i][j] * ca9[p][d][i][j]);
                   for (p = 0; p < m; p++)
                        for (d = 0; d < n; d++)
                             for (i = 0; i < o; i++)
                            for (j = 0; j < adj_list[i].size(); j++)

                   model.add(ca10[p][d][i][j] * ca10[p][d][i][j] + ca11[p][d][i][j] * ca11[p][d][i][j] <= ca12[p][d][i][j] * ca12[p][d][i][j]);
                        
     model.add(IloMaximize(env, obj)); // linear objective function

    obj.end();

    IloCplex cplex(env);
    cplex.extract(model); //*************************//

     cplex.setOut(env.getNullStream());

     cplex.setParam(IloCplex::Param::Barrier::QCPConvergeTol, 0.03);
     cplex.solve();

    My question that is there any way to speed up extracting the SOCP model? 

    Thanks,

    Nadere 


    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: c++ IloCplex ImportModel Function is to slow, compared with read problem from cplex console application (v 12.6)

    Posted Wed January 08, 2020 04:11 AM