PlanningSolution

Derive Macro PlanningSolution 

Source
#[derive(PlanningSolution)]
{
    // Attributes available to this derive:
    #[constraint_provider]
    #[problem_fact_collection]
    #[problem_fact]
    #[planning_entity_collection]
    #[planning_entity]
    #[value_range_provider]
    #[planning_score]
}
Expand description

Derive macro for implementing the PlanningSolution trait.

§Attributes

§Struct Attributes

  • #[constraint_provider = "function_name"] - Specifies the function that provides constraints for this solution. The function must have signature fn(ConstraintFactory) -> Vec<Constraint>.

§Field Attributes

  • #[problem_fact_collection] - Marks a collection field as containing immutable problem facts.

  • #[problem_fact] - Marks a single field as a problem fact.

  • #[planning_entity_collection] - Marks a collection field as containing planning entities that will be modified during solving.

  • #[planning_entity] - Marks a single field as a planning entity.

  • #[value_range_provider(id = "...")] - Marks a field as providing values for planning variables with the matching value_range_provider reference.

  • #[planning_score] - Marks the field that will hold the solution’s score.

§Example

#[derive(PlanningSolution, Clone)]
#[constraint_provider = "define_constraints"]
pub struct Timetable {
    #[problem_fact_collection]
    #[value_range_provider(id = "timeslots")]
    pub timeslots: Vec<Timeslot>,

    #[problem_fact_collection]
    #[value_range_provider(id = "rooms")]
    pub rooms: Vec<Room>,

    #[planning_entity_collection]
    pub lessons: Vec<Lesson>,

    #[planning_score]
    pub score: Option<HardSoftScore>,
}