Metaheuristic approach in a VRP

146 views
Skip to first unread message

Bruno Moreira

unread,
Apr 4, 2025, 4:48:09 AM4/4/25
to or-tools-discuss

I'm currently using OR-Tools to solve a Vehicle Routing Problem with a metaheuristic approach (TABU_SEARCH). Here’s a snippet of my code:

4214.png
  1. By default, it seems the solver keeps running until it hits the maximum time limit (total_time). Is there a way to configure an additional stopping criterion (like a certain number of iterations or a gap tolerance) so that it doesn’t necessarily run for the entire duration?

  2. Another issue I’m facing is that the solution I get is always the same. I was under the impression that using a metaheuristic (TABU_SEARCH) would produce different solutions because it’s supposed to be somewhat stochastic. Am I missing some parameter or configuration that would introduce randomness into the search process?

Any tips?

Thank you in advance.

Laurent Perron

unread,
Apr 4, 2025, 5:18:09 AM4/4/25
to or-tools-discuss
No, the solver is supposed to be deterministic.

Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00


--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/or-tools-discuss/20bed9e6-b0aa-4228-847d-6b6f0fb685e2n%40googlegroups.com.

Bruno Moreira

unread,
Apr 4, 2025, 1:58:13 PM4/4/25
to or-tools-discuss
So none of this methods have any random component?
I can't change the seed or something?

234.png

Vincent Furnon

unread,
Apr 7, 2025, 10:53:28 AM4/7/25
to or-tools...@googlegroups.com
About randomness, randomly re-ordering nodes in the model can help.
About stopping criteria, you can specify a max number of solutions generated (solution_limit in RoutingSearchParameters). You can also define a custom stopping criterion using RoutingModel::AddAtSolutionCallback, passing a callback which will call RoutingModel::CancelSearch when you want to interrupt the search. 

Message has been deleted

Bruno Moreira

unread,
Apr 11, 2025, 10:12:27 AM4/11/25
to or-tools-discuss
I am only using Tabu_Search for 300 seconds. Is there anyway i can print all the solutions found each second? Basically, i want to do a graph to see how it works until it finds the best solution.
Reply all
Reply to author
Forward
0 new messages