use auto_impl::auto_impl;
use crate::LocalsearchError;
#[auto_impl(&, Box, Rc, Arc)]
pub trait OptModel: Sync + Send {
type ScoreType: Ord + Copy + Sync + Send;
type SolutionType: Clone + Sync + Send;
type TransitionType: Clone + Sync + Send;
fn generate_random_solution<R: rand::Rng>(
&self,
rng: &mut R,
) -> Result<(Self::SolutionType, Self::ScoreType), LocalsearchError>;
fn generate_trial_solution<R: rand::Rng>(
&self,
current_solution: Self::SolutionType,
current_score: Self::ScoreType,
rng: &mut R,
) -> (Self::SolutionType, Self::TransitionType, Self::ScoreType);
fn preprocess_solution(
&self,
current_solution: Self::SolutionType,
current_score: Self::ScoreType,
) -> Result<(Self::SolutionType, Self::ScoreType), LocalsearchError> {
Ok((current_solution, current_score))
}
fn postprocess_solution(
&self,
current_solution: Self::SolutionType,
current_score: Self::ScoreType,
) -> (Self::SolutionType, Self::ScoreType) {
(current_solution, current_score)
}
}