pub trait PlanningSolution:
Clone
+ Send
+ Sync
+ 'static {
type Score: Score;
// Required methods
fn score(&self) -> Option<Self::Score>;
fn set_score(&mut self, score: Option<Self::Score>);
// Provided method
fn is_initialized(&self) -> bool { ... }
}Expand description
Marker trait for planning solutions.
A planning solution represents both the problem definition and the (potentially partial) solution. It contains:
- Problem facts: Immutable input data
- Planning entities: Things to be optimized
- Score: The quality of the current solution
§Example
use solverforge_core::{PlanningSolution, score::SimpleScore};
#[derive(Clone)]
struct NQueens {
n: usize,
rows: Vec<Option<usize>>,
score: Option<SimpleScore>,
}
impl PlanningSolution for NQueens {
type Score = SimpleScore;
fn score(&self) -> Option<Self::Score> {
self.score
}
fn set_score(&mut self, score: Option<Self::Score>) {
self.score = score;
}
}For complex solutions, use the #[derive(PlanningSolution)] macro from solverforge-macros.
§Thread Safety
Planning solutions must be Send + Sync to support multi-threaded solving.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn is_initialized(&self) -> bool
fn is_initialized(&self) -> bool
Returns true if this solution is fully initialized.
A solution is initialized when all planning variables have been assigned.
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.