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.
WriteToFile saves the parameter vector
to disk and as such requires the parameter vector to be serializable. Hence this feature is
only available with the
SlogLogger logs the progress of the
optimization to screen or to disk. This requires the
slog-logger feature. Writing to disk
in addtion requires the
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
(whenever a new best solution is found) or
Every(i) which means every
Custom observers can be used as well by implementing the
// [...] 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) // Log to file whenever a new best solution is found .add_observer(SlogLogger::file("solver.log", false)?, ObserverMode::NewBest) // Write parameter vector to `params/param.arg` every 20th iteration .add_observer( WriteToFile::new("params", "param", WriteToFileSerializer::JSON), ObserverMode::Every(20) ) // run the solver on the defined problem .run()?; // [...]
Write parameter vectors to a file during optimization.
Loggers based on the
Container for observers.
Indicates when to call an observer.
An interface which every observer is required to implement