BaseCallback#

class lumopt2.utils.callbacks.BaseCallback#

Base class for optimization callbacks.

Callbacks are invoked at various points during optimization to enable logging, visualization, checkpointing, or other monitoring tasks.

All hook methods default to no-ops, so subclasses only need to override the events they actually care about. Concrete callbacks typically implement either the *_iteration_* pair (for per-step bookkeeping such as the visualizer) or just on_function_eval (for everything-fires-on-every-eval loggers); both flavours coexist happily with the no-op defaults supplied here.

Hooks fire in this order:

  1. on_optimization_start – once at the beginning.

  2. on_function_eval – after each objective-function evaluation.

  3. on_iteration_start – before each iteration (if the optimizer exposes iteration boundaries).

  4. on_iteration_end – after each iteration (idem).

  5. on_optimization_end – once at the end.

SciPy-driven optimizers expose both per-iteration and per-evaluation hooks; gradient-free or single-pass optimizers may only fire on_function_eval. Subclasses that only care about iteration boundaries can therefore safely leave on_function_eval at the no-op default and vice-versa.

Methods

BaseCallback.on_function_eval(project, ...)

Called after each objective function evaluation.

BaseCallback.on_iteration_end(project, ...)

Called at the end of each iteration.

BaseCallback.on_iteration_start(iteration, ...)

Called at the start of each iteration.

BaseCallback.on_optimization_end(success, ...)

Called when optimization completes.

BaseCallback.on_optimization_start(project, ...)

Called when optimization begins.