Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Presolve, exportModel, importModel, and .lp files

    Posted Wed May 02, 2012 11:34 AM

    Originally posted by: Michael_D


    The following strange behaviour occurs when solving an MIP with Concert C++ with presolve turned on, using a branch callback:

    After extracting a model into a cplex object via
    
    IloCplex cplex(model);
    
    , and before calling
    
    cplex.solve()
    
    , the model is exported to a .lp file via
    
    cplex.exportModel(
    "aaa.lp");
    
    .

    In the
    
    main()
    
    function of the branch callback, when the callback is called for the first time, the model is again exported (to a different file, say, bbb.lp).

    The two files are very much different. Most importantly, in the bbb.lp file, several variables that are supposed to have zero coefficients in the objective function do appear there with nonzero coefficients. These variables rightly do not appear in the objective function of aaa.lp, and also not when the objective function is output to the console before calling
    
    solve()
    
    .

    Solving bbb.lp with the interactive optimizer nevertheless yields the correct optimal solution (at least for the cases tested).

    Presolve eliminates some variables. What could be a possible cause for cplex to modify the objective function in the described way? And why should, in general, the resulting modified model still be equivalent to the original one? Could it be that cplex changes the names of some variables (the variables are assigned names using
    
    IloNumVar::setName())
    
    ?

    When turning presolve off via
    
    CurCplex.setParam(IloCplex::PreInd, 0);
    
    , aaa.lp and bbb.lp are identical, and the objective looks as it should.
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Presolve, exportModel, importModel, and .lp files

    Posted Wed May 02, 2012 01:57 PM

    Originally posted by: T_O


    Just a guess:

    For LPs, this might be due to dual reductions: Changing the objective function is similar to changing the dual RHS.

    Maybe there are similar dual redutions for MIPs? Just try to disable dual reductions.

    Best regards,
    Thomas
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Presolve, exportModel, importModel, and .lp files

    Posted Thu May 03, 2012 02:27 AM

    Originally posted by: Michael_D


    Hi Thomas,

    thanks for the hint, but disabling dual reductions via
    cplex.setParam(IloCplex::Reduce, 0);
    
    had no effect.

    Best regards,

    Michael
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Presolve, exportModel, importModel, and .lp files

    Posted Thu May 03, 2012 05:25 AM

    Originally posted by: SystemAdmin


    Do I understand correctly that you call
    cplex.exportModel("model.lp");
    

    from a callback and 'cplex' is an instance of IloCplex that is currently running IloCplex::solve()? If so then this is unsupported and the resulting behavior is undefined.

    I wonder why you want to export the model from a callback. During IloCplex::solve() the IloModel instance does not change, so you would not see a different model, even if exporting from the callback would work. What are you trying to achieve by exporting the model from the callback?
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Presolve, exportModel, importModel, and .lp files

    Posted Thu May 03, 2012 12:32 PM

    Originally posted by: Michael_D


    >Do I understand correctly that you call cplex.exportModel("model.lp"); from a callback and 'cplex' is an instance of IloCplex that is currently running IloCplex::solve()?

    Yes, indeed.

    >If so then this is unsupported and the resulting behavior is undefined.

    Ah, ok.

    >I wonder why you want to export the model from a callback. During IloCplex::solve() the IloModel instance does not change, so you would not see a different model, even if >exporting from the callback would work.

    Well, I thought that, if cuts are added or variables are fixed through branching, these changes would be exported to the file.

    Thanks, this answers my question.
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Presolve, exportModel, importModel, and .lp files

    Posted Thu May 03, 2012 12:57 PM

    Originally posted by: SystemAdmin


    > >I wonder why you want to export the model from a callback. During IloCplex::solve() the IloModel instance does not change, so you would not see a different model, even if >exporting from the callback would work.
    >
    > Well, I thought that, if cuts are added or variables are fixed through branching, these changes would be exported to the file.
    >
    To be explicit: These changes are not tracked in the IloModel instance.
    You can keep track of variable fixings due to branching by using a branch callback (this has been discussed in several threads on this Forum). If you want to keep track of cuts that were added by CPLEX (and not by a cut callback) then you will most probably have to resort to the C API.
    #CPLEXOptimizers
    #DecisionOptimization