Crate solverforge_derive

Crate solverforge_derive 

Source
Expand description

Derive macros for SolverForge domain types.

This crate provides derive macros for implementing PlanningEntity and PlanningSolution traits from solverforge-core.

§Example

use solverforge_derive::{PlanningEntity, PlanningSolution};

#[derive(PlanningEntity, Clone)]
pub struct Lesson {
    #[planning_id]
    pub id: String,
    pub subject: String,
    #[planning_variable(value_range_provider = "rooms")]
    pub room: Option<Room>,
}

#[derive(PlanningSolution, Clone)]
#[constraint_provider = "define_constraints"]
pub struct Timetable {
    #[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>,
}

Derive Macros§

DomainStruct
Derive macro for implementing the DomainStruct trait.
PlanningEntity
Derive macro for implementing the PlanningEntity trait.
PlanningSolution
Derive macro for implementing the PlanningSolution trait.