Expand description
§Observers
Argmin offers an interface to observe the state of the solver at initialization as well as after every iteration. This includes the parameter vector, gradient, Jacobian, Hessian, iteration number, cost values and many more as well as solver-specific metrics. This interface can be used to implement loggers, send the information to a storage or to plot metrics.
The observer ParamWriter saves the parameter vector to disk. It is distributed via the
argmin-observer-paramwriter crate.
The observer SlogLogger logs the progress of the optimization to screen or to disk.
It can be found in the argmin-observer-slog crate.
For each observer it can be defined how often it will observe the progress of the solver. This
is indicated via the enum ObserverMode which can be either Always, Never, NewBest
(whenever a new best solution is found) or Every(i) which means every ith iteration.
Custom observers can be used as well by implementing the crate::core::observers::Observe
trait.
§Example
// [...]
let res = Executor::new(problem, solver)
.configure(|config| config.param(init_param).max_iters(2))
// Add an observer which will log all iterations to the terminal (without blocking)
.add_observer(SlogLogger::term_noblock(), ObserverMode::Always)
// Write parameter vector to `params/param.arg` every 20th iteration
.add_observer(
ParamWriter::new("params", "param", ParamWriterFormat::JSON),
ObserverMode::Every(20)
)
// run the solver on the defined problem
.run()?;
// [...]Structs§
- Observers
- Container for observers.
Enums§
- Observer
Mode - Indicates when to call an observer.
Traits§
- Observe
- An interface which every observer is required to implement