Skip to main content

solverforge_core/domain/supply/
mod.rs

1/* Supply infrastructure for variable relationship tracking.
2
3Supplies provide efficient access to derived information about planning variables,
4such as inverse relationships and list-element positions.
5
6# Zero-Erasure Design
7
8- **Index-based**: All supplies store indices, not cloned domain objects
9- **Owned**: Supplies are owned directly, no `Arc`, `Box`, or `dyn`
10- **Mutation via `&mut`**: Ordinary Rust ownership, no `RwLock` or interior mutability
11- **Generic**: Full type information preserved through the entire pipeline
12
13# Available Supplies
14
15- [`InverseSupply`]: Maps values to entity indices for O(1) inverse lookups
16- [`ListStateSupply`]: Tracks element positions in list variables
17
18# Usage
19
20Supplies are owned by the score director or solver scope. They're created
21when needed and accessed via regular Rust references:
22
23```
24use solverforge_core::domain::supply::{InverseSupply, ListStateSupply};
25
26// Create supplies owned by your containing struct
27let mut inverse: InverseSupply<i64> = InverseSupply::new();
28let mut list_state: ListStateSupply<usize> = ListStateSupply::new();
29
30// Use with standard Rust ownership
31inverse.insert(42, 0);  // value 42 -> entity index 0
32list_state.assign(10, 0, 0);  // element 10 -> entity 0, position 0
33
34// Read with shared reference
35assert_eq!(inverse.get(&42), Some(0));
36assert_eq!(list_state.get_entity(&10), Some(0));
37```
38*/
39
40mod inverse;
41mod list_state;
42
43#[cfg(test)]
44mod tests;
45
46pub use inverse::InverseSupply;
47pub use list_state::{ElementPosition, ListStateSupply};