pastas.timer.SolveTimer#
- class pastas.timer.SolveTimer(max_time: float | None = None, *args, **kwargs)#
Progress indicator for model optimization.
Examples
Print timer and number of iterations in console while running ml.solve():
with SolveTimer() as t: ml.solve(callback=t.timer)
This prints the following to the console, for example:
Optimization progress: 73it [00:01, 67.68it/s]
Set maximum allowable time (in seconds) for solve, otherwise raise ExceededMaxSolveTime exception:
with SolveTimer(max_time=60) as t: ml.solve(callback=t.timer)
Notes
If the logger is also printing messages to the console the timer will not be updated quite as nicely.
Methods#
|
Callback method for ps.Model.solve(). |