1

I implemented a MIP model with SCIP as a solver. One of my goals is to plot the evolution of the intermediate solutions through time.

Using a loop on NextSolution(), I retrieve the intermediate solutions (as explained in Google OR-Tools (using SCIP solver) - How to access the intermediate solutions found by the solver?). Since I also need to monitor time (i.e. the timestamp of each intermediate solution), I added WallTime() to the loop:

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

The problem is that I don't get enough time precision to differentiate the timestamps. The output that I get is:

[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

So, different solutions have the same timestamp. Is there a way to achieve more time precision in order to get unique timestamps?

Thank you.

lbrandao
  • 95
  • 10
  • WallTime is the time for the solver, it is not linked with the time of the solutions. I do not know if this is accessible. – Laurent Perron Jan 12 '21 at 10:53
  • I have a CP model (with a CP-SAT solver) that uses solveWithSolutionCallback to get the intermediate solutions and their timestamp. The method uses WallTime() to get the timestamps and it gets unique timestamps because it outputs them with higher precision (i.e. several decimal places; e.g. 3432.892657 miliseconds). So, I'm puzzled why the same doesn't happen with the WallTime() in the MIP model (where it outputs all the timestamps with zero decimal places). – lbrandao Jan 12 '21 at 11:23
  • 1
    Because WallTime() returns the time since solve was started, at the moment WallTime() is called, not according to the solution being replayed. – Laurent Perron Jan 12 '21 at 13:48
  • Ok, I finally understood.The timestamp I get during the loop tracks only the moment the intermediate solution is replayed (and has nothing to do with the moment the solution was actually found). Thank you @Laurent Perron for the nice explanation. – lbrandao Jan 12 '21 at 14:07

0 Answers0