pub trait Analyzable:
PlanningSolution
+ Clone
+ Send
+ 'static {
// Required method
fn analyze(&self) -> ScoreAnalysis<Self::Score>;
}Expand description
Trait for solutions that can be analyzed for constraint violations.
This trait is implemented by the #[planning_solution] macro when
constraints is specified. It provides constraint analysis without
knowing the concrete solution type.
§Example
use solverforge_core::domain::PlanningSolution;
use solverforge_core::score::SoftScore;
use solverforge_solver::manager::{Analyzable, ScoreAnalysis, ConstraintAnalysis};
#[derive(Clone)]
struct Schedule {
score: Option<SoftScore>,
}
impl PlanningSolution for Schedule {
type Score = SoftScore;
fn score(&self) -> Option<Self::Score> { self.score }
fn set_score(&mut self, score: Option<Self::Score>) { self.score = score; }
}
impl Analyzable for Schedule {
fn analyze(&self) -> ScoreAnalysis<SoftScore> {
ScoreAnalysis {
score: SoftScore::of(0),
constraints: vec![],
}
}
}
let schedule = Schedule { score: Some(SoftScore::of(0)) };
let analysis = schedule.analyze();
assert_eq!(analysis.score, SoftScore::of(0));Required Methods§
fn analyze(&self) -> ScoreAnalysis<Self::Score>
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.