pub trait SearchProblem {
type State: Clone;
type Choice: Clone + Ord;
type Output: Clone + Debug;
// Required methods
fn initial_state(&self) -> Self::State;
fn expand(&self, state: &Self::State, out: &mut Vec<Self::Choice>);
fn apply(
&self,
state: &Self::State,
choice: &Self::Choice,
) -> SearchStep<Self::State>;
fn finish(&self, state: &Self::State) -> Option<Self::Output>;
// Provided methods
fn propagate(&self, state: Self::State) -> SearchStep<Self::State> { ... }
fn score_state(&self, _state: &Self::State) -> i64 { ... }
fn estimate_remaining(&self, _state: &Self::State) -> i64 { ... }
fn bound(&self, _state: &Self::State) -> Option<i64> { ... }
fn output_score(&self, _output: &Self::Output) -> Option<i64> { ... }
}Expand description
Generic state-space problem consumed by crate::solve.
Required Associated Types§
Required Methods§
Sourcefn initial_state(&self) -> Self::State
fn initial_state(&self) -> Self::State
Return the initial search state.
Sourcefn expand(&self, state: &Self::State, out: &mut Vec<Self::Choice>)
fn expand(&self, state: &Self::State, out: &mut Vec<Self::Choice>)
Append possible choices for state to out.
Provided Methods§
Sourcefn propagate(&self, state: Self::State) -> SearchStep<Self::State>
fn propagate(&self, state: Self::State) -> SearchStep<Self::State>
Propagate generic CSP constraints after a state is produced.
Sourcefn score_state(&self, _state: &Self::State) -> i64
fn score_state(&self, _state: &Self::State) -> i64
Deterministic priority score for best-first and A-star search.
Sourcefn estimate_remaining(&self, _state: &Self::State) -> i64
fn estimate_remaining(&self, _state: &Self::State) -> i64
Deterministic optimistic remaining estimate for A-star and beam search.
Sourcefn bound(&self, _state: &Self::State) -> Option<i64>
fn bound(&self, _state: &Self::State) -> Option<i64>
Lower-bound score used by branch-and-bound minimization.
Sourcefn output_score(&self, _output: &Self::Output) -> Option<i64>
fn output_score(&self, _output: &Self::Output) -> Option<i64>
Score for a finished output used by branch-and-bound minimization.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".