Struct rustsat_kissat::Kissat

source ·
pub struct Kissat<'term> { /* private fields */ }
Expand description

The Kissat solver type

Implementations§

source§

impl Kissat<'_>

source

pub fn commit_id() -> &'static str

Gets the commit ID that Kissat was built from

source

pub fn version() -> &'static str

Gets the Kissat version

source

pub fn compiler() -> &'static str

Gets the compiler Kissat was built with

source

pub fn set_configuration(&mut self, config: Config) -> Result<()>

Sets a pre-defined configuration for Kissat’s internal options

source

pub fn set_option(&mut self, name: &str, value: c_int) -> Result<()>

Sets the value of a Kissat option. For possible options, check Kissat with kissat --help. Requires state SolverState::Configuring.

source

pub fn get_option(&self, name: &str) -> Result<c_int>

Gets the value of a Kissat option. For possible options, check Kissat with kissat --help.

source

pub fn set_limit(&mut self, limit: Limit)

Sets an internal limit for Kissat

source

pub fn print_stats(&self)

Prints the solver statistics from the Kissat backend

Trait Implementations§

source§

impl Default for Kissat<'_>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Drop for Kissat<'_>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<'a> Extend<&'a Clause> for Kissat<'_>

source§

fn extend<T: IntoIterator<Item = &'a Clause>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl Extend<Clause> for Kissat<'_>

source§

fn extend<T: IntoIterator<Item = Clause>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl Interrupt for Kissat<'_>

§

type Interrupter = Interrupter

The interrupter of the solver
source§

fn interrupter(&mut self) -> Self::Interrupter

Gets a thread safe interrupter object that can be used to terminate the solver
source§

impl Solve for Kissat<'_>

source§

fn signature(&self) -> &'static str

Gets a signature of the solver implementation
source§

fn reserve(&mut self, max_var: Var) -> Result<()>

Reserves memory in the solver until a maximum variables, if the solver supports it
source§

fn solve(&mut self) -> Result<SolverResult>

Solves the internal CNF formula without any assumptions. Read more
source§

fn lit_val(&self, lit: Lit) -> Result<TernaryVal>

Gets an assignment of a variable in the solver. Read more
source§

fn add_clause_ref(&mut self, clause: &Clause) -> Result<()>

Adds a clause to the solver by reference. If the solver is in the satisfied or unsatisfied state before, it is in the input state afterwards.
source§

fn solution(&self, high_var: Var) -> Result<Assignment, Error>

Gets a solution found by the solver up to a specified highest variable. Read more
source§

fn full_solution(&self) -> Result<Assignment, Error>
where Self: SolveStats,

Gets a solution found by the solver up to the highest variable known to the solver. Read more
source§

fn var_val(&self, var: Var) -> Result<TernaryVal, Error>

Same as Solve::lit_val, but for variables.
source§

fn add_clause(&mut self, clause: Clause) -> Result<(), Error>

Adds a clause to the solver. If the solver is in the satisfied or unsatisfied state before, it is in the input state afterwards. Read more
source§

fn add_unit(&mut self, lit: Lit) -> Result<(), Error>

Like Solve::add_clause but for unit clauses (clauses with one literal).
source§

fn add_binary(&mut self, lit1: Lit, lit2: Lit) -> Result<(), Error>

Like Solve::add_clause but for clauses with two literals.
source§

fn add_ternary(&mut self, lit1: Lit, lit2: Lit, lit3: Lit) -> Result<(), Error>

Like Solve::add_clause but for clauses with three literals.
source§

fn add_cnf(&mut self, cnf: Cnf) -> Result<(), Error>

Adds all clauses from a Cnf instance.
source§

fn add_cnf_ref(&mut self, cnf: &Cnf) -> Result<(), Error>

Adds all clauses from a Cnf instance by reference.
source§

impl SolveStats for Kissat<'_>

source§

fn stats(&self) -> SolverStats

Gets the available statistics from the solver
source§

fn n_sat_solves(&self) -> usize

Gets the number of satisfiable queries executed.
source§

fn n_unsat_solves(&self) -> usize

Gets the number of unsatisfiable queries executed.
source§

fn n_terminated(&self) -> usize

Gets the number of queries that were prematurely terminated.
source§

fn n_solves(&self) -> usize

Gets the total number of queries executed.
source§

fn n_clauses(&self) -> usize

Gets the number of clauses in the solver.
source§

fn max_var(&self) -> Option<Var>

Gets the variable with the highest index in the solver, if any. If all variables below have been used, the index of this variable +1 is the number of variables in the solver.
source§

fn n_vars(&self) -> usize

Get number of variables. Note: this is only correct if all variables are used in order!
source§

fn avg_clause_len(&self) -> f32

Gets the average length of all clauses in the solver.
source§

fn cpu_solve_time(&self) -> Duration

Gets the total CPU time spent solving.
source§

impl<'term> Terminate<'term> for Kissat<'term>

source§

fn attach_terminator<CB>(&mut self, cb: CB)
where CB: FnMut() -> ControlSignal + 'term,

Sets a terminator callback that is regularly called during solving.

§Examples

Terminate solver after 10 callback calls.

use rustsat::solvers::{ControlSignal, Solve, SolverResult, Terminate};
use rustsat_kissat::Kissat;

let mut solver = Kissat::default();

// Load instance

let mut cnt = 1;
solver.attach_terminator(move || {
    if cnt > 10 {
        ControlSignal::Terminate
    } else {
        cnt += 1;
        ControlSignal::Continue
    }
});

let ret = solver.solve().unwrap();

// Assuming an instance is actually loaded and runs long enough
// assert_eq!(ret, SolverResult::Interrupted);
source§

fn detach_terminator(&mut self)

Detaches the terminator
source§

impl Send for Kissat<'_>

Auto Trait Implementations§

§

impl<'term> Freeze for Kissat<'term>

§

impl<'term> !RefUnwindSafe for Kissat<'term>

§

impl<'term> !Sync for Kissat<'term>

§

impl<'term> Unpin for Kissat<'term>

§

impl<'term> !UnwindSafe for Kissat<'term>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<S> CollectClauses for S
where S: Solve + SolveStats,

source§

fn n_clauses(&self) -> usize

Gets the number of clauses in the collection
source§

fn extend_clauses<T>(&mut self, cl_iter: T) -> Result<(), OutOfMemory>
where T: IntoIterator<Item = Clause>,

Extends the clause collector with an iterator of clauses Read more
source§

fn add_clause(&mut self, cl: Clause) -> Result<(), OutOfMemory>

Adds one clause to the collector
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.