Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Order of callbacks

    Posted 01/05/19 09:30 AM

    Originally posted by: Lessi


     

    Hi Cplexers.

    I have the following question that needs your advice,


    I write several callbacks :

    a. A callback ILOINCUMBENTCALLBACK to check if the solution is feasible. 

    b. A callback ILOLAZYCONSTRAINTCALLBACK which should be called when the checking in a) failed.

    c. A callback ILOLAZYCONSTRAINTCALLBACK which should be called when the checking in a) passed.

     

    I have boolean variables named feasibleCut and infeasibleCut; which are set to be true when the checking passed/failed in a)

    and then (I hope) the cut callbacks will check the corresponding boolean values to add new cuts. It is a correct approach?  I am not sure whether when a feasible solution is available, b) and c) are called before or after a).

    Thanks in advance,

     

    /Lessi


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Order of callbacks

    Posted 01/05/19 08:52 PM

    Originally posted by: EdKlotz


    I think the order of your callbacks works fine.   Conceptually, it makes sense for the incumbent callback to be called before either the lazy constraint callback or the branch callback.   If the incumbent callback rejects a an integer feasible solution that was found by branching, you need to instruct CPLEX how to branch since there are no integrality violations at the node.  You don't need the branch callback if the rejected solution came from a heuristic, as the associated node will have some integrality violations.   You can instead use a lazy constraint to reject an incumbent, in which case CPLEX will reoptimize the node relaxation with the additional lazy constraint, and the whole node evaluation process will repeat.

     

    You can find more information on the order of callbacks in this technote:  https://www-01.ibm.com/support/docview.wss?uid=swg21400064.

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Order of callbacks

    Posted 01/06/19 12:35 PM

    Originally posted by: Lessi


     

    Your comments are helpful. Many thanks.


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Order of callbacks - an implementation question

    Posted 01/10/19 12:47 PM

    Originally posted by: Lessi


     

    I have three callbacks:

     

    cplexMaster.use(feasibilityCheck(env));
    cplexMaster.use(lazyconstraintCallback(env));
    cplexMaster.use(removeViolatedCandidate(env, violatedCandidate));

     

    In the feasiblityCheck callback, I have the following piece of code wherein I want to call two other callbacks
     
    if (cplexSlave.isPrimalFeasible())
    {
    cout << "Has a feasible solution with value = " << this->getObjValue() << endl;
    slnCount++;
    slnBest = max(slnBest, this->getObjValue());
    feasibleCut = true; => I want to call the lazy cut here
    infeasibleCut = false;
    //exit(0);
    }
    else
    {
    cout << "It is not a good candidate" << endl;
     
    infeasibleCut = true; => I want to call the lazy cut callback here
    feasibleCut = false;
     
    violatedCandidate.clear();
     
    for (int i = 1;i + 1 < ttdp.N;i++)
    if (y_val[i] == 1)
    violatedCandidate.push_back(i);
    }

    ------------------------------------------------

    This is the log I have, the lazycut have not been called yet.

     

    Total (root+branch&cut) =    0.00 sec. (4.41 ticks)
    Has a feasible solution with value = 270 => here I have a feasible solution with objective value = 270, so I do not want to enumerate solutions with objective value < 270.

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

    *     0     0      integral     0      270.0000      270.0000        1    0.00%

    Root node processing (before b&c):
      Real time             =    0.01 sec. (4.79 ticks)
    Sequential b&c:
      Real time             =    0.00 sec. (0.00 ticks)
                              ------------
    Total (root+branch&cut) =    0.01 sec. (4.79 ticks)

    Populate: phase II 
    Lazy constraint(s) or lazy constraint callback is present.
        Disabling dual reductions (CPX_PARAM_REDUCE) in presolve.
        Disabling non-linear reductions (CPX_PARAM_PRELINEAR) in presolve.
    MIP emphasis: balance optimality and feasibility.
    MIP search method: traditional branch-and-cut.
    Parallel mode: none, using 1 thread.
    We have a solution with value 270
    Reject an incumbent

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

          0     2      270.0000     1      270.0000      270.0000        1    0.00%                        0             0
    Elapsed time = 0.01 sec. (4.95 ticks, tree = 0.01 MB, solutions = 1)


    We have a solution with value 60 => it means that the lazycutcallback has not been called yet. 
    Reject an incumbent
    We have a solution with value 230
    Reject an incumbent
    We have a solution with value 40
    Reject an incumbent
    We have a solution with value 20
    Reject an incumbent
    We have a solution with value 0
    Reject an incumbent

     

    -----------------------------------

     

    Thank for your help.

     

    /Lessi

     

     


    #CPLEXOptimizers
    #DecisionOptimization