pub struct BoundedOptionsBacktrackingStrategy<FO, FA, S>{ /* 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>
impl<FO, FA, S> BoundedOptionsBacktrackingStrategy<FO, FA, S>
Sourcepub fn new(
max_options_computer: FO,
max_applications_computer: FA,
continuation_strategy: S,
) -> BoundedOptionsBacktrackingStrategy<FO, FA, S>
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 returnNone
.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>
impl<FO, FA, S> Clone for BoundedOptionsBacktrackingStrategy<FO, FA, S>
Source§fn clone(&self) -> BoundedOptionsBacktrackingStrategy<FO, FA, S>
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<FO, FA, S> Strategy for BoundedOptionsBacktrackingStrategy<FO, FA, S>
impl<FO, FA, S> Strategy for BoundedOptionsBacktrackingStrategy<FO, FA, S>
Source§fn apply(&self, sudoku_info: &mut SudokuInfo<impl Constraint + Clone>) -> bool
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 moreAuto Trait Implementations§
impl<FO, FA, S> Freeze for BoundedOptionsBacktrackingStrategy<FO, FA, S>
impl<FO, FA, S> RefUnwindSafe for BoundedOptionsBacktrackingStrategy<FO, FA, S>
impl<FO, FA, S> Send for BoundedOptionsBacktrackingStrategy<FO, FA, S>
impl<FO, FA, S> Sync for BoundedOptionsBacktrackingStrategy<FO, FA, S>
impl<FO, FA, S> Unpin for BoundedOptionsBacktrackingStrategy<FO, FA, S>
impl<FO, FA, S> UnwindSafe for BoundedOptionsBacktrackingStrategy<FO, FA, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more