pub trait Calculation<P, S> {
type Error: Error + 'static;
type Output;
const NAME: &'static str;
// Required methods
fn next(
&mut self,
problem: &mut Problem<P>,
state: S,
) -> Result<S, Self::Error>;
fn finalise(
&mut self,
problem: &mut Problem<P>,
state: S,
) -> Result<Self::Output, Self::Error>;
// Provided method
fn initialise(
&mut self,
_problem: &mut Problem<P>,
state: S,
) -> Result<S, Self::Error> { ... }
}Expand description
Trait implemented by all problems solveable by Trellis
A calculation defines the core loop of the solver. Typically we would write a for loop,
consisting of an initialisation step where the calculation is arranged, a procedure carried out
on each loop iteration, and a finalisation step prior to return. This trait separates these
methods so they can be called by the [Runner]
Required Associated Constants§
Required Associated Types§
Sourcetype Output
type Output
The type returned to the caller.
Trellis defines a data-rich [Output], which can be constructed from the calculation, and
internal state. In some circumstances it may be appropriate to return this type to the
caller. In other circumstances it may be preferential to bury this complexity, returning
the caller a custom datatype.
Required Methods§
Provided Methods§
Sourcefn initialise(
&mut self,
_problem: &mut Problem<P>,
state: S,
) -> Result<S, Self::Error>
fn initialise( &mut self, _problem: &mut Problem<P>, state: S, ) -> Result<S, Self::Error>
Initialisation.
This step prepares the state object for the main calculation loop.
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.