Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  CPLEX does not enter (Branch-/Usercut-/Heuristic-)Callback

    Posted 10/23/13 05:36 AM

    Originally posted by: Evaba


    Hi,

    I did already post another question (Speed Up Branch&Bound with selfmade Heuristic) and while waiting for an answer (due to time difference) I was practicing the implementation of a UsercutCallback, a  BranchCallback and HeuristicCallback (using the Java CPLEX API) with empty body for my MIP. Unfortunately I discovered that none of these calls are being entered.

    The corresponding code looks like this: 

    MyCutCallback cut_callback = new MyCutCallback();
    MyBranchCallback branch_callback = new MyBranchCallback();
    MyHeuristicCallback heuristic_callback = new MyHeuristicCallback();
                    
    cplex.use(cut_callback);
    cplex.use(branch_callback);
    cplex.use(heuristic_callback);

     

    ...

     

    static class MyCutCallback extends IloCplex.UserCutCallback {

       MyCutCallback() {}
                   
       public void main() {
          System.out.println("----> User Cut Callback");
       }

    }
            
    static class MyBranchCallback extends IloCplex.BranchCallback {


       MyBranchCallback() {}
                            
       public void main() {
          System.out.println("----> Branch Callback");
       }

    }

     

    static class MyHeuristicCallback extends IloCplex.HeuristicCallback {

       MyHeuristicCallback() {}
                            
       public void main() {
          System.out.println("----> Heuristic Callback");
       }
                
    }

    I'm sure I just made a stupid mistake. What went wrong?

    Thanks again.


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: CPLEX does not enter (Branch-/Usercut-/Heuristic-)Callback

    Posted 10/23/13 07:43 AM

    I don't see an obvious mistake in your code. I take it you registered the callbacks before you called solve()?

    Could you show us the CPLEX log output for the call to solve() that has the callbacks added?

    Could it be that your problem is very simple and is solved so quickly that CPLEX never gets to the point at which it would invoke the callbacks?


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: CPLEX does not enter (Branch-/Usercut-/Heuristic-)Callback

    Posted 10/24/13 07:17 AM

    Originally posted by: Evaba


    Thank you for your answer so far.

    I did put the solve() command after the use(...) commands.

    My program includes several hundred binary variables but maybe still the solution is easy to find for CPLEX?!

    I now set the following parameters:

     

    // set CPLEX parameters
    cplex.setParam(IntParam.PreslvNd, -1);
    cplex.setParam(IntParam.MIPInterval, 1);
    cplex.setParam(IntParam.MIPDisplay, 2);

     

    And additionally implemented a SolveCallback just the way I did with the other callbacks.

    The CPLEX log output looks like this:

     

    Tried aggregator 2 times.
    MIP Presolve eliminated 244600 rows and 301328 columns.
    Aggregator did 22894 substitutions.
    Reduced MIP has 188645 rows, 405319 columns, and 1215159 nonzeros.
    Reduced MIP has 9391 binaries, 0 generals, 0 SOSs, and 0 indicators.
    Presolve time = 4.96 sec. (1183.56 ticks)
    Probing changed sense of 1419 constraints.
    Probing time = 0.45 sec. (170.06 ticks)
    Tried aggregator 2 times.
    MIP Presolve eliminated 5547 rows and 192 columns.
    MIP Presolve modified 39309 coefficients.
    Aggregator did 1119 substitutions.
    Reduced MIP has 181979 rows, 404008 columns, and 1156319 nonzeros.
    Reduced MIP has 9240 binaries, 0 generals, 0 SOSs, and 0 indicators.
    Presolve time = 4.65 sec. (1167.60 ticks)
    Warning: Control callbacks may disable some MIP features.
    Probing changed sense of 139 constraints.
    Probing time = 0.34 sec. (43.12 ticks)
    Clique table members: 1681.
    MIP emphasis: balance optimality and feasibility.
    MIP search method: traditional branch-and-cut.
    Parallel mode: none, using 1 thread.
    ----> solve callback
    Root relaxation solution time = 41.87 sec. (11732.90 ticks)
    ----> solve callback

            Nodes                                         Cuts/
       Node  Left     Objective  IInf  Best Integer    Best Bound    ItCnt     Gap         Variable B NodeID Parent  Depth

    *     0     0      integral     0  3105764.4046  3105764.4046    88804    0.00%                        0             0
    Elapsed time = 54.91 sec. (14781.36 ticks, tree = 0.00 MB, solutions = 1)

    Root node processing (before b&c):
      Real time             =   43.63 sec. (12025.53 ticks)
    Sequential b&c:
      Real time             =    0.00 sec. (0.00 ticks)
                              ------------
    Total (root+branch&cut) =   43.63 sec. (12025.53 ticks)
    RS: 0, Value: 3105764.4046185184, Solution Optimal

     

    So we can see, CPLEX enters the SolveCallback twice but never enters any of the other callbacks. How can that be?


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: CPLEX does not enter (Branch-/Usercut-/Heuristic-)Callback

    Posted 10/24/13 02:52 PM

    Your problem is so simple that CPLEX solves it before it ever comes to the point at which it would invoke any of the other callbacks.

    As you can see in the log file, a CPLEX heuristic finds the optimal solution right at the beginning of the root node. You could try a more difficult problem or try to disable heuristics (set IloCplex.IntParam.HeurFreq to -1).


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: CPLEX does not enter (Branch-/Usercut-/Heuristic-)Callback

    Posted 10/25/13 03:35 AM

    Originally posted by: Evaba


    Ok, will do. Thank you for your advice!


    #CPLEXOptimizers
    #DecisionOptimization