Google ORTools(使用SCIP解算器)如何使用WallTime()获取唯一的时间戳?

2024-10-04 11:30:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我用SCIP作为解算器实现了一个MIP模型。我的目标之一是绘制中间解决方案随时间的演变

使用NextSolution()上的循环检索中间解决方案(如Google OR-Tools (using SCIP solver) - How to access the intermediate solutions found by the solver?中所述)。由于我还需要监视时间(即每个中间解决方案的时间戳),因此我将WallTime()添加到循环中:

solutions = [] # list to store intermediate solutions
localtimes = [] #list to store intermediate localtimes

while solver.NextSolution():
  solutions.append(solver.WallTime()) #in miliseconds
  localtimes.append(C.solution_value())

问题是我没有足够的时间精度来区分时间戳。我得到的结果是:

[5329, 5329, 5329, 5329, 5329, 5329, 5329, 5329, 5329, 5329, 5329, 5329, 5329, 5330, 5330, ...] --> intermediate localtimes list
[263.0, 264.0, 268.0, 269.0, 275.0, 279.0, 280.0, 296.0, 297.0, 304.0, 306.0, 307.0, 308.0, 309.0, 311.0,  ...] --> intermediate solutions list

因此,不同的解决方案具有相同的时间戳。是否有一种方法可以实现更高的时间精度以获得唯一的时间戳

多谢各位


Tags: thetostore时间精度解决方案listsolver