metaheuristic_designer.reporters package#

Submodules#

Module contents#

Built-in reporter implementations (silent, tqdm, verbose) and the factory.

class Reporter[source]#

Bases: ABC

Abstract interface for progress reporters.

A reporter is notified at three key moments of an optimization run: initialization, after each generation, and at completion. Implementations can display progress bars, log messages, update dashboards, etc.

Methods

log_end(algorithm)

Called once, after the optimization loop finishes.

log_init(algorithm)

Called once, before the main optimization loop starts.

log_step(algorithm)

Called after each generation.

abstract log_init(algorithm)[source]#

Called once, before the main optimization loop starts.

Parameters:
algorithmAlgorithm

The algorithm that is about to run.

Parameters:

algorithm (Algorithm)

abstract log_step(algorithm)[source]#

Called after each generation.

Parameters:
algorithmAlgorithm

The running algorithm, with up-to-date population, iteration count, and best solution.

Parameters:

algorithm (Algorithm)

abstract log_end(algorithm)[source]#

Called once, after the optimization loop finishes.

Parameters:
algorithmAlgorithm

The algorithm that has just finished.

Parameters:

algorithm (Algorithm)

create_reporter(reporter_name, **kwargs)[source]#

Instantiate a reporter by name.

Return type:

Reporter

Parameters:
reporter_namestr

One of "silent", "tqdm", or "verbose".

**kwargs

Forwarded to the reporter constructor.

Returns:
Reporter

A concrete reporter instance.

Raises:
ValueError

If reporter_name is not recognized.

Parameters:

reporter_name (str)

class SilentReporter[source]#

Bases: Reporter

Reporter that produces no output.

All logging methods are no-ops. Useful for running experiments without visual clutter.

Methods

log_end(algorithm)

Called once, after the optimization loop finishes.

log_init(algorithm)

Called once, before the main optimization loop starts.

log_step(algorithm)

Called after each generation.

log_init(algorithm)[source]#

Called once, before the main optimization loop starts.

Parameters:
algorithmAlgorithm

The algorithm that is about to run.

Parameters:

algorithm (Algorithm)

log_step(algorithm)[source]#

Called after each generation.

Parameters:
algorithmAlgorithm

The running algorithm, with up-to-date population, iteration count, and best solution.

Parameters:

algorithm (Algorithm)

log_end(algorithm)[source]#

Called once, after the optimization loop finishes.

Parameters:
algorithmAlgorithm

The algorithm that has just finished.

Parameters:

algorithm (Algorithm)

class TQDMReporter(resolution=1000, **kwargs)[source]#

Bases: Reporter

Reporter that displays a tqdm progress bar.

Parameters:
resolutionint, optional

Number of ticks in the progress bar (default 1000). Higher values give smoother updates.

Parameters:

resolution (int)

Methods

log_end(algorithm)

Fill the progress bar to 100% and close it.

log_init(algorithm)

Initialise the progress bar and display the first postfix.

log_step(algorithm)

Update the progress bar with current iteration, evaluations, and fitness.

log_init(algorithm)[source]#

Initialise the progress bar and display the first postfix.

Parameters:

algorithm (Algorithm)

log_step(algorithm)[source]#

Update the progress bar with current iteration, evaluations, and fitness.

Parameters:

algorithm (Algorithm)

log_end(algorithm)[source]#

Fill the progress bar to 100% and close it.

Parameters:

algorithm (Algorithm)

class VerboseReporter(verbose_timer=0.5, **kwargs)[source]#

Bases: Reporter

Reporter that prints a multi-line status block every verbose_timer seconds.

Parameters:
verbose_timerfloat, optional

Minimum interval (in seconds) between printed updates (default 0.5).

Methods

log_end(algorithm)

Print a final summary of the completed run.

log_init(algorithm)

Print a header indicating the start of the optimization.

log_step(algorithm)

Print a status block if enough time has elapsed.

log_init(algorithm)[source]#

Print a header indicating the start of the optimization.

Parameters:

algorithm (Algorithm)

log_step(algorithm)[source]#

Print a status block if enough time has elapsed.

Parameters:

algorithm (Algorithm)

log_end(algorithm)[source]#

Print a final summary of the completed run.

Parameters:

algorithm (Algorithm)