Module change

Module change 

Source
Expand description

ProblemChange API for real-time planning.

This module provides the ability to dynamically add, remove, or modify planning entities and problem facts during solving.

§Architecture

Problem changes are queued and applied between solver moves. When a problem change is applied:

  1. The solver clones the current best solution
  2. The problem change is applied via the ProblemChangeDirector
  3. Variable listeners are triggered
  4. The score is recalculated
  5. Solving resumes from the modified state

§Example

use solverforge_core::solver::change::{ProblemChange, ProblemChangeDirector};

struct AddEntityChange {
    entity_id: String,
    entity_data: serde_json::Value,
}

impl ProblemChange for AddEntityChange {
    fn do_change(&self, solution: &mut serde_json::Value, director: &mut dyn ProblemChangeDirector) {
        director.add_entity(&self.entity_id, self.entity_data.clone(), |entities| {
            entities.as_array_mut().unwrap().push(self.entity_data.clone());
        });
    }
}

Structs§

DefaultProblemChangeDirector
Default implementation of ProblemChangeDirector for local use.

Enums§

ChangeRecord
Record of a change made through the director.
ProblemChangeDto
Serializable DTO for transmitting problem changes to the solver service.
ProblemChangeError
Error type for problem change operations.

Traits§

ProblemChange
A problem change represents a modification to the planning solution during solving.
ProblemChangeDirector
Director for applying problem changes to the working solution.

Type Aliases§

ChangeConsumer
Type alias for consumer functions used by ProblemChangeDirector.