Skip to main content

Crate csp_solver

Crate csp_solver 

Source
Expand description

A generalized CSP (Constraint Satisfaction Problem) solver.

This is the sole solver in the workspace. Supports:

  • Backtracking search with configurable pruning and variable ordering
  • AC-3 (Maintaining Arc Consistency) propagation
  • Forward checking and the AC-FC hybrid
  • GAC all-different (Régin 1994), default-ON
  • Lattice domains for monotonic fixed-point propagation

The optional PyO3 (feature = "py") and wasm bindings expose this same core to Python and JavaScript — they wrap it, they do not mirror a separate implementation.

The crate-root surface is assembled from three internal modules: [config] (solve vocabulary + the Csp<D> container), [csp] (the builder methods), and [csp::solve] (propagation + search dispatch).

Re-exports§

pub use builder::assignment::AssignmentBuilder;
pub use builder::assignment::AssignmentError;
pub use builder::assignment::AssignmentSolution;
pub use builder::assignment::SENTINEL;
pub use builder::assignment::assignment;
pub use cancel::CancelToken;
pub use error::CspError;
pub use puzzles::sudoku;

Modules§

builder
Fluent builders for common CSP / COP shapes.
cancel
Cooperative cancellation token.
constraint
Constraint trait, built-in implementations, and devirtualized dispatch.
domain
Domain trait and built-in implementations.
error
Unified error family for the solver’s public API surface.
ordering
Variable ordering heuristics.
puzzles
Domain-specific puzzle modules.
solver
Solver dispatch: AC-3 propagation, forward checking, and the unified monomorphized search kernel.
variable
CSP variable with domain tracking and pruned-value undo log.

Structs§

Csp
The main CSP solver struct.
SolveConfig
Solve configuration, isomorphic to Python’s CSP constructor arguments.
SolveStats
Solver statistics.
Unsatisfiable
Error type for unsatisfiable constraints.

Enums§

OptimizationMode
Optimization mode for the solver.
PropagationStrategy
Propagation strategy for propagate_with().
Pruning
Pruning strategy for backtracking search.