Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

logging the first feasible solution via callback

  • 1.  logging the first feasible solution via callback

    Posted Mon January 07, 2019 09:16 AM

    Originally posted by: Lessi


     

    I use ILOINCUMBENTCALLBACK to log information about feasible solutions. As far as I understand, when the incumbent callback is called, a new feasible solution is discovered.

     

    hasIncumbent

    public IloBool hasIncumbent() const

    Returns IloTrue if an integer feasible solution has been found, or, equivalenty, if an incumbent solution is available at the time the invoking callback is called by an instance of IloCplex while solving a MIP.

    However, it seems that  hasIncumbent()returns true when the second feasible solution is found, not the first one. I am not sure why?

    int newIncumbent = this->hasIncumbent(); //if this line is commented and I assign newIncumbent = 1; it will log all solutions; otherwise, it does not log the first solution.

    //newIncumbent = true cplex has found more than 1 feasible solution, otherwise, newIncumbent takes value "false"

    ILOINCUMBENTCALLBACK3(loggingCallbackFull,
    TTDP_DATA, ttdp,
    IloNum, startTime,
    IloNum, startDetTime)
    {

    try {

    //cout << "we are in the incumbent callback!!!" << endl;
    int newIncumbent = this->hasIncumbent(); //if this line is commented and I assign newIncumbent = 1; it will log all solutions; otherwise, it does not log the first solution.
    //newIncumbent = true cplex has found more than 1 feasible solution, otherwise, newIncumbent takes value "false"
    if (newIncumbent)
    {
    ... do something here
    catch (IloException& ex) {
    cerr << "Error: " << ex << endl;
    }

          0     0      244.0000    41                    244.0000       81         
          0     0      244.0000    19                  Cliques: 2       88         
          0     0      244.0000    30                    Cuts: 51      120         
          0     0      244.0000    26                     Cuts: 3      125         
          0     0      244.0000    28                    Cuts: 82      146         
          0     2      244.0000    15                    244.0000      146                                 0             0
    Elapsed time = 0.08 sec. (40.07 ticks, tree = 0.00 MB, solutions = 0)
    *   340   115      integral     0      234.0000      244.0000     4274    4.27% => no logging for the first feasible solution with objective 244
    Time = 0.222538  Dettime = 165.408  Current objective = 244
    candidate selected POI
    0 2 7 9 11 12 22 24 30 31 32 34 35 36 38 41 44 45 47 49 
    (0,0),(9,72),(12,124),(47,141),(24,154),(30,185),(38,218),(2,274),(41,316),(36,345),(32,381),(11,418),(45,428),(44,477),(31,500),(7,528),(34,551),(35,572),(22,607),(49,1000),
    *   344     1      integral     0      244.0000      244.0000     4290    0.00% => logging here


    Thanks for your comment and explanation.

     

    /Lessi

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: logging the first feasible solution via callback

    Posted Mon January 07, 2019 10:09 AM

    This is expected and in line with the documentation.

    When the incumbent callback is invoked for the first solution then the solution has not been accepted yet: the incumbent could still reject it. So there is no incumbent yet in this case.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: logging the first feasible solution via callback

    Posted Tue January 08, 2019 06:19 AM

    Originally posted by: Lessi


     

    So hasIncumbent() returns true if there is a solution stored in the solution pool, not the current "candidate" solution. We can reject a solution in the incumbent callback with reject() method.
     


    #CPLEXOptimizers
    #DecisionOptimization