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
impl Solver
Sourcepub fn new(
cmd: Command,
input: InputVia,
output: OutputVia,
signature: &'static str,
) -> Self
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_clearwas 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.
Sourcepub fn new_default(cmd: Command, signature: &'static str) -> Self
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<'a> Extend<&'a Clause> for Solver
impl<'a> Extend<&'a Clause> for Solver
Source§fn extend<T: IntoIterator<Item = &'a Clause>>(&mut self, iter: T)
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)
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)
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
impl Extend<Clause> for Solver
Source§fn extend<T: IntoIterator<Item = Clause>>(&mut self, iter: T)
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)
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)
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
impl Solve for Solver
Source§fn solve(&mut self) -> Result<SolverResult>
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>
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<()>
fn add_clause_ref<C>(&mut self, clause: &C) -> 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. Read more
Source§fn solution(&self, high_var: Var) -> Result<Assignment>
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<()>
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<()>
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>
fn var_val(&self, var: Var) -> Result<TernaryVal>
Same as
Solve::lit_val, but for variables. Read moreSource§fn add_unit(&mut self, lit: Lit) -> Result<()>
fn add_unit(&mut self, lit: Lit) -> Result<()>
Like
Solve::add_clause but for unit clauses (clauses with one literal). Read moreSource§fn add_binary(&mut self, lit1: Lit, lit2: Lit) -> Result<()>
fn add_binary(&mut self, lit1: Lit, lit2: Lit) -> Result<()>
Like
Solve::add_clause but for clauses with two literals. Read moreSource§fn add_ternary(&mut self, lit1: Lit, lit2: Lit, lit3: Lit) -> Result<()>
fn add_ternary(&mut self, lit1: Lit, lit2: Lit, lit3: Lit) -> Result<()>
Like
Solve::add_clause but for clauses with three literals. Read moreAuto 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> 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
Mutably borrows from an owned value. Read more
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>
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 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>
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