IpasirSolverLoader

Struct IpasirSolverLoader 

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

A structure used to load a shared library and build new SAT solvers from it.

This structure takes as entry point a path to a shared library containing a SAT solver that conform to the IPASIR specification. An IpasirSolverLoader is built by passing this path to the from_path function. This object can be used to create new solvers with the new_solver function.

The IPASIR interface provides two functions that take a function pointer as parameter. To use them on solvers created by this object, these functions must be enabled by calling enable_set_terminate and enable_set_learn before creating the SAT solvers.

§Example

let mut loader = IpasirSolverLoader::from_path("path/to/lib.so").unwrap();
loader.enable_set_terminate(true); // activate ipasir_set_terminate
loader.enable_set_learn(Some(8)); // activate ipasir_set_learn for clause of sizes at most 8
let sat_solver = loader.new_solver().unwrap(); // create the solver

Implementations§

Source§

impl IpasirSolverLoader

Source

pub fn from_path<P: AsRef<OsStr>>(path: P) -> Result<Self>

Builds a new IpasirSolverLoader given a path to a shared library containing a SAT solver that conform to the IPASIR specification.

§Errors

This function returns an error if the library cannot be loaded, e.g. if the path does not point to a shared library.

Source

pub fn ipasir_signature(&self) -> Result<String>

Returns a string describing the name and the version of the library solver.

§Errors

This function returns an error if the library does not include the corresponding IPASIR function, or if an error occurs when calling it.

Source

pub fn new_solver(&self) -> Result<IpasirSolverWrapper>

Builds a new SAT solver from the shared library.

The returned solver can accept callback functions on termination or when learning a clause only if the appropriate activation functions (enable_set_terminate or enable_set_learn) have been called before calling this function.

§Errors

This function returns an error if the library does not contain the ipasir_init function, or if an error occurs when calling it. In case some callback functions are enabled, this function will also return an error if the corresponding IPASIR callback function (ipasir_set_terminate or ipasir_set_learn) is missing from the library or if an error occurs when calling it.

Source

pub fn enable_set_terminate(&mut self, v: bool)

Enables or disables the ipasir_set_terminate for the solvers created after the call to this function.

Source

pub fn enable_set_learn(&mut self, bound: Option<i32>)

Enables or disables the ipasir_set_learn for the solvers created after the call to this function.

To enable the function, pass Some(n) where n is the maximum length of the learned clauses you are interested in. To disable the function, pass None.

Trait Implementations§

Source§

impl AsRef<Library> for IpasirSolverLoader

Source§

fn as_ref(&self) -> &Library

Converts this type into a shared reference of the (usually inferred) input type.

Auto Trait Implementations§

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