Expand description
Move system for modifying planning solutions.
Moves are the fundamental operations that modify planning variables during solving. The solver explores the solution space by applying different moves and evaluating their impact on the score.
§Architecture
All moves are fully typed with inline value storage for maximum performance:
ChangeMove<S, V>- assigns a value to a variableSwapMove<S, V>- swaps values between two entitiesCompositeMove<'a, S, M1, M2>- applies two moves by referencePillarChangeMove<S, V>- changes multiple entities with same valuePillarSwapMove<S, V>- swaps between two pillarsListChangeMove<S, V>- relocates an element in a list variableListSwapMove<S, V>- swaps two elements in list variablesSubListChangeMove<S, V>- relocates a contiguous sublistSubListSwapMove<S, V>- swaps two contiguous sublistsListReverseMove<S, V>- reverses a segment (2-opt for TSP)RuinMove<S, V>- unassigns multiple entities (for Large Neighborhood Search)ListRuinMove<S, V>- removes elements from a list (for LNS on list variables)
Undo is handled by RecordingScoreDirector, not by moves returning undo data.
§Arena Allocation
Use MoveArena<M> for O(1) per-step cleanup. Call reset() at each step
instead of allocating a new Vec.
§Zero-Erasure Design
Moves are NEVER cloned. Ownership transfers via arena indices:
use solverforge_solver::heuristic::MoveArena;
// Simple move type for demonstration
struct SimpleMove { value: i32 }
let mut arena: MoveArena<SimpleMove> = MoveArena::new();
// Store moves - track indices manually
arena.push(SimpleMove { value: 1 }); // index 0
arena.push(SimpleMove { value: 2 }); // index 1
// Take ownership from arena when picking
let selected = arena.take(0);
assert_eq!(selected.value, 1);
// Reset clears arena for next step
arena.reset();Modules§
- k_
opt_ reconnection - Reconnection patterns for k-opt moves.
Structs§
- Change
Move - A move that assigns a value to an entity’s variable.
- Composite
Move - A move that applies two moves in sequence via arena indices.
- CutPoint
- A cut point in a route, defining where an edge is removed.
- KOpt
Move - A k-opt move that removes k edges and reconnects segments.
- List
Change Move - A move that relocates an element from one list position to another.
- List
Reverse Move - A move that reverses a segment within a list.
- List
Ruin Move - A move that removes elements from a list for Large Neighborhood Search.
- List
Swap Move - A move that swaps two elements in list variables.
- Move
Arena - Arena allocator for moves with O(1) reset.
- Pillar
Change Move - A move that assigns a value to all entities in a pillar.
- Pillar
Swap Move - A move that swaps values between two pillars.
- Ruin
Move - A move that unassigns multiple entities for Large Neighborhood Search.
- SubList
Change Move - A move that relocates a contiguous sublist from one position to another.
- SubList
Swap Move - A move that swaps two contiguous sublists.
- Swap
Move - A move that swaps values between two entities.
Traits§
- Move
- A move that modifies one or more planning variables.