pub struct Solver { /* private fields */ }Expand description
CDCL SAT Solver
Implementations§
Source§impl Solver
impl Solver
Sourcepub fn with_config(config: SolverConfig) -> Self
pub fn with_config(config: SolverConfig) -> Self
Create a new solver with configuration
Sourcepub fn ensure_vars(&mut self, n: usize)
pub fn ensure_vars(&mut self, n: usize)
Ensure we have at least n variables
Sourcepub fn add_clause(&mut self, lits: impl IntoIterator<Item = Lit>) -> bool
pub fn add_clause(&mut self, lits: impl IntoIterator<Item = Lit>) -> bool
Add a clause
Sourcepub fn add_clause_dimacs(&mut self, lits: &[i32]) -> bool
pub fn add_clause_dimacs(&mut self, lits: &[i32]) -> bool
Add a clause from DIMACS literals
Sourcepub fn solve(&mut self) -> SolverResult
pub fn solve(&mut self) -> SolverResult
Solve the SAT problem
Sourcepub fn solve_with_assumptions(
&mut self,
assumptions: &[Lit],
) -> (SolverResult, Option<Vec<Lit>>)
pub fn solve_with_assumptions( &mut self, assumptions: &[Lit], ) -> (SolverResult, Option<Vec<Lit>>)
Solve with assumptions and return unsat core if UNSAT
This is the key method for MaxSAT: it solves under assumptions and if the result is UNSAT, returns the subset of assumptions in the core.
§Arguments
assumptions- Literals that must be true
§Returns
(SolverResult, Option<Vec<Lit>>)- Result and unsat core (if UNSAT)
Sourcepub fn solve_with_theory<T: TheoryCallback>(
&mut self,
theory: &mut T,
) -> SolverResult
pub fn solve_with_theory<T: TheoryCallback>( &mut self, theory: &mut T, ) -> SolverResult
Solve with theory integration via callbacks
This implements the CDCL(T) loop:
- BCP (Boolean Constraint Propagation)
- Theory propagation (via callback)
- On conflict: analyze and learn
- Decision
- Final theory check when all vars assigned
Sourcepub fn model_value(&self, var: Var) -> LBool
pub fn model_value(&self, var: Var) -> LBool
Get the value of a variable in the model
Sourcepub fn stats(&self) -> &SolverStats
pub fn stats(&self) -> &SolverStats
Get statistics
Sourcepub fn memory_opt_stats(&self) -> &MemoryOptStats
pub fn memory_opt_stats(&self) -> &MemoryOptStats
Get memory optimizer statistics
Sourcepub fn num_clauses(&self) -> usize
pub fn num_clauses(&self) -> usize
Get number of clauses
Sourcepub fn push(&mut self)
pub fn push(&mut self)
Push a new assertion level (for incremental solving)
This saves the current state so that clauses added after this point can be removed with pop(). Automatically backtracks to decision level 0 to ensure a clean state for adding new constraints.
Sourcepub fn backtrack_to_root(&mut self)
pub fn backtrack_to_root(&mut self)
Backtrack to decision level 0 (for AllSAT enumeration)
This is necessary after a SAT result before adding blocking clauses to ensure the new clauses can trigger propagation correctly. Uses phase-saving backtrack to properly re-insert unassigned variables into the decision heaps (VSIDS, CHB, LRB).
Sourcepub fn decision_level(&self) -> u32
pub fn decision_level(&self) -> u32
Get the current decision level
Sourcepub fn debug_print_learned_clauses(&self)
pub fn debug_print_learned_clauses(&self)
Debug method: print all learned clauses
Sourcepub fn debug_print_binary_graph(&self)
pub fn debug_print_binary_graph(&self)
Debug method: print binary implication graph entries
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Solver
impl RefUnwindSafe for Solver
impl Send for Solver
impl Sync for Solver
impl Unpin for Solver
impl UnsafeUnpin for Solver
impl UnwindSafe for Solver
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more