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, build_vnd, AcceptorBuilder, AnyAcceptor, AnyForager,
38    ForagerBuilder, IntraDistanceAdapter, ListVariableSlot, LocalSearch, Neighborhood,
39    NeighborhoodLeaf, NeighborhoodMove, RuntimeModel, ScalarGroupBinding, ScalarGroupMemberBinding,
40    ScalarVariableSlot, Selector, ValueSource, VariableSlot, Vnd,
41};
42pub use descriptor::{
43    build_descriptor_move_selector, descriptor_has_bindings, DescriptorConstruction,
44    DescriptorFlatSelector, DescriptorLeafSelector, DescriptorMoveUnion,
45    DescriptorPillarChangeMove, DescriptorPillarSwapMove, DescriptorRuinRecreateMove,
46    DescriptorSelector, DescriptorSelectorNode,
47};
48pub use heuristic::{
49    // K-opt reconnection patterns
50    k_opt_reconnection,
51    // Selectors
52    AllEntitiesSelector,
53    // Move types
54    ChangeMove,
55    ChangeMoveSelector,
56    CompositeMove,
57    CompoundScalarEdit,
58    CompoundScalarMove,
59    CrossEntityDistanceMeter,
60    CutPoint,
61    DefaultCrossEntityDistanceMeter,
62    DefaultDistanceMeter,
63    DefaultPillarSelector,
64    EntityReference,
65    EntitySelector,
66    FromSolutionEntitySelector,
67    FromSolutionValueSelector,
68    KOptConfig,
69    KOptMove,
70    KOptMoveSelector,
71    ListPositionDistanceMeter,
72    ListRuinMove,
73    ListRuinMoveSelector,
74    MimicRecorder,
75    MimicRecordingEntitySelector,
76    MimicReplayingEntitySelector,
77    Move,
78    MoveArena,
79    MoveSelector,
80    NearbyDistanceMeter,
81    NearbyEntitySelector,
82    NearbyKOptMoveSelector,
83    NearbySelectionConfig,
84    PerEntitySliceValueSelector,
85    Pillar,
86    PillarChangeMove,
87    PillarSelector,
88    PillarSwapMove,
89    RuinMove,
90    RuinMoveSelector,
91    RuinVariableAccess,
92    SelectionOrder,
93    StaticValueSelector,
94    SubPillarConfig,
95    SwapMove,
96    SwapMoveSelector,
97    ValueSelector,
98    // Vec union selector
99    VecUnionSelector,
100};
101pub use manager::{
102    analyze, Analyzable, ConstraintAnalysis, ConstructionPhaseFactory, ConstructionType, KOptPhase,
103    KOptPhaseBuilder, ListCheapestInsertionPhase, ListClarkeWrightPhase, ListConstructionPhase,
104    ListConstructionPhaseBuilder, ListKOptPhase, ListRegretInsertionPhase, LocalSearchPhaseFactory,
105    LocalSearchType, PhaseFactory, ScoreAnalysis, Solvable, SolverEvent, SolverEventMetadata,
106    SolverFactory, SolverFactoryBuilder, SolverLifecycleState, SolverManager, SolverManagerError,
107    SolverRuntime, SolverSnapshot, SolverSnapshotAnalysis, SolverStatus, SolverTerminalReason,
108};
109pub use model_support::PlanningModelSupport;
110pub use phase::{
111    construction::{
112        BestFitForager, ConstructionChoice, ConstructionForager, ConstructionHeuristicConfig,
113        ConstructionHeuristicPhase, EntityPlacer, FirstFeasibleForager, FirstFitForager,
114        ForagerType, Placement, QueuedEntityPlacer,
115    },
116    dynamic_vnd::DynamicVndPhase,
117    exhaustive::{
118        BounderType, ExhaustiveSearchConfig, ExhaustiveSearchDecider, ExhaustiveSearchNode,
119        ExhaustiveSearchPhase, ExplorationType, FixedOffsetBounder, MoveSequence, ScoreBounder,
120        SimpleDecider, SoftScoreBounder,
121    },
122    localsearch::{
123        AcceptedCountForager, Acceptor, BestScoreForager, DiversifiedLateAcceptanceAcceptor,
124        FirstAcceptedForager, FirstBestScoreImprovingForager, FirstLastStepScoreImprovingForager,
125        GreatDelugeAcceptor, HardRegressionPolicy, HillClimbingAcceptor, LateAcceptanceAcceptor,
126        LocalSearchForager, LocalSearchPhase, SimulatedAnnealingAcceptor,
127        SimulatedAnnealingCalibration, StepCountingHillClimbingAcceptor, TabuSearchAcceptor,
128    },
129    partitioned::{
130        ChildPhases, FunctionalPartitioner, PartitionedSearchConfig, PartitionedSearchPhase,
131        SolutionPartitioner, ThreadCount,
132    },
133    sequence::PhaseSequence,
134    vnd::VndPhase,
135    Phase,
136};
137pub use planning::{
138    ConflictRepair, RepairCandidate, RepairLimits, RepairProvider, ScalarCandidate,
139    ScalarCandidateProvider, ScalarEdit, ScalarGroup, ScalarGroupLimits, ScalarTarget,
140};
141pub use run::{log_solve_start, run_solver, run_solver_with_config};
142pub use runtime::{ListVariableEntity, ListVariableMetadata};
143pub use scope::{PhaseScope, SolverScope, StepScope};
144pub use solver::{MaybeTermination, NoTermination, SolveResult, Solver};
145pub use stats::{PhaseStats, SelectorTelemetry, SolverStats, SolverTelemetry};
146pub use termination::{
147    AndTermination, BestScoreFeasibleTermination, BestScoreTermination,
148    DiminishedReturnsTermination, MoveCountTermination, OrTermination,
149    ScoreCalculationCountTermination, StepCountTermination, Termination, TimeTermination,
150    UnimprovedStepCountTermination, UnimprovedTimeTermination,
151};