pub trait PlanningSolution:
Send
+ Sync
+ Clone {
type Score: Score;
// Required methods
fn domain_model() -> DomainModel;
fn constraints() -> ConstraintSet;
fn score(&self) -> Option<Self::Score>;
fn set_score(&mut self, score: Self::Score);
fn to_json(&self) -> SolverForgeResult<String>;
fn from_json(json: &str) -> SolverForgeResult<Self>
where Self: Sized;
}Expand description
Marker trait for types that can be used as planning solutions.
A planning solution contains:
- Problem facts: immutable data that constraints can reference
- Planning entities: objects that can be changed during solving
- A score: represents the quality of the solution
§Requirements
- Must have at least one planning entity collection
- Must have a score field
- Must provide a constraint provider function
§Derive Macro
This trait is typically implemented via #[derive(PlanningSolution)]:
ⓘ
#[derive(PlanningSolution)]
#[constraint_provider = "define_constraints"]
struct Timetable {
#[problem_fact_collection]
#[value_range_provider(id = "timeslots")]
timeslots: Vec<Timeslot>,
#[planning_entity_collection]
lessons: Vec<Lesson>,
#[planning_score]
score: Option<HardSoftScore>,
}Required Associated Types§
Required Methods§
Sourcefn domain_model() -> DomainModel
fn domain_model() -> DomainModel
Returns the complete domain model for this solution.
The domain model includes all entity classes, problem fact classes, and the solution class itself with all their fields and annotations.
Sourcefn constraints() -> ConstraintSet
fn constraints() -> ConstraintSet
Returns the constraint set for this solution.
The constraint set contains all constraints that will be evaluated during solving to calculate the solution’s score.
Sourcefn to_json(&self) -> SolverForgeResult<String>
fn to_json(&self) -> SolverForgeResult<String>
Serializes this solution to JSON.
Sourcefn from_json(json: &str) -> SolverForgeResult<Self>where
Self: Sized,
fn from_json(json: &str) -> SolverForgeResult<Self>where
Self: Sized,
Deserializes a solution from JSON.
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.