metaheuristic_designer.reporters package

Submodules

metaheuristic_designer.reporters.create_reporter module

Factory function for reporter objects.

create_reporter(reporter_name: str, **kwargs) Reporter[source]

Instantiate a reporter by name.

Parameters:
  • reporter_name (str) – One of "silent", "tqdm", or "verbose".

  • **kwargs – Forwarded to the reporter constructor.

Returns:

A concrete reporter instance.

Return type:

Reporter

Raises:

ValueError – If reporter_name is not recognized.

metaheuristic_designer.reporters.silent_reporter module

Silent reporter that produces no output during a run.

class SilentReporter[source]

Bases: Reporter

Reporter that produces no output.

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

log_init(algorithm: Algorithm)[source]

Called once, before the main optimization loop starts.

Parameters:

algorithm (Algorithm) – The algorithm that is about to run.

log_step(algorithm: Algorithm)[source]

Called after each generation.

Parameters:

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

log_end(algorithm: Algorithm)[source]

Called once, after the optimization loop finishes.

Parameters:

algorithm (Algorithm) – The algorithm that has just finished.

metaheuristic_designer.reporters.tqdm_reporter module

Reporter that shows a tqdm progress bar during optimization.

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

Bases: Reporter

Reporter that displays a tqdm progress bar.

Parameters:

resolution (int, optional) – Number of ticks in the progress bar (default 1000). Higher values give smoother updates.

log_init(algorithm: Algorithm)[source]

Initialise the progress bar and display the first postfix.

log_step(algorithm: Algorithm)[source]

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

log_end(algorithm: Algorithm)[source]

Fill the progress bar to 100% and close it.

metaheuristic_designer.reporters.verbose_reporter module

Reporter that prints a text summary at regular intervals.

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

Bases: Reporter

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

Parameters:

verbose_timer (float, optional) – Minimum interval (in seconds) between printed updates (default 0.5).

log_init(algorithm: Algorithm)[source]

Print a header indicating the start of the optimization.

log_step(algorithm: Algorithm)[source]

Print a status block if enough time has elapsed.

log_end(algorithm: Algorithm)[source]

Print a final summary of the completed run.

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.

abstract log_init(algorithm: Algorithm)[source]

Called once, before the main optimization loop starts.

Parameters:

algorithm (Algorithm) – The algorithm that is about to run.

abstract log_step(algorithm: Algorithm)[source]

Called after each generation.

Parameters:

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

abstract log_end(algorithm: Algorithm)[source]

Called once, after the optimization loop finishes.

Parameters:

algorithm (Algorithm) – The algorithm that has just finished.

create_reporter(reporter_name: str, **kwargs) Reporter[source]

Instantiate a reporter by name.

Parameters:
  • reporter_name (str) – One of "silent", "tqdm", or "verbose".

  • **kwargs – Forwarded to the reporter constructor.

Returns:

A concrete reporter instance.

Return type:

Reporter

Raises:

ValueError – If reporter_name is not recognized.

class SilentReporter[source]

Bases: Reporter

Reporter that produces no output.

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

log_init(algorithm: Algorithm)[source]

Called once, before the main optimization loop starts.

Parameters:

algorithm (Algorithm) – The algorithm that is about to run.

log_step(algorithm: Algorithm)[source]

Called after each generation.

Parameters:

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

log_end(algorithm: Algorithm)[source]

Called once, after the optimization loop finishes.

Parameters:

algorithm (Algorithm) – The algorithm that has just finished.

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

Bases: Reporter

Reporter that displays a tqdm progress bar.

Parameters:

resolution (int, optional) – Number of ticks in the progress bar (default 1000). Higher values give smoother updates.

log_init(algorithm: Algorithm)[source]

Initialise the progress bar and display the first postfix.

log_step(algorithm: Algorithm)[source]

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

log_end(algorithm: Algorithm)[source]

Fill the progress bar to 100% and close it.

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

Bases: Reporter

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

Parameters:

verbose_timer (float, optional) – Minimum interval (in seconds) between printed updates (default 0.5).

log_init(algorithm: Algorithm)[source]

Print a header indicating the start of the optimization.

log_step(algorithm: Algorithm)[source]

Print a status block if enough time has elapsed.

log_end(algorithm: Algorithm)[source]

Print a final summary of the completed run.