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::SimpleScore;
use solverforge_solver::manager::{Analyzable, ScoreAnalysis, ConstraintAnalysis};
#[derive(Clone)]
struct Schedule {
score: Option<SimpleScore>,
}
impl PlanningSolution for Schedule {
type Score = SimpleScore;
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<SimpleScore> {
ScoreAnalysis {
score: SimpleScore::of(0),
constraints: vec![],
}
}
}
let schedule = Schedule { score: Some(SimpleScore::of(0)) };
let analysis = schedule.analyze();
assert_eq!(analysis.score, SimpleScore::of(0));Required Methods§
Sourcefn analyze(&self) -> ScoreAnalysis<Self::Score>
fn analyze(&self) -> ScoreAnalysis<Self::Score>
Analyzes the solution and returns constraint breakdowns.
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.