微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

获取 RoutingSolver 或工具的中间解决方案

如何解决获取 RoutingSolver 或工具的中间解决方案

我对 python 中的 ortools 有点陌生,我有认的 CVRP 示例,我正在尝试获得中间解决方案,而不仅仅是最后一个。 我已经尝试在搜索参数中设置要收集的解决方数量,但似乎没有效果。使用参数调用 solve 时可以选择传递赋值向量,但是将空列表传递给它(因为 python)会引发错误类型。

#this is how the routing model is initialized
routing = pywrapcp.RoutingModel(manager)
.
.
.
# setting search parameters
search_parameters = pywrapcp.DefaultRoutingSearchParameters()
search_parameters.first_solution_strategy = (routing_enums_pb2.FirstSolutionStrategy.PATH_CHEApest_ARC)
search_parameters.local_search_Metaheuristic = 1 #myNaturalBeauty #greedyDescent
search_parameters.log_search = True
search_parameters.solution_limit = 3
search_parameters.number_of_solutions_to_collect = 3

#attempt to get solutions
solutions = []
solution = routing.solveWithParameters(search_parameters,solutions)

出现这个错误

return _pywrapcp.RoutingModel_SolveWithParameters(self,search_parameters,solutions)

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 &)

任何帮助将不胜感激。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。