Using GRBterminate after a number of same incumbent solution
Hi all,
I wrote a callback function which is executed at GRB_CB_MIP. The aims of this callback are:
1- if for the last 50 iterations, the best incumbent solution is not changed, then terminate solving the problem and get the best incumbent solution found so far.
2- depending on the reduced cost value, terminate solving the problem at 30%, 20%, or 10% mipgap, and get the best incumbent solution found so far.
In the solution process, the mipgap works but the 50 same iterations termination criterion doesnt work.
What might be the reason for this?
Ebru
0
-
Official comment
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?. -
This is my callback function. In this part of the program, I set the best mip objective obtained so far toto 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.Ebruint __stdcallmycallback(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.
Comments
2 comments