pub struct Observers<I> { /* private fields */ }
Expand description

Container for observers.

This tpe also implements Observe and therefore can be used like a single observer. Each observer has an ObserverMode attached which indicates when the observer will be called.

Implementations

Construct a new empty Observers instance.

Example
use argmin::core::observers::Observers;
use argmin::core::IterState;

let observers: Observers<IterState<Vec<f64>, (), (), (), f64>> = Observers::new();

Add another observer with a corresponding ObserverMode.

Example
use argmin::core::observers::{Observers, ObserverMode};
use argmin::core::observers::SlogLogger;
use argmin::core::IterState;

let mut observers: Observers<IterState<Vec<f64>, (), (), (), f64>> = Observers::new();

let logger = SlogLogger::term();
observers.push(logger, ObserverMode::Always);

Returns true if there are no observers stored.

Example
use argmin::core::observers::Observers;
use argmin::core::IterState;

let observers: Observers<IterState<Vec<f64>, (), (), (), f64>> = Observers::new();
assert!(observers.is_empty());

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Returns the “default value” for a type. Read more

Implementing Observe for Observers allows to use it like a single observer. In its implementation it will loop over all stored observers, checks if the conditions for observing are met and calls the actual observers if required.

After initialization of the solver, this loops over all stored observers and calls them.

Called after each iteration.

Loops over all observers, and based on whether the condition for calling the observers are met, calls them.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.