Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get progress log on Google OR-Tools?

I'm using Google's OR-Tools to solve VRPtw problem and struggling with thinking about log.
I'm giving certain amount of visiting points and vehicles to the solver. And I have no idea how much it takes time, meaning that even the scale of time.
Do we have any way of getting the progress information?
I know there is a SearchLog class(https://developers.google.com/optimization/reference/constraint_solver/constraint_solveri/SearchLog). But I don't understand this can give me the information I want.

like image 402
Shuhei Kishi Avatar asked Oct 11 '25 11:10

Shuhei Kishi


1 Answers

First, you must understand the solver work in two steps, first it will try to find a first solution, then it will try to improve it using local search if enable.

To get a log each time a solution found you can use the search parameter proto.

search_parameters.local_search_metaheuristic = (
   routing_enums_pb2.LocalSearchMetaheuristic.GUIDED_LOCAL_SEARCH)
search_parameters.log_search = True
solution = routing.SolveWithParameters(search_parameters)

ref: https://github.com/google/or-tools/blob/a0a56698ba8fd07b7f84aee4fc45d891a8cd9828/ortools/constraint_solver/routing_parameters.proto#L414-L423

Then if you want a very fine grained trace you can enable trace log using the routing parameter proto

routing_parameters = pywrapcp.DefaultRoutingModelParameters()
routing_parameters.solver_parameters.trace_propagation = True
routing_parameters.solver_parameters.trace_search = True
routing = pywrapcp.RoutingModel(manager, routing_parameters)

ref: https://github.com/google/or-tools/blob/a0a56698ba8fd07b7f84aee4fc45d891a8cd9828/ortools/constraint_solver/routing_parameters.proto#L431-L433 and
https://github.com/google/or-tools/blob/a0a56698ba8fd07b7f84aee4fc45d891a8cd9828/ortools/constraint_solver/solver_parameters.proto#L77-L81

Also don't forget VRP is NP-hard....

like image 74
Mizux Avatar answered Oct 14 '25 16:10

Mizux