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.
§Hint
The only data parsed from the solvers output are the s and v lines specifying the
result and solution. When using a pipe for the solver output, it is therefore recommended
to make the solver output as little information as possible (via a --quiet flag or
similar) to reduce the amount of text RustSAT has to process.
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.
§Hint
The only data parsed from the solvers output are the s and v lines specifying the
result and solution, it is therefore recommended to make the solver output as little
information as possible (via a --quiet flag or similar) to reduce the amount of text
RustSAT has to process.
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)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)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)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Solve for Solver
impl Solve for Solver
Source§fn solve(&mut self) -> Result<SolverResult>
fn solve(&mut self) -> Result<SolverResult>
Source§fn lit_val(&self, lit: Lit) -> Result<TernaryVal>
fn lit_val(&self, lit: Lit) -> Result<TernaryVal>
Source§fn add_clause_ref<C>(&mut self, clause: &C) -> Result<()>
fn add_clause_ref<C>(&mut self, clause: &C) -> Result<()>
Source§fn solution(&self, high_var: Var) -> Result<Assignment>
fn solution(&self, high_var: Var) -> Result<Assignment>
Source§fn add_clause(&mut self, clause: Clause) -> Result<()>
fn add_clause(&mut self, clause: Clause) -> Result<()>
Source§fn reserve(&mut self, _max_var: Var) -> Result<()>
fn reserve(&mut self, _max_var: Var) -> Result<()>
Source§fn var_val(&self, var: Var) -> Result<TernaryVal>
fn var_val(&self, var: Var) -> Result<TernaryVal>
Solve::lit_val, but for variables. Read moreSource§fn add_unit(&mut self, lit: Lit) -> Result<()>
fn add_unit(&mut self, lit: Lit) -> Result<()>
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<()>
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<()>
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
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