CVRPTW : How to get the best K solutions found

112 views
Skip to first unread message

Nilton

unread,
Sep 22, 2021, 9:43:34 AM9/22/21
to or-tools-discuss
Hi,
We are working on a full CVRPTW problem, using ORTools and Python, and we would like to get the best K solutions found by the routing model. We thought maybe we could use the second arg on SolveWithParameters, but we're not sure how. 

We tried to build a list of Assignments, since the method expects a vector of Assignments, but we keep getting an error that says we're passing the wrong type.

It works fine when only the parameters are passed. So, we have a couple questions:
 1. Is this second argument of SolveWithParameters working properly for python? 
2. If so, how should we use it? 
3. If we use the SolutionCollector instead, will it return an ordered list of solutions or we'll need to evaluate each ObjectiveValue to get the best K?

Below I leave the code we're using to call SolveWithParameters: 

search_parameters = pywrapcp.DefaultRoutingSearchParameters()
search_parameters.local_search_metaheuristic = ( routing_enums_pb2.LocalSearchMetaheuristic.GUIDED_LOCAL_SEARCH)
search_parameters.first_solution_strategy = ( routing_enums_pb2.FirstSolutionStrategy.LOCAL_CHEAPEST_ARC)
search_parameters.number_of_solutions_to_collect = 3
def solve_problem(self, search_parameters): 
    self.solutions_holder = [self.routing_model.PreAssignment() for i in range(3)]
    solution = self.routing_model.SolveWithParameters(search_parameters, self.solutions_holder)
     return solution


And, then, the error:
 
TypeError: Wrong number or type of arguments for overloaded function 'RoutingModel_SolveWithParameters'.
Possible C/C++ prototypes are: operations_research::RoutingModel::SolveWithParameters(operations_research::RoutingSearchParameters const &,std::vector< operations_research::Assignment const * > *)
operations_research::RoutingModel::SolveWithParameters(operations_research::RoutingSearchParameters const &)

Nilton

unread,
Sep 29, 2021, 10:56:27 AM9/29/21
to or-tools-discuss
Any help with this problem? Is this behavior expected or might be a bug in the python wrapper?
Reply all
Reply to author
Forward
0 new messages