Struct BoundedOptionsBacktrackingStrategy

Source
pub struct BoundedOptionsBacktrackingStrategy<FO, FA, S>
where FO: Fn(usize) -> usize, FA: Fn(usize) -> Option<usize>, S: Strategy,
{ /* private fields */ }
Expand description

A Strategy which looks for cells with few options (up to a specified maximum) and tries all of them. It then uses a wrapped strategy to find deductions in all paths. If any of those deductions hold for all options, they are stored in the metadata.

As an example, consider the following situation.

╔═══╤═══╤═══╦═══╤═══╤═══╦═══╤═══╤═══╗
║ 1 │ A │ 2 ║ 3 │ 4 │ 5 ║ 6 │ B │ 7 ║
╟───┼───┼───╫───┼───┼───╫───┼───┼───╢
║   │   │   ║   │   │   ║   │   │   ║
╟───┼───┼───╫───┼───┼───╫───┼───┼───╢
║   │   │   ║   │   │   ║   │   │   ║
╠═══╪═══╪═══╬═══╪═══╪═══╬═══╪═══╪═══╣
║ 2 │ 3 │ C ║   │   │   ║   │ Z │   ║
╟───┼───┼───╫───┼───┼───╫───┼───┼───╢
║ 4 │   │ 1 ║   │   │   ║   │   │   ║
╟───┼───┼───╫───┼───┼───╫───┼───┼───╢
║ 5 │ 6 │ 7 ║   │   │   ║   │   │   ║
╠═══╪═══╪═══╬═══╪═══╪═══╬═══╪═══╪═══╣
║   │   │   ║   │   │   ║   │   │   ║
╟───┼───┼───╫───┼───┼───╫───┼───┼───╢
║   │   │   ║   │   │   ║   │   │   ║
╟───┼───┼───╫───┼───┼───╫───┼───┼───╢
║   │   │   ║   │   │   ║   │   │   ║
╚═══╧═══╧═══╩═══╧═══╧═══╩═══╧═══╧═══╝

In this case, if A is an 8, then B must be a 9 by the OnlyCellStrategy, so Z cannot be a 9. If A is a 9, then C must be a 9 by the same strategy, and consequently Z cannot be a 9 aswell. So, this strategy with an options bound of at least 2 (since A can be 8 or 9), an OnlyCellStrategy as the continuation strategy, and at least 1 application, can conclude that Z cannot be a 9.

Implementations§

Source§

impl<FO, FA, S> BoundedOptionsBacktrackingStrategy<FO, FA, S>
where FO: Fn(usize) -> usize, FA: Fn(usize) -> Option<usize>, S: Strategy,

Source

pub fn new( max_options_computer: FO, max_applications_computer: FA, continuation_strategy: S, ) -> BoundedOptionsBacktrackingStrategy<FO, FA, S>

Creates a new bounded options backtracking strategy.

§Arguments
  • max_options_computer: A closure that, given the grid size, computes the maximum number of options that may be present in a cell for this strategy to consider all of them.
  • max_applications_computer: A closure that, given the grid size, computes the maximum number of times the continuation strategy may be applied for each considered option before no further inference is done. If no limit is desired, this may return None.
  • continuation_strategy: The Strategy with which each considered option is developed to find any inferences.

Trait Implementations§

Source§

impl<FO, FA, S> Clone for BoundedOptionsBacktrackingStrategy<FO, FA, S>
where FO: Fn(usize) -> usize + Clone, FA: Fn(usize) -> Option<usize> + Clone, S: Strategy + Clone,

Source§

fn clone(&self) -> BoundedOptionsBacktrackingStrategy<FO, FA, S>

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

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

Performs copy-assignment from source. Read more
Source§

impl<FO, FA, S> Strategy for BoundedOptionsBacktrackingStrategy<FO, FA, S>
where FO: Fn(usize) -> usize, FA: Fn(usize) -> Option<usize>, S: Strategy,

Source§

fn apply(&self, sudoku_info: &mut SudokuInfo<impl Constraint + Clone>) -> bool

Applies this strategy to the given Sudoku. The strategy may rely on and modify the information in the given sudoku_info. This instance is given to other strategies that participate in the solution and/or future iterations of the same strategy. It can thus be used to communicate insights. Read more

Auto Trait Implementations§

§

impl<FO, FA, S> Freeze for BoundedOptionsBacktrackingStrategy<FO, FA, S>
where FO: Freeze, FA: Freeze, S: Freeze,

§

impl<FO, FA, S> RefUnwindSafe for BoundedOptionsBacktrackingStrategy<FO, FA, S>

§

impl<FO, FA, S> Send for BoundedOptionsBacktrackingStrategy<FO, FA, S>
where FO: Send, FA: Send, S: Send,

§

impl<FO, FA, S> Sync for BoundedOptionsBacktrackingStrategy<FO, FA, S>
where FO: Sync, FA: Sync, S: Sync,

§

impl<FO, FA, S> Unpin for BoundedOptionsBacktrackingStrategy<FO, FA, S>
where FO: Unpin, FA: Unpin, S: Unpin,

§

impl<FO, FA, S> UnwindSafe for BoundedOptionsBacktrackingStrategy<FO, FA, S>
where FO: UnwindSafe, FA: UnwindSafe, S: 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> 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> 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.
Source§

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

Source§

fn vzip(self) -> V