pub trait Solver<O: ArgminOp>: Serialize {
const NAME: &'static str = "UNDEFINED";
// Required method
fn next_iter(
&mut self,
op: &mut OpWrapper<O>,
state: &IterState<O>,
) -> Result<ArgminIterData<O>, Error>;
// Provided methods
fn init(
&mut self,
_op: &mut OpWrapper<O>,
_state: &IterState<O>,
) -> Result<Option<ArgminIterData<O>>, Error> { ... }
fn terminate_internal(&mut self, state: &IterState<O>) -> TerminationReason { ... }
fn terminate(&mut self, _state: &IterState<O>) -> TerminationReason { ... }
}
Expand description
Solver
Every solver needs to implement this trait.
Provided Associated Constants§
Required Methods§
Provided Methods§
Sourcefn init(
&mut self,
_op: &mut OpWrapper<O>,
_state: &IterState<O>,
) -> Result<Option<ArgminIterData<O>>, Error>
fn init( &mut self, _op: &mut OpWrapper<O>, _state: &IterState<O>, ) -> Result<Option<ArgminIterData<O>>, Error>
Initializes the algorithm
This is executed before any iterations are performed. It can be used to perform precomputations. The default implementation corresponds to doing nothing.
Sourcefn terminate_internal(&mut self, state: &IterState<O>) -> TerminationReason
fn terminate_internal(&mut self, state: &IterState<O>) -> TerminationReason
Checks whether basic termination reasons apply.
Terminate if
- algorithm was terminated somewhere else in the Executor
- iteration count exceeds maximum number of iterations
- cost is lower than target cost
This can be overwritten in a Solver
implementation; however it is not advised.
Sourcefn terminate(&mut self, _state: &IterState<O>) -> TerminationReason
fn terminate(&mut self, _state: &IterState<O>) -> TerminationReason
Checks whether the algorithm must be terminated
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.