我使用下面的代码在routingModel上设置时间限制。
RoutingSearchParameters search_parameters = RoutingModel.DefaultSearchParameters();
search_parameters.FirstSolutionStrategy = FirstSolutionStrategy.Types.Value.PATH_CHEAPEST_ARC;
search_parameters.TimeLimitMs = 30000;
RoutingModel routing = new RoutingModel(number_of_locations, number_of_vehicles);
但是我不知道如何在搜索完成后获取状态,因此我可以检查是否有时间限制取消它或由于其他原因未找到解决方案。请帮忙
Assignment solution = routing.SolveWithParameters(search_parameters);
RoutingModel类具有此静态属性,但我不知道如何从实例中读取它们:
public static readonly int ROUTING_FAIL;
public static readonly int ROUTING_FAIL_TIMEOUT;
public static readonly int ROUTING_INVALID;
public static readonly int ROUTING_NOT_SOLVED;
public static readonly int ROUTING_SUCCESS;
答案 0 :(得分:0)
..是时间限制取消它或找到解决方案..
这在python 3中适用于我:
....
solution = routing.SolveWithParameters(search_parameters)
if solution:
print("Solution Found")
....
else:
print("Terminated without finding solution")
从问题中不清楚您是否正在寻找上述解决方案,或者您是否有兴趣检查找到的解决方案是否最佳。