SolveTimer#

class SolveTimer(*_, **__)[source]#

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.

Parameters

max_time (Optional[float]) –

Attributes#

format_dict

Public API for read-only member access.

monitor

monitor_interval

Methods#

__init__

Initialize SolveTimer.

as_completed

Wrapper for asyncio.as_completed.

clear

Clear current bar display.

close

Cleanup and (if leave=False) close the progressbar.

display

Use self.sp to display msg in the specified pos.

external_write_mode

Disable tqdm within context and refresh tqdm when exits.

format_interval

Formats a number of seconds as a clock time, [H:]MM:SS

format_meter

Return a string-based progress bar given some parameters

format_num

Intelligent scientific notation (.3g).

format_sizeof

Formats a number (greater than unity) with SI Order of Magnitude prefixes.

gather

Wrapper for asyncio.gather.

get_lock

Get the global lock.

moveto

pandas

Registers the current tqdm class with

refresh

Force refresh the display of this bar.

reset

Resets to 0 iterations for repeated use.

send

set_description

Set/modify description of the progress bar.

set_description_str

Set/modify description without ': ' appended.

set_lock

Set the global lock.

set_postfix

Set/modify postfix (additional stats) with automatic formatting based on datatype.

set_postfix_str

Postfix without dictionary expansion, similar to prefix handling.

status_printer

Manage the printing and in-place updating of a line of characters.

timer

Callback method for ps.Model.solve().

unpause

Restart tqdm timer from last print time.

update

Manually update the progress bar, useful for streams such as reading files.

wrapattr

stream : file-like object. method : str, "read" or "write". The result of read() and the first argument of write() should have a len().

write

Print a message via tqdm (without overlap with bars).