How do we obtain intermediate results in Google OR-Tools TSP/VRP?

Viewed 28

In Gurobi, I can write a callback like this to get the elapsed time, the current objective value, and the current bound. It's useful because we would like to see how the objective value improves over time:

def data_cb(model, where):
  if where == gp.GRB.Callback.MIP:
    cur_obj = model.cbGet(gp.GRB.Callback.MIP_OBJBST)
    cur_bd = model.cbGet(gp.GRB.Callback.MIP_OBJBND)

    # Did objective value or best bound change?
    if model._obj != cur_obj or model._bd != cur_bd:
      model._obj = cur_obj
      model._bd = cur_bd
      model._data.append([time.time() - model._start, cur_obj, cur_bd])

I've been trying to do this in Google OR Tools Python, but find it difficult to do so. I currently have a hacky solution where I set search_parameters.log_search = True and then parse the logs to extract [time, objective_value]. No bound is available since Google OR Tools is a heuristic.

Is there a best practice to do this?

0 Answers
Related