Skip to main content

Using GRBterminate after a number of same incumbent solution

Comments

2 comments

  • Official comment
    Simranjit Kaur
    Gurobi Staff Gurobi Staff
    This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?.
  • Ebru Angun
    Gurobi-versary
    Conversationalist
    Curious
    This is my callback function. In this part of the program, I set the best mip objective obtained so far to  
    to mydata-best_obj_bnd, and passed this to the main program, where it counted whether for the last fifty iterations, the best mip objective is changed or not. If it is not changed, it should terminate solving the pricing_model. But I observed that this is not the case. The mip gap below works, but the last fifty iterations do not work.
     
    What is the reason for it? Thanks in advance.
     
    Ebru 
     
     
    int __stdcall
    mycallback(GRBmodel *pricing_model,
    void     *cbdata,
    int       where,
    void     *usrdata)
    {
    struct callback_data *mydata = (struct callback_data *) usrdata;
    int    call_fifty_objectives = mydata->fifty_objectives;
    double master_last = mydata->master_dual_last;
    double subprob_bnd;
     
    if (where == GRB_CB_MIP) {
     
    if (call_fifty_objectives > 50)
    GRBterminate(pricing_model);
     
    GRBcbget(cbdata, where, GRB_CB_MIP_OBJBST, &mydata->best_obj_bnd);
    GRBcbget(cbdata, where, GRB_CB_MIP_OBJBND, &subprob_bnd);
     
    if (mydata->best_obj_bnd - master_last <= -300000) {
    if (fabs(mydata->best_obj_bnd - subprob_bnd) < 0.3 * fabs(mydata->best_obj_bnd))
    GRBterminate(pricing_model);
    }
    else if ((mydata->best_obj_bnd - master_last <= -100000) && (mydata->best_obj_bnd - master_last > -300000)) {
    if (fabs(mydata->best_obj_bnd - subprob_bnd) < 0.2 * fabs(mydata->best_obj_bnd))
    GRBterminate(pricing_model);
    }
    else if ((mydata->best_obj_bnd - master_last <= -5000) && (mydata->best_obj_bnd - master_last > -100000)) {
    if (fabs(mydata->best_obj_bnd - subprob_bnd) < 0.1 * fabs(mydata->best_obj_bnd))
    GRBterminate(pricing_model);
    }
    else {
    if (fabs(mydata->best_obj_bnd - subprob_bnd) < 0.001 * fabs(mydata->best_obj_bnd))
    GRBterminate(pricing_model);
    }
    }
    return 0;
    }
    0

Post is closed for comments.