Skip to main content

Procedure

Trait Procedure 

Source
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 Engine

Required Associated Constants§

Source

const NAME: &'static str

An identifier for the procedure.

This identifier is printed in tracing logs

Required Associated Types§

Source

type Output

The type returned to the caller.

Source

type State

The internal state used by the procedure

Required Methods§

Source

fn step( &self, problem: &mut P, state: &mut Self::State, guard: CancellationGuard<'_>, )

One iteration of the core algorithm

Source

fn finalise(&self, problem: &mut P, state: &Self::State) -> Self::Output

Converts the internal state to the user-facing return datatype

Provided Methods§

Source

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".

Implementors§