Computational disadvantage of preferring bivalue/bilocal cells in T&E
In this post, I'm not speaking of exactly the same thing as tknottet, eleven or Blue's DFS procedure.
Below, T&E always means the procedure I have defined as T&E (which I’ve always considered as the mere formalisation of what players usually mean by T&E and also of Ruud's original definition in Sudopedia - now disappeared):
- it has no guessing (if a tried candidate leads to a solution, the corresponding path is merely forgotten);
- it tries all the candidates at some depth before going deeper;
- it may try candidates at some depth several times so that the result at this depth is independent of the order they are tried (a necessary condition for the procedure being well defined).
I’ve shown years ago that all the known puzzles can be solved at depth 2 (at most) and
Blue has shown that only 1 puzzle in about 30,000,000 requires more than depth 1.
What I compare below is two different strategies for trying all the candidates at some depth: (pseudo) random and bivalue/bilocal first.
Notice that the T&E strategy used has no impact on the resolution state reached at each depth; it can only change the computation times.
As I said above, T&E is very different from ttknottet’s DFS procedure. However, I think the comparisons below about the preference for bivalue/bilocal cells, valid for my T&E definition, should me more or less valid for DFS.
The results below must be taken with some grain of salt:
- they are implementation-dependent (they were obtained with the latest version of SudoRules, based on my general pattern-based CSP-Rules solver)
- they rely on small samples
- my T&E procedure is generic (it works for any CSP) but it is very far from being optimised for Sudoku
- all the timings are relative to the first cell of each table, arbitrarily set to 1
- in the first two samples, many puzzles can be solved without T&E
- the cb collection (controlled-bias) is the closest we can get to a random unbiased one (I didn’t consider worth doing the corrections for the known bias); all the puzzles are in T&E(1)
- the magictour-top234 collection was once considered as the hardest, but that was long ago; it remains among the hardest puzzles solvable by human brains; no puzzle in it can be solved without T&E (i.e. with only the rules in BRT or W1) but almost all are in T&E(1) and all are in gT&E(1)
- the eleven’s-hardest collection is version V2_26370.tx of eleven’s collection of puzzles not in T&E(1, S4) i.e. not solvable by S4-braids; I consider only the first 100, i.e. the hardest; no puzzle is in T&E(1)
For each collection, I used only T&E(T, 1), i.e. no T&E level deeper than 1. It implies that a few puzzles may be only partly solved, but it doesn’t matter for the comparison, as the 2 strategies lead to the same final resolution states (T fixed).
The only exception is eleven’s collection, for which I also tried T&E(T, 2). In this case, all the puzzles are solved.
Notations:
BRT = universal Basic Resolution Theory (= Singles + ECP)
W1 = BRT + whips[1] (= claiming and pointing)
bivalue-first: try first any candidate in a bivalue/bilocal cell
The format for each cell is: mean time - max time (each value is relative to first cell)
- Code: Select all
Rules in T BRT BRT
T&E strategy random bivalue-first
Royle17-1-100 1 - 1 0.96 - 0.91
cb-1-100 1.06 - 1.68 1.02 - 1.64
magictour-top234 6.26 - 13 6.61 - 15
eleven’s-hardest-0-100 (1) 9.07 - 7.18 9.20 - 7.27
eleven’s-hardest-0-100 (2) 73.2 - 144.9 76.7 - 146.3
Comment: there is no significant difference between the two strategies for T&E
Now we add whips[1] to T. The final states are still the same for the 2 strategies, but possibly different from above (closer to solution)
- Code: Select all
Rules in T W1 W1
T&E strategy random bivalue-first
Royle17-1-100 1 - 1 0.95 - 0.6
cb-1-100 1.11 - 1.33 1.07 - 0.94
magictour-top234 10.8 - 19.2 6.26 - 8.9
eleven’s-hardest-0-100 (1) 55 - 34.3 8.4 - 4.2
eleven’s-hardest-0-100 (2) 185.8 - 319.4 591 - 708
Comments:
I was surprised by the results for gT&E = T&E(W1). Preference for the bivalue/bilocal candidates seems to give faster calculations at depth 1 for the hard puzzles (no full solution found at this depth), but slower at depth 2. (I checked the results 3 times.)
For puzzles that can be solved by T&E (almost all the puzzles), using gT&E instead leads to a slower procedure.
For puzzles needing T&E(2), the bivalue strategy is much slower for gT&E(2). It is faster for gT&E(1) (producing only partial results).
Globally, I conclude that the bivalue/bilocal strategy is rarely good, confirming the impression I had when I watched hundreds of resolution paths for hard puzzles: long streaks of whips with no Single in between (in SudoRules, an elimination for a bivalue would be immediately followed by a Single).
I didn't try using only bivalue candidates instead of bivalue/bilocal.