Solver

Struct Solver 

Source
pub struct Solver<State: SolverState = Init> { /* 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_cp_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_cp_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 Solver

Source

pub fn new<A: SolverAdaptor>(solver_adaptor: A) -> Solver

Source

pub fn get_family(&self) -> SolverFamily

Source

pub fn get_name(&self) -> &'static str

Source§

impl Solver<Init>

Source§

impl Solver<ModelLoaded>

Source

pub fn solve( self, callback: SolverCallback, ) -> Result<Solver<ExecutionSuccess>, SolverError>

Source

pub fn solve_mut( self, callback: SolverMutCallback, ) -> Result<Solver<ExecutionSuccess>, SolverError>

Source

pub fn write_solver_input_file( &self, writer: &mut Box<dyn 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 Solver<ExecutionSuccess>

Source

pub fn stats(&self) -> SolverStats

Source

pub fn save_stats_to_context(&self)

Source

pub fn wall_time_s(&self) -> f64

Auto Trait Implementations§

§

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

§

impl<State = Init> !RefUnwindSafe for Solver<State>

§

impl<State = Init> !Send for Solver<State>

§

impl<State = Init> !Sync for Solver<State>

§

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

§

impl<State = Init> !UnwindSafe for Solver<State>

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.

§

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.

§

impl<T, A> IntoAst<A> for T
where T: Into<A>, A: Ast,

§

fn into_ast(self, _a: &A) -> A

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

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.