pub trait Procedure<P> {
type Output;
type State;
const NAME: &'static str;
// Required methods
fn step(
&self,
problem: &mut P,
state: &mut Self::State,
guard: CancellationGuard<'_>,
);
fn finalise(&self, problem: &mut P, state: &Self::State) -> Self::Output;
// Provided method
fn initialise(&self, _problem: &mut P, _state: &mut Self::State) { ... }
}Expand description
Trait implemented by all problems solvable by Trellis
A procedure defines the core loop of the solver. Typically we would write a for loop,
consisting of an initialisation step where the procedure 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 procedure, 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.
type State
Required Methods§
Sourcefn step(
&self,
problem: &mut P,
state: &mut Self::State,
guard: CancellationGuard<'_>,
)
fn step( &self, problem: &mut P, state: &mut Self::State, guard: CancellationGuard<'_>, )
One iteration of the core algorithm
Provided Methods§
Sourcefn initialise(&self, _problem: &mut P, _state: &mut Self::State)
fn initialise(&self, _problem: &mut P, _state: &mut Self::State)
Initialisation.
This step prepares the state object for the main procedure loop.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".