solverforge-cli 2.0.1

CLI for scaffolding and managing SolverForge constraint solver projects
use serde::{Deserialize, Serialize};
use solverforge::prelude::*;
// @solverforge:begin solution-imports
use super::Container;
use super::Item;
// @solverforge:end solution-imports

/// The root planning solution: items + containers + score.
///
/// Rename this to something domain-specific (Route, Schedule, Assignment, …).
/// The list field on `Container` declares what is solvable; this root type
/// groups the sample data and score for the scaffold.
#[planning_solution(
    constraints = "crate::constraints::create_constraints",
    solver_toml = "../../solver.toml"
)]
#[derive(Serialize, Deserialize)]
pub struct Plan {
    // @solverforge:begin solution-collections
    #[problem_fact_collection]
    pub item_facts: Vec<Item>,
    #[planning_entity_collection]
    pub containers: Vec<Container>,
    // @solverforge:end solution-collections
    #[planning_score]
    pub score: Option<HardSoftScore>,
}

impl Plan {
    pub fn new(
        // @solverforge:begin solution-constructor-params
        item_facts: Vec<Item>,
        containers: Vec<Container>,
        // @solverforge:end solution-constructor-params
    ) -> Self {
        Self {
            // @solverforge:begin solution-constructor-init
            item_facts,
            containers,
            // @solverforge:end solution-constructor-init
            score: None,
        }
    }
}