solverforge_solver/realtime/mod.rs
1/* Real-time planning support.
2
3Allows submitting problem changes while the solver is running. Changes are
4processed at step boundaries to maintain solver consistency.
5
6# Overview
7
8Real-time planning enables dynamic updates to the problem during solving:
9- Add new entities (e.g., new orders, tasks, employees)
10- Remove entities (e.g., cancelled orders)
11- Update entity properties (e.g., deadline changes)
12- Modify problem facts (e.g., new constraints)
13
14# Example
15
16```
17use solverforge_solver::realtime::ProblemChange;
18use solverforge_scoring::Director;
19use solverforge_core::domain::PlanningSolution;
20use solverforge_core::score::SoftScore;
21
22#[derive(Clone, Debug)]
23struct Task { id: usize, priority: Option<i32> }
24
25#[derive(Clone, Debug)]
26struct Schedule {
27tasks: Vec<Task>,
28score: Option<SoftScore>,
29}
30
31impl PlanningSolution for Schedule {
32type Score = SoftScore;
33fn score(&self) -> Option<Self::Score> { self.score }
34fn set_score(&mut self, score: Option<Self::Score>) { self.score = score; }
35}
36
37// Create a problem change that adds a new task
38#[derive(Debug)]
39struct AddTask { id: usize }
40
41impl ProblemChange<Schedule> for AddTask {
42fn apply(&self, score_director: &mut dyn Director<Schedule>) {
43let task = Task { id: self.id, priority: None };
44score_director.working_solution_mut().tasks.push(task);
45}
46}
47```
48*/
49
50mod problem_change;
51mod solver_handle;
52
53pub use problem_change::{BoxedProblemChange, ClosureProblemChange, ProblemChange};
54pub use solver_handle::{ProblemChangeReceiver, ProblemChangeResult, SolverHandle};