Skip to main content

Solver

Struct Solver 

Source
pub struct Solver<S, St = UNKNOWN>
where S: Search, St: SolverState,
{ pub(crate) pre_processor: Vec<Box<dyn Pass>>, pub(crate) in_processor: Vec<Box<dyn Pass>>, pub(crate) search: S, pub(crate) kernel: Kernel, pub(crate) _state: PhantomData<St>, }
Expand description

主求解器对象。

组件说明:

  • pre_processor:搜索前执行;
  • in_processor:搜索循环中周期执行;
  • search:CDCL 核心;
  • kernel:统一状态与数据。

Fields§

§pre_processor: Vec<Box<dyn Pass>>§in_processor: Vec<Box<dyn Pass>>§search: S§kernel: Kernel§_state: PhantomData<St>

Implementations§

Source§

impl<S, St> Solver<S, St>
where S: Search, St: SolverState,

Source

pub const fn status(&self) -> SolverStatus

返回编译期状态对应的运行时枚举。

Source

pub fn kernel(&self) -> &Kernel

只读访问内核。

Source

pub(crate) fn into_state<Next>(self) -> Solver<S, Next>
where Next: SolverState,

Source§

impl<S> Solver<S, UNKNOWN>
where S: Search,

Source

pub fn new(search: S, kernel: Kernel) -> Self

创建处于 UNKNOWN 状态的求解器。

Source

pub fn add_preprocess_pass(&mut self, pass: impl Pass + 'static)

注册一个预处理 Pass。

Source

pub fn arrange_preprocess_passes(&mut self, ordered: &str)

按逗号分隔短名重排预处理 Pass。

Source

pub fn add_inprocess_pass(&mut self, pass: impl Pass + 'static)

注册一个搜索中 Pass。

Source

pub fn arrange_inprocess_passes(&mut self, ordered: &str)

按逗号分隔短名重排搜索中 Pass。

Source

pub fn solve(self) -> SolveResult<S>

执行完整求解流程并返回分型结果。

主要顺序:

  1. 先跑预处理,若可直接判定则提前返回;
  2. 进入 SOLVING 状态,执行 CDCL 搜索;
  3. 按最终结果转移到 SAT/UNSAT/UNKNOWN 状态。
Source

pub(crate) fn arrange_passes(passes: &mut Vec<Box<dyn Pass>>, ordered: &str)

根据短名称重排 Pass,未出现在 ordered 中的 Pass 会被丢弃。

Source§

impl<S> Solver<S, SAT>
where S: Search,

Source

pub fn model(&self) -> Vec<bool>

导出模型(索引 0 保留,不对应实际变量)。

Source

pub fn check_sat(&self) -> Result<(), String>

用当前模型逐子句校验 SAT 结果。

Source

pub fn print_model(&self)

按 DIMACS 竞赛风格打印模型。

Auto Trait Implementations§

§

impl<S, St> Freeze for Solver<S, St>
where S: Freeze,

§

impl<S, St = UNKNOWN> !RefUnwindSafe for Solver<S, St>

§

impl<S, St = UNKNOWN> !Send for Solver<S, St>

§

impl<S, St = UNKNOWN> !Sync for Solver<S, St>

§

impl<S, St> Unpin for Solver<S, St>
where S: Unpin, St: Unpin,

§

impl<S, St> UnsafeUnpin for Solver<S, St>
where S: UnsafeUnpin,

§

impl<S, St = UNKNOWN> !UnwindSafe for Solver<S, St>

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.

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