pub trait Observe<I> {
// Provided methods
fn observe_init(
&mut self,
_name: &str,
_state: &I,
_kv: &KV
) -> Result<(), Error> { ... }
fn observe_iter(&mut self, _state: &I, _kv: &KV) -> Result<(), Error> { ... }
fn observe_final(&mut self, _state: &I) -> Result<(), Error> { ... }
}
Expand description
An interface which every observer is required to implement
§Example
use argmin::core::{Error, KV, State};
use argmin::core::observers::Observe;
struct MyObserver {}
impl<I> Observe<I> for MyObserver
where
// Optional constraint on `I`. The `State` trait, which every state used in argmin needs to
// implement, offers a range of methods which can be useful.
I: State,
{
fn observe_init(&mut self, name: &str, state: &I, kv: &KV) -> Result<(), Error> {
// Do something with `name` and/or `kv`
// Is executed after initialization of a solver
Ok(())
}
fn observe_iter(&mut self, state: &I, kv: &KV) -> Result<(), Error> {
// Do something with `state` and/or `kv`
// Is executed after each iteration of a solver
Ok(())
}
}
Provided Methods§
sourcefn observe_init(
&mut self,
_name: &str,
_state: &I,
_kv: &KV
) -> Result<(), Error>
fn observe_init( &mut self, _name: &str, _state: &I, _kv: &KV ) -> Result<(), Error>
Called once after initialization of the solver.
Has access to the name of the solver via name
, the initial state
and to a key-value
store kv
with settings of the solver.