Skip to main content

solverforge_solver/
lib.rs

1/* SolverForge Solver Engine
2
3This crate provides the main solver implementation including:
4- Solver and SolverFactory
5- Phases (construction heuristic, local search, exhaustive search)
6- Move system
7- Termination conditions
8- Tracing-based structured logging
9- Configuration wiring (builder module)
10*/
11
12/* PhantomData<(fn() -> T, ...)> is an intentional pattern to avoid inheriting
13trait bounds from phantom type parameters. Clippy's type_complexity lint
14triggers on these tuples but the pattern is architecturally required.
15*/
16#![allow(clippy::type_complexity)]
17
18#[cfg(test)]
19pub mod test_utils;
20
21pub mod builder;
22pub mod descriptor;
23pub mod heuristic;
24pub mod manager;
25pub mod model_support;
26pub mod phase;
27pub mod planning;
28pub mod realtime;
29pub mod run;
30pub mod runtime;
31pub mod scope;
32pub mod solver;
33pub mod stats;
34pub mod termination;
35
36pub use builder::{
37    build_local_search, build_move_selector, local_search, AcceptorBuilder, AnyAcceptor,
38    AnyForager, CustomSearchPhase, ForagerBuilder, IntraDistanceAdapter, ListVariableSlot,
39    LocalSearch, LocalSearchStrategy, Neighborhood, NeighborhoodLeaf, NeighborhoodMove,
40    RuntimeModel, ScalarGroupBinding, ScalarGroupMemberBinding, ScalarVariableSlot, Search,
41    SearchContext, Selector, ValueSource, VariableSlot,
42};
43pub use descriptor::{
44    build_descriptor_move_selector, descriptor_has_bindings, DescriptorConstruction,
45    DescriptorFlatSelector, DescriptorLeafSelector, DescriptorMoveUnion,
46    DescriptorPillarChangeMove, DescriptorPillarSwapMove, DescriptorRuinRecreateMove,
47    DescriptorSelector, DescriptorSelectorNode,
48};
49pub use heuristic::{
50    // K-opt reconnection patterns
51    k_opt_reconnection,
52    // Selectors
53    AllEntitiesSelector,
54    // Move types
55    ChangeMove,
56    ChangeMoveSelector,
57    CompositeMove,
58    CompoundScalarEdit,
59    CompoundScalarMove,
60    CrossEntityDistanceMeter,
61    CutPoint,
62    DefaultCrossEntityDistanceMeter,
63    DefaultDistanceMeter,
64    DefaultPillarSelector,
65    EntityReference,
66    EntitySelector,
67    FromSolutionEntitySelector,
68    FromSolutionValueSelector,
69    KOptConfig,
70    KOptMove,
71    KOptMoveSelector,
72    ListPositionDistanceMeter,
73    ListRuinMove,
74    ListRuinMoveSelector,
75    MimicRecorder,
76    MimicRecordingEntitySelector,
77    MimicReplayingEntitySelector,
78    Move,
79    MoveArena,
80    MoveSelector,
81    NearbyDistanceMeter,
82    NearbyEntitySelector,
83    NearbyKOptMoveSelector,
84    NearbySelectionConfig,
85    PerEntitySliceValueSelector,
86    Pillar,
87    PillarChangeMove,
88    PillarSelector,
89    PillarSwapMove,
90    RuinMove,
91    RuinMoveSelector,
92    RuinVariableAccess,
93    SelectionOrder,
94    StaticValueSelector,
95    SubPillarConfig,
96    SwapMove,
97    SwapMoveSelector,
98    ValueSelector,
99    // Vec union selector
100    VecUnionSelector,
101};
102pub use manager::{
103    analyze, Analyzable, ConstraintAnalysis, ConstructionPhaseFactory, ConstructionType, KOptPhase,
104    KOptPhaseBuilder, ListCheapestInsertionPhase, ListClarkeWrightPhase, ListConstructionPhase,
105    ListConstructionPhaseBuilder, ListKOptPhase, ListRegretInsertionPhase, LocalSearchAcceptorType,
106    LocalSearchPhaseFactory, PhaseFactory, ScoreAnalysis, Solvable, SolverEvent,
107    SolverEventMetadata, SolverFactory, SolverFactoryBuilder, SolverLifecycleState, SolverManager,
108    SolverManagerError, SolverRuntime, SolverSnapshot, SolverSnapshotAnalysis, SolverStatus,
109    SolverTerminalReason,
110};
111pub use model_support::PlanningModelSupport;
112pub use phase::{
113    construction::{
114        BestFitForager, ConstructionChoice, ConstructionForager, ConstructionHeuristicConfig,
115        ConstructionHeuristicPhase, EntityPlacer, FirstFeasibleForager, FirstFitForager,
116        ForagerType, Placement, QueuedEntityPlacer,
117    },
118    exhaustive::{
119        BounderType, ExhaustiveSearchConfig, ExhaustiveSearchDecider, ExhaustiveSearchNode,
120        ExhaustiveSearchPhase, ExplorationType, FixedOffsetBounder, ScoreBounder, SimpleDecider,
121        SoftScoreBounder,
122    },
123    localsearch::{
124        AcceptedCountForager, Acceptor, BestScoreForager, DiversifiedLateAcceptanceAcceptor,
125        FirstAcceptedForager, FirstBestScoreImprovingForager, FirstLastStepScoreImprovingForager,
126        GreatDelugeAcceptor, HardRegressionPolicy, HillClimbingAcceptor, LateAcceptanceAcceptor,
127        LocalSearchForager, LocalSearchPhase, SimulatedAnnealingAcceptor,
128        SimulatedAnnealingCalibration, StepCountingHillClimbingAcceptor, TabuSearchAcceptor,
129    },
130    partitioned::{
131        ChildPhases, FunctionalPartitioner, PartitionedSearchConfig, PartitionedSearchPhase,
132        SolutionPartitioner, ThreadCount,
133    },
134    sequence::PhaseSequence,
135    Phase,
136};
137pub use planning::{
138    ConflictRepair, RepairCandidate, RepairLimits, RepairProvider, ScalarAssignmentRule,
139    ScalarCandidate, ScalarCandidateProvider, ScalarEdit, ScalarGroup, ScalarGroupLimits,
140    ScalarTarget,
141};
142pub use run::{log_solve_start, run_solver, run_solver_with_config};
143pub use runtime::{ListVariableEntity, ListVariableMetadata};
144pub use scope::{PhaseScope, SolverScope, StepScope};
145pub use solver::{MaybeTermination, NoTermination, SolveResult, Solver};
146pub use stats::{PhaseStats, SelectorTelemetry, SolverStats, SolverTelemetry};
147pub use termination::{
148    AndTermination, BestScoreFeasibleTermination, BestScoreTermination,
149    DiminishedReturnsTermination, MoveCountTermination, OrTermination,
150    ScoreCalculationCountTermination, StepCountTermination, Termination, TimeTermination,
151    UnimprovedStepCountTermination, UnimprovedTimeTermination,
152};