从 or-tools 获得更多输出

getting some more output from or-tools

好吧,我正在使用 or-tools 示例 "Vehicle Routing Problem with Time Windows" [1]

我根据自己的需要修改了它,我对这个解决方案很满意。

但是,如何从求解器中获取一些元数据?

在示例中,只有一个从求解器返回的赋值。我没有找到上面列出的任何信息。

问候。 另一个

[1] https://developers.google.com/optimization/routing/vrptw

编辑:

部分解决方案是查看 search_parameters。在这个变量中有很多信息。

在底层求解器上,您可以访问其中的大部分。

参见 C++ documentation of the routing library

中的示例

请注意,您无法以编程方式查询所用 moves/algorithms 的类型。

在python中可以先开启日志搜索再解决:

...
search_parameters = pywrapcp.DefaultRoutingSearchParameters()
search_parameters.log_search = True
...
# Solve the problem.
solution = routing.SolveWithParameters(search_parameters)

输出示例:

$ python vrp.py
WARNING: Logging before InitGoogleLogging() is written to STDERR
I0512 13:41:39.431615 16227 search.cc:254] Start search (memory used = 23.05 MB)
I0512 13:41:39.431676 16227 search.cc:254] Root node processed (time = 0 ms, constraints = 88, memory used = 23.09 MB)
I0512 13:41:39.433583 16227 search.cc:254] Solution #0 (18, time = 1 ms, branches = 66, failures = 9, depth = 33, memory used = 23.09 MB)
I0512 13:41:39.437201 16227 search.cc:254] Finished search tree (time = 5 ms, branches = 101, failures = 51, neighbors = 1154, filtered neighbors = 6, accepted neigbors = 0, memory used = 23.09 MB)
I0512 13:41:39.437227 16227 search.cc:254] End search (time = 5 ms, branches = 101, failures = 51, memory used = 23.09 MB, speed = 20200 branches/s)