## 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 `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 `serde1`

feature.

The observer `SlogLogger`

logs the progress of the
optimization to screen or to disk. This requires the `slog-logger`

feature. Writing to disk
in addition requires the `serde1`

feature.

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 `i`

th 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)
// 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()?;
// [...]
```

## Re-exports

`pub use file::*;`

`pub use slog_logger::*;`

## Modules

`slog`

crate