Struct Solver

Source
pub struct Solver<A, State = Init>
where A: SolverAdaptor, State: SolverState,
{ /* private fields */ }
Expand description

An abstract representation of a constraints solver.

Solver provides a common interface for interacting with a constraint solver. It also abstracts over solver-specific datatypes, handling the translation to/from conjure_core::ast types for a model and its solutions.

Details of how a model is solved is specified by the SolverAdaptor. This includes: the underlying solver used, the translation of the model to a solver compatible form, how solutions are translated back to conjure_core::ast types, and how incremental solving is implemented. As such, there may be multiple SolverAdaptor implementations for a single underlying solver: e.g. one adaptor may give solutions in a representation close to the solvers, while another may attempt to rewrite it back into Essence.

Implementations§

Source§

impl<Adaptor> Solver<Adaptor>
where Adaptor: SolverAdaptor,

Source

pub fn new(solver_adaptor: Adaptor) -> Solver<Adaptor>

Source

pub fn get_family(&self) -> SolverFamily

Source§

impl<A> Solver<A>
where A: SolverAdaptor,

Source

pub fn load_model( self, model: Model, ) -> Result<Solver<A, ModelLoaded>, SolverError>

Source§

impl<A> Solver<A, ModelLoaded>
where A: SolverAdaptor,

Source

pub fn solve( self, callback: Box<dyn Fn(HashMap<Name, Literal>) -> bool + Send>, ) -> Result<Solver<A, ExecutionSuccess>, SolverError>

Source

pub fn solve_mut( self, callback: Box<dyn Fn(HashMap<Name, Literal>, Box<dyn ModelModifier>) -> bool + Send>, ) -> Result<Solver<A, ExecutionSuccess>, SolverError>

Source

pub fn write_solver_input_file( &self, writer: &mut impl Write, ) -> Result<(), Error>

Writes a solver input file to the given writer.

This method is for debugging use only, and there are no plans to make the solutions obtained by running this file through the solver translatable back into high-level Essence.

This file is runnable using the solvers command line interface. E.g. for Minion, this outputs a valid .minion file.

This function is only available in the ModelLoaded state as solvers are allowed to edit the model in place.

Source§

impl<A> Solver<A, ExecutionSuccess>
where A: SolverAdaptor,

Source

pub fn stats(&self) -> SolverStats

Source

pub fn save_stats_to_context(&self)

Source

pub fn wall_time_s(&self) -> f64

Trait Implementations§

Source§

impl<A, State> Clone for Solver<A, State>
where A: Clone + SolverAdaptor, State: Clone + SolverState,

Source§

fn clone(&self) -> Solver<A, State>

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<A, State> Freeze for Solver<A, State>
where State: Freeze, A: Freeze,

§

impl<A, State> RefUnwindSafe for Solver<A, State>
where State: RefUnwindSafe, A: RefUnwindSafe,

§

impl<A, State> Send for Solver<A, State>
where State: Send, A: Send,

§

impl<A, State> Sync for Solver<A, State>
where State: Sync, A: Sync,

§

impl<A, State> Unpin for Solver<A, State>
where State: Unpin, A: Unpin,

§

impl<A, State> UnwindSafe for Solver<A, State>
where State: UnwindSafe, A: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more

Layout§

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.