Struct Solver

Source
pub struct Solver { /* private fields */ }
Expand description

A solver called via an external executable

This solver will perform a call to the solver executable via Command and parse the solver output via fio::parse_sat_solver_output

Implementations§

Source§

impl Solver

Source

pub fn new( cmd: Command, input: InputVia, output: OutputVia, signature: &'static str, ) -> Self

Initializes a solver with a Command that is fully set up, except for the input instance

§Notes
  • If input is passed via a file with a path that ends in a compression extension, RustSAT will write a compressed file
  • If the solver output is processed via a file, compression is not supported
  • If Command::env_clear was called on the command and the input is passed via a file as the first argument, the fact that the environment has been cleared might be forgotten
§Example
use std::process::Command;
use rustsat::solvers::{ExternalSolver, external};
let solver = ExternalSolver::new(
    Command::new("<path to solver binary>"),
    external::InputVia::tempfile_last(),
    external::OutputVia::pipe(),
    "solver-signature",
);

After this initialization, the solver instance can be used with the Solve trait.

Source

pub fn new_default(cmd: Command, signature: &'static str) -> Self

Initializes a solver with default values for InputVia and OutputVia

The default values are passing the input via a temporary file and processing the output via a pipe.

§Example
use std::process::Command;
use rustsat::solvers::{ExternalSolver, external};
let solver = ExternalSolver::new_default(
    Command::new("<path to solver binary>"),
    "solver-signature",
);

After this initialization, the solver instance can be used with the Solve trait.

Trait Implementations§

Source§

impl Debug for Solver

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Extend<&'a Clause> for Solver

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 Solver

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 Solve for Solver

Source§

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

Gets a signature of the solver implementation
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<C>(&mut self, clause: &C) -> Result<()>
where C: AsRef<Cl> + ?Sized,

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. Read more
Source§

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

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

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

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 reserve(&mut self, _max_var: Var) -> Result<()>

Reserves memory in the solver until a maximum variables, if the solver supports it Read more
Source§

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

Same as Solve::lit_val, but for variables. Read more
Source§

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

Like Solve::add_clause but for unit clauses (clauses with one literal). Read more
Source§

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

Like Solve::add_clause but for clauses with two literals. Read more
Source§

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

Like Solve::add_clause but for clauses with three literals. Read more
Source§

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

Adds all clauses from a Cnf instance. Read more
Source§

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

Adds all clauses from a Cnf instance by reference. Read more

Auto Trait Implementations§

§

impl Freeze for Solver

§

impl !RefUnwindSafe for Solver

§

impl Send for Solver

§

impl Sync for Solver

§

impl Unpin for Solver

§

impl !UnwindSafe for Solver

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<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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

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

Source§

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>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V