Users currently have no way to hook into the running optimisation loop — e.g. to implement early stopping based on a custom criterion, log to an external system, or visualise intermediate pulses.
The History class (history.py) covers post-hoc logging but requires the full run to finish.
Proposed change:
Add an optional callbacks argument to Geope.optimize — a list of callables with the signature:
def cb(step: int, history: History, geope: Geope) -> bool:
... # return False to request early stop
Callbacks are called after each optimisation step (after add_parameters in the main loop, geope.py:615–647). If any callback returns False the loop exits cleanly.
Acceptance criteria:
callbacks=[cb] is accepted and called each step.
- Returning
True from a callback terminates the loop early.
- Default (
callbacks=None) preserves current behaviour with zero overhead.
- At least one test covering early-stop and logging callbacks.
Users currently have no way to hook into the running optimisation loop — e.g. to implement early stopping based on a custom criterion, log to an external system, or visualise intermediate pulses.
The
Historyclass (history.py) covers post-hoc logging but requires the full run to finish.Proposed change:
Add an optional
callbacksargument toGeope.optimize— a list of callables with the signature:Callbacks are called after each optimisation step (after
add_parametersin the main loop,geope.py:615–647). If any callback returnsFalsethe loop exits cleanly.Acceptance criteria:
callbacks=[cb]is accepted and called each step.Truefrom a callback terminates the loop early.callbacks=None) preserves current behaviour with zero overhead.