PlanningEntity

Derive Macro PlanningEntity 

Source
#[derive(PlanningEntity)]
{
    // Attributes available to this derive:
    #[planning_id]
    #[planning_variable]
    #[planning_list_variable]
    #[inverse_relation_shadow]
    #[index_shadow]
    #[next_element_shadow]
    #[previous_element_shadow]
    #[anchor_shadow]
    #[cascading_update_shadow]
}
Expand description

Derive macro for implementing the PlanningEntity trait.

§Attributes

§Field Attributes

  • #[planning_id] - Marks the field as the unique identifier for this entity. Required for every planning entity.

  • #[planning_variable(value_range_provider = "...")] - Marks the field as a planning variable. The solver will assign values from the specified value range provider.

  • #[planning_variable(value_range_provider = "...", allows_unassigned = true)] - Allows the variable to remain unassigned (null/None).

§Example

#[derive(PlanningEntity, Clone)]
pub struct Lesson {
    #[planning_id]
    pub id: String,

    pub subject: String,
    pub teacher: String,

    #[planning_variable(value_range_provider = "timeslots")]
    pub timeslot: Option<Timeslot>,

    #[planning_variable(value_range_provider = "rooms", allows_unassigned = true)]
    pub room: Option<Room>,
}