Struct sudoku_variants::solver::strategy::impls::BoundedOptionsBacktrackingStrategy [−][src]
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
impl<FO, FA, S> BoundedOptionsBacktrackingStrategy<FO, FA, S> where
FO: Fn(usize) -> usize,
FA: Fn(usize) -> Option<usize>,
S: Strategy,
[src]
FO: Fn(usize) -> usize,
FA: Fn(usize) -> Option<usize>,
S: Strategy,
pub fn new(
max_options_computer: FO,
max_applications_computer: FA,
continuation_strategy: S
) -> BoundedOptionsBacktrackingStrategy<FO, FA, S>
[src]
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 returnNone
.continuation_strategy
: The Strategy with which each considered option is developed to find any inferences.
Trait Implementations
impl<FO: Clone, FA: Clone, S: Clone> Clone for BoundedOptionsBacktrackingStrategy<FO, FA, S> where
FO: Fn(usize) -> usize,
FA: Fn(usize) -> Option<usize>,
S: Strategy,
[src]
FO: Fn(usize) -> usize,
FA: Fn(usize) -> Option<usize>,
S: Strategy,
fn clone(&self) -> BoundedOptionsBacktrackingStrategy<FO, FA, S>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<FO, FA, S> Strategy for BoundedOptionsBacktrackingStrategy<FO, FA, S> where
FO: Fn(usize) -> usize,
FA: Fn(usize) -> Option<usize>,
S: Strategy,
[src]
FO: Fn(usize) -> usize,
FA: Fn(usize) -> Option<usize>,
S: Strategy,
fn apply(&self, sudoku_info: &mut SudokuInfo<impl Constraint + Clone>) -> bool
[src]
Auto Trait Implementations
impl<FO, FA, S> RefUnwindSafe for BoundedOptionsBacktrackingStrategy<FO, FA, S> where
FA: RefUnwindSafe,
FO: RefUnwindSafe,
S: RefUnwindSafe,
FA: RefUnwindSafe,
FO: RefUnwindSafe,
S: RefUnwindSafe,
impl<FO, FA, S> Send for BoundedOptionsBacktrackingStrategy<FO, FA, S> where
FA: Send,
FO: Send,
S: Send,
FA: Send,
FO: Send,
S: Send,
impl<FO, FA, S> Sync for BoundedOptionsBacktrackingStrategy<FO, FA, S> where
FA: Sync,
FO: Sync,
S: Sync,
FA: Sync,
FO: Sync,
S: Sync,
impl<FO, FA, S> Unpin for BoundedOptionsBacktrackingStrategy<FO, FA, S> where
FA: Unpin,
FO: Unpin,
S: Unpin,
FA: Unpin,
FO: Unpin,
S: Unpin,
impl<FO, FA, S> UnwindSafe for BoundedOptionsBacktrackingStrategy<FO, FA, S> where
FA: UnwindSafe,
FO: UnwindSafe,
S: UnwindSafe,
FA: UnwindSafe,
FO: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,