Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Differences in CPLEX/ILOG Concert Tech performance

    Posted Wed February 18, 2015 02:59 AM

    Originally posted by: DianaHuerta


    Hello, 
     
    I have some doubts about cplex performance, I would like to be sure there is not a bug in my development. I have modeled a problem using ILOG concert tech & c++. I made 3 types of tests in order to identify some performance differences between the runs. 
     
    My first test was to create the basic model of my problem, then apply the cplex.extract(model) function,  cplex.exportModel(NomInstance), and finally cplex.solve(). For this run I obtained the .lp, .log and .sol files. Then I run again my program but now instead of creating the model and solving it, I imported the model obtained in the my first run (using cplex.importModel(model, mymodellp, obj, var, rng, lazy, cuts);) and then I solved it.  For this test, I compared lps, logs and sols files and I obtained some CPU times differences and no more. For me that was understandable.
     
    The problem is when I add a lazyconstraint & a callback function in both modes (creating & solving or imported & solving). Those functions are "dummies" or empty. I obtained the same files and when I compared them, I saw differences in the number of explored nodes and the best objective functions found at each node. At the end, the final solution remains the same, but I don't know why it can happen. As far as I know, when lazy constraints & callbacks are added, some features are disabled in order to obtain a correct performance of CPLEX methods. But in this case, the lazy & callback were empty, so I was expected that the behavior was similar to the first test.
     
    As another test, I fixed some parameters in order to "remove" some features which may have influenced in the performance, but the differences still appear. 
     
    Does anyone know what could be happening?
     
    I'm using  CPLEX 12.5.0.0 through C++ API (Visual Studio 2010).

    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Differences in CPLEX/ILOG Concert Tech performance

    Posted Wed February 18, 2015 06:30 AM

    Basically everything you describe is expected. Here is why:

    The LP model format is not suitable for reproducing results. If you export your model to LP and then import it, this may change the order of variables, may truncate coefficients, etc. You may want to repeat that experiment but export to a SAV file instead. Exporting to a SAV file and then solving with the exact same parameter settings on the same machine should show the same performance.

    As for callbacks: just adding a lazy constraint callback (even an empty one) will disable dynamic search. So if you make comparisons you should compare this to a run that has CPX_PARAM_MIPSEARCH set to 1. Also, lazy constraint callbacks will disable dual reductions (CPX_PARAM_REDUCE = 1) and non-linear reductions (CPX_PARAM_PRELINEAR = 0). So your reference run should have these parameter settings as well.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Differences in CPLEX/ILOG Concert Tech performance

    Posted Wed February 18, 2015 10:21 AM

    Originally posted by: DianaHuerta


    Thank you for your explanation, 

    I have made one test more considering your advice, but there are still differences between log files. May be, I'm not applying correctly the way to obtain a sav file.

    Is there an extra step I need to do in order to get the same log file?.

    *************************************************************************

    This is a part of the code I use to export the model into a sav file:

    IloCplex::Callback sec = cplex.use(MyCallback(env)); //empty
    IloCplex::Callback sec2 =  cplex.use(MyLazyC(env)); //empty

    //Fix parameters ...

    cplex.extract(model);
    //cplex.exportModel("MyModel.sav");
        
    // Optimize the problem and obtain solution.
    if ( !cplex.solve() ) {
    env.error() << "Failed to optimize SAV" << endl;
    env.out() << "Solution status = " << cplex.getStatus() << endl;
    throw(-1);
    }
     
    cplex.exportModel("MyModel.sav");

    ******************************************************************************************

    And this part is when I import the model and resolve it to compare files:

    IloCplex cplex(env);

    IloObjective   obj;

    IloNumVarArray var(env,1000);
    IloRangeArray  rng(env,1000);
    IloRangeArray  lazy(env,1000);
    IloRangeArray  cuts(env,1000);
     
    cplex.importModel(model, "MyModel.sav", obj, var, rng, lazy, cuts);
     
    cout<<"Lazy:\n"<<lazy<<endl;
    cout<<"Cuts:\n"<<cuts<<endl;
     
    if(lazy.getSize() > 0) cplex.addLazyConstraints(lazy);
    if(cuts.getSize() > 0) cplex.addUserCuts(cuts);
     
    IloCplex::Callback sec = cplex.use(MyCallback(env)); //empty
    IloCplex::Callback sec2 =  cplex.use(MyLazyC(env)); //empty

    //Fix parameters ...

    cplex.extract(model);

            if ( !cplex.solve() ) {

               env.error() << "Failed to optimize SAV" << endl;
               throw(-1);
            }

    cplex.exportModel("BModelImport.sav");

     

    I send you the files I obtained. Files with the label "_Import" are the ones obtained with the import function.

    Thank you.

    Diana

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Differences in CPLEX/ILOG Concert Tech performance

    Posted Wed February 18, 2015 12:29 PM

    Originally posted by: DianaHuerta


    Another question I have, is how to add constraints, that come from a lazy/Callback function, to the SAV file?.  The thing is when I add my lazyconstraints & callbacks functions (now these are not empty), and then save the SAV file, it has not that information. It seems to be like the original model (without any new constraint added). 
     
    How can I manage this in order to obtain the final SAV file (with lazy & users cuts added)?.
     
    I just have found that I need to use the exportmodel function and the add function to aggregate the new constraints, but I have not found  an example about how to apply it.
     
    I would like to understand how it operates. I will be very thankful for your help.

    Diana.

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Differences in CPLEX/ILOG Concert Tech performance

    Posted Tue February 24, 2015 02:14 AM

    Constraints that you add from a callback will never be written to a SAV file (or any other CPLEX file). The only way to get all of them into a file is to

    1. keep a global list of the separated lazy constraints/user cuts
    2. after solve() returns use IloCplex::addLazyConstraints() and IloCplex::addUserCuts() to add the constraints/cuts from the global list
    3. use IloCplex::exportModel() to export the model including the separated constraints/cuts

    Without step 2 function exportModel() will only output the original model (without anything you separated in your callbacks).


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Differences in CPLEX/ILOG Concert Tech performance

    Posted Tue February 24, 2015 02:09 AM

    Does it help to read in the model like this:

    IloModel model(env);
    IloCplex cplex(model);
    cplex.importModel(model, "MyModel.sav");

    IloCplex::Callback sec = cplex.use(MyCallback(env)); //empty
    IloCplex::Callback sec2 =  cplex.use(MyLazyC(env)); //empty
    cplex.solve();

    instead of what you are doing right now? This way you do not have to explicitly extract the model and do not need to add the lazy constraints explicitly either.


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Differences in CPLEX/ILOG Concert Tech performance

    Posted Wed March 04, 2015 11:10 AM

    Originally posted by: DianaHuerta


    Thank you!, your answers helped me a lot. Now I have my SAV file complete =).

    Now I have detected one instance where the optimum is different. If I solve my model (adding the lazy&callbacks constraints during the branch & cut process) the optimal solution is different than the obtained using the import function.

    The optimal solution reported by the B&C is:

    429(1)  97.189  366.85  0       64      64      5623.11 5626    0.000513797
    430(0)  97.204  367.264 0       64      64      5626    5626    0
    Solution status = Optimal
    Solution value  = 5626
    Number of B&B nodes = 430

    I would like to know how I can give to cplex that solution in order to obtain the same one when I import it (or at least to know if something is happening or if a cut is violated for the "optimal" B&C solution).

     I have tried the following things:

    When I solve the B&C, I save the final solution in a SOL file (and also have tested with the MST file).

    Using the first one I have the following:

    Warning, line 28: Constraint index '2' out of range.
    Warning, line 29: Constraint index '3' out of range.
    Warning, line 30: Constraint index '4' out of range.
    Warning, line 31: Constraint index '5' out of range.
    Warning, line 32: Constraint index '6' out of range.
    Warning, line 33: Constraint index '7' out of range.
    Warning, line 34: Constraint index '8' out of range.
    Warning, line 35: Constraint index '9' out of range.
    Warning, line 36: Constraint index '10' out of range.
    Warning, line 37: Constraint index '11' out of range.
    Warning, line 38: Constraint index '12' out of range.
    Warning, line 39: Constraint index '13' out of range.
    Warning, line 40: Constraint index '14' out of range.
    Warning, line 41: Constraint index '15' out of range.
    Warning, line 42: Constraint index '16' out of range.
    Warning, line 43: Constraint index '17' out of range.
    Warning, line 44: Constraint index '18' out of range.
    Warning, line 45: Constraint index '19' out of range.
    395 warnings not printed.
    Default row names c1, c2 ... being created.
    EpMrk = 0.01
    Solution status = Optimal
    Solution value  = 5766.54
    Maximum bound violation = 0

    Using the second one I obtain:

    Concert exception caught: CPLEX Error  3003: Not a mixed-integer problem. *

    * I have read that this kind of problem appears because the solution seems to be not feasible. I have tried this using the interactive cplex and it can be solved but the optimal value is 5766.54 (the same as if I use the SOL file using the Concert API). Also, I have seen that this message: "Warning:  No solution found from 1 MIP starts."  appears in the interactive application. I have disabled some features of cplex in order to avoid to fix the initial solution and see why the MIP start is ignored, but I had no success until now.

    Any idea will be appreciated =).

    Kind regards.

    Diana

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: Differences in CPLEX/ILOG Concert Tech performance

    Posted Wed March 04, 2015 11:33 AM

    Sorry, I lost track of what exactly you are doing and what the issues are. Could you please tell again what exactly your code is doing and what the unexpected results are?

    A few general remarks:

    1. That you get "not a mixed-integer problem" is suspicious. It seems like one of the models you are loading is not a MIP?
    2. If you have a model and a MIP start for it for which CPLEX does not find a solution and you suspect that the MIP start is infeasible, then you can use the conflict refiner to analyze this. In C++ use IloCplex::refineMIPStartConflict and in the interactive do this:
      CPLEX> read model.sav
      CPLEX> read start.mst
      CPLEX> conflict 1
    3. When using MIP starts in conjunction with lazy constraints: can you upgrade to CPLEX 12.6.1? In the past there were some very subtle bugs with lazy constraints and MIP starts (off the top of my head I don't remember which versions were affected).

    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: Differences in CPLEX/ILOG Concert Tech performance

    Posted Wed March 04, 2015 12:35 PM

    Originally posted by: DianaHuerta


    Thanks for your immediate response, 
     
    I have two ways to solve a problem. One of them  is create the model and solve it (applying lazy&callback cuts during B&C), then save the whole model in a SAV file. The other one is to import that SAV file and solve it. In both cases I set the same parameters. The problem is that for some instances I have detected that the optimal solution is different (either if I give the optimal solution as input). In the first way I obtained  Solution value  = 5626 (optimal), but in the second the optimal value is Solution value  = 5766.54.
     
    My question is, how can I see why the optimal solution is not the same?. I guess they should be equal. 
     
    I have tried some things in order to identify what is happening, but I have not had success until know. 
     
    Now, talking about the general remarks: 
     
    - My model is a MIP one.
     
    - Trying the process you recommended to me, using interactive cplex, I obtained: 
     
    CPLEX> read D:\TESIS\CPP_CPLEX\FPVRP_ENE\bin\abs1n5_2a.sav
     
    Problem 'D:\TESIS\CPP_CPLEX\FPVRP_ENE\bin\abs1n5_2a.sav' read.
    Read time = 0.00 sec. (0.01 ticks)
    CPLEX> read D:\TESIS\CPP_CPLEX\FPVRP_ENE\bin\FinalSolution.mst
    MIP start file 'D:\TESIS\CPP_CPLEX\FPVRP_ENE\bin\FinalSolution.mst' r
    CPLEX> conflict 1
     
    Refine conflict on 393 members...
     
     Iteration  Max Members  Min Members
             1          295            0
             2          246            0
             3          222            0
             4          216            0
             5          213            0
             6          212            0
             7          212            1
             8            1            1
     
    Minimal conflict:    1 linear constraint(s)
                         0 lower bound(s)
                         0 upper bound(s)
    Conflict computation time =    0.08 sec.  Iterations = 8
    Deterministic time = 4.48 ticks  (57.42 ticks/sec)

     

    But I do not know exactly what it means, I'm working on that.
     
    -  I'm using CPLEX 12.5.0.0, I will see what happen if I upgrade the version to a newer one.

    Thanks.

     

    Diana

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 10.  Re: Differences in CPLEX/ILOG Concert Tech performance

    Posted Wed March 04, 2015 01:36 PM

    Originally posted by: DianaHuerta


    I have understood what means the information of the conflict refiner, I observed (using <<display conflict all>>) that I had an unbounded variable. I changed it, solved it again, and compared both solutions. Now the optimal values between way 1 and 2 are the same :).

    Your recommendations were really useful!!

     

    Thanks a lot.

     

    Best Regards,

     

    Diana 


    #CPLEXOptimizers
    #DecisionOptimization