Decision Optimization

Decision Optimization

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

 View Only
  • 1.  IncumbentCallback does not filter the incumbent found in the root node

    Posted Fri May 08, 2015 11:43 AM

    Originally posted by: Hosssein


    Hi,

    I am testing IncumbentCallbackI on a very very simple MIP model in C++ that is solved in the root node by MIP presolve. It looks that the IncumbentCallbackI is not called when an incumbent is found. You can find my code in the following. Could you please help me? I expected to see that "hello" is printed in the output (see SolutionFilterCallbackI::main()), but it never happens. (Please check the P.S. after the code) 

     

    #include<ilcplex/ilocplex.h>

    #include<iostream>

    #include<queue>

    #include<vector>

    usingnamespace std;

    #include<ctime>

    #include<cmath>

     

    classSolutionFilterCallbackI : public IloCplex::IncumbentCallbackI  {

           IloNumVarArray xVar;

    public:

           IloCplex::CallbackI* duplicateCallback() const {

                  return (new (getEnv()) SolutionFilterCallbackI(*this));

           }

           SolutionFilterCallbackI    (IloEnv env, IloNumVarArray x) :

                  IloCplex::IncumbentCallbackI(env), xVar(x) {

           }

           void main();

    };

    IloCplex::Callback

    SolutionFilterCallback(IloEnv env, IloNumVarArray xVar){

           return (IloCplex::Callback(new(env) SolutionFilterCallbackI(env, xVar)));

    }

     

    voidSolutionFilterCallbackI::main() {

           cout << "hello" << endl;

           if (getValue(xVar[0])==5){

                  reject();

           }

    }

     

     

    intmain(int argc, char **argv)

    {

           IloEnv env;

           IloNumVarArray X(env,10);

           for(int i=0; i< 10; i++) {

                  X[i] = IloNumVar(env, 0, 5, ILOINT);

           }

           IloModel model (env);

           IloExpr MyObjectiveFunction(env);

           for(int i=0; i< 10; i++) {

                  MyObjectiveFunction += X[i];

           }

           model.add(IloMaximize(env, MyObjectiveFunction));

           IloCplex Mycplex(model);

           Mycplex.use(SolutionFilterCallback(env, X));

           Mycplex.solve();

           cout << "Finished" << endl;

    system("Pause");

    return0;

    }

     

    P.S

    I just tested the IncumbentCallbackI on a more complicated MIP model (that is not presented here) in which to get the optimal solution some branchings are required. I can see that "hello" is printed whenever a new incumbent is found, except when the first incumbent is found in the root node. It looks the reason that SolutionFilterCallbackI::main()  was not called in the above code is that the optimal solution is found by MIP presolve in the root node. Is it right? Is there any way for filtering incumbents found in the root node?


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: IncumbentCallback does not filter the incumbent found in the root node

    Posted Mon May 18, 2015 01:09 AM

    It is a known problem that the incumbent callback is not invoked if CPLEX solve the problem to optimality already in presolve. However, in this case there are only two options: 1. the incumbent is feasible and thus optimal. 2. the incumbent is infeasible in which the whole model is infeasible.

    So you can just explicitly check for feasibility if the problem solves in presolve.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: IncumbentCallback does not filter the incumbent found in the root node

    Posted Mon May 18, 2015 01:57 AM

    Originally posted by: Hosssein


    Thanks for your reply. Fortunately I found another way to formulate my problem without using Incumbent callback, but I still believe that CPLEX should check the incumbent callback even if the problem is solved in the root node by presolve. Sometimes the incumbents that are found by presolve are infeasible with respect to some non-linear constraints that cannot be stated in the model. In such cases CPLEX does not provide any insight and does not find any feasible solution satsifying the non-linear constraints.

    Thanks again for your answer.

    Hossein


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: IncumbentCallback does not filter the incumbent found in the root node

    Posted Mon May 18, 2015 03:23 AM

    I completely agree that the incumbent callback should be invoked. We are working on improving that but I cannot tell yet which release will contain the fix.


    #CPLEXOptimizers
    #DecisionOptimization