Expand description
Unified monomorphized search kernel.
Tests: tests/solver.rs (general solve correctness),
tests/solution_set_invariance.rs (solution-set property test).
One tree-search skeleton — [search] — parameterized by a zero-sized
[SearchPolicy]. The policy decides the four things that actually differ
between the crate’s search modes:
| axis | [Feasibility] | [BranchBound] |
|---|---|---|
| leaf action | record, stop at max | score, keep best, never stop |
| node prune | none | optimistic-bound cutoff |
| value order | raw domain order | cost-sorted |
Every hook is #[inline] and every implementor is (near) zero-sized, so
monomorphization inlines the whole policy — no dispatch cost, the same
devirtualization the crate already applies to ConstraintEnum.
This kernel replaces the three near-verbatim recursive DFS functions that
preceded it (backtrack_recurse, backjump_recurse, bb_recurse) whose
propagate match, validity-check loop, and restore sweep were byte-identical.
Undo now runs off the shared [Trail] (touched-variable list) rather than an
O(num_vars) per-node sweep, and read-only state (weights, var_cids,
adjacency) is borrowed rather than deep-cloned per solve.
Structs§
- Search
Params - Shared, immutable search parameters. Collapses the three former per-mode
config structs (
BacktrackConfig/BackjumpConfig/OptimizeConfig), which differed only in amaximizebool and each carried its own cloned copy ofconstraint_weights+var_constraint_ids. Those read-only vectors are now borrowed by the kernel, so they live nowhere in this struct.
Constants§
- PERMANENT_
DEPTH - Depth reserved for permanent pre-search propagation (root AC-3, given-cell
propagation). Search recursion begins at [
SEARCH_ROOT_DEPTH] so its depth-keyed undo can never target these permanent reductions — fixing the depth-0 seam where the first failed root candidate un-pruned the initial AC-3 viarestore(0).
Functions§
- branch_
and_ bound - Run branch-and-bound optimization. Returns up to
max_solutionssolutions, sorted best-first per the optimization direction. - feasibility_
search - Run feasibility (satisfaction) search.
givenpre-seeds an assignment and filters the branch stack;Nonesearches all variables from scratch.