Emily Frost
unread,Jan 14, 2013, 8:42:59 AM1/14/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pulp-or...@googlegroups.com
Hi all,
I am using PuLP to model a MIP problem with Gurobi as the solver. I've used a custom callback function in Gurobi before (copied below) to log interim solutions and the time at which they were found. (the version below also terminates the optimization once the rate of improvement slows.) Is there a way to tell Gurobi to optimize according to this callback function in PuLP?
Thanks,
Emily
def mycallback(mod, where):
global oldsol
if where == GRB.callback.MIPSOL:
print mod.cbGet(GRB.callback.MIPSOL_SOLCNT), ",", mod.cbGet(GRB.callback.RUNTIME), ",", mod.cbGet(GRB.callback.MIPSOL_OBJ)
if mod.cbGet(GRB.callback.MIPSOL_SOLCNT) == 1:
oldsol = mod.cbGet(GRB.callback.MIPSOL_OBJ)
elif (mod.cbGet(GRB.callback.MIPSOL_OBJ) - oldsol) > 15:
oldsol = mod.cbGet(GRB.callback.MIPSOL_OBJ)
else:
mod.terminate()