CSP-Rules, SudoRules, KakuRules...

Programs which generate, solve, and analyze Sudoku puzzles

Re: CSP-Rules, SudoRules, KakuRules...

Postby denis_berthier » Fri Aug 25, 2023 1:49 am

.
Today's update on GitHub revolves around function solve-knowing-solution.
It is now compatible with T&E at any level (it was previously designed to work only with resolution rules)

Companion functions have also been added to deal with files of puzzles in the standard line format, with-syntax:
(solve-n-grids-after-first-p-from-text-file-knowing-solutions ?puzzles-file ?solutions-file ?p ?n )
(solve-n-grids-after-first-p-from-text-file-knowing-solutions-excluding ?puzzles-file ?solutions-file ?p ?n ?excluded-list)
[?excluded list is useful if you know some puzzles in the list are e.g. in B4B and you want to check which are in B5B)

This allows to reduce computation times for the T&E-depth of any puzzle or for the BpB rating for puzzles in T&E(2).
Beware that reduction in time is quite varying, between 0 and 50%.
The best improvement I observed was on Hendrik's list of 384 (383 non redundant) hard puzzles, while showing that only 43 are in T&E(3), i.e. the other ones are solved in T&E(2): 50% reduction.
Note: the good point is, the gain seems to be larger for the hardest computations.

Note that, if you need to compute solutions (e.g. by DFS),
(record-solutions-n-grids-after-first-p-from-text-file ?puzzles-file ?p ?n ?solutions-file)
will record them in file ?solutions-file.
Note that only ?n lines will appear in ?solutions-file.
It is supposed that the set of selected rules is enough to solve all the puzzles; otherwise, some lines will be incomplete. Anyway, this function is mainly intended for use with DFS.

Update of the User Manual remains to be done.
.
denis_berthier
2010 Supporter
 
Posts: 3972
Joined: 19 June 2007
Location: Paris

Re: CSP-Rules, SudoRules, KakuRules...

Postby denis_berthier » Tue Oct 10, 2023 6:12 am

.
a SudoRules user wrote:With the new SHC, how to know which of SudoRules or SHC to use?

It's not really a problem. They are based on the same theoretical background but their goals are very different:

1) SudoRules:
- SudoRules has been designed to implement resolution rules in the most straightforward way, based on the technique of pattern-matching (with the secondary benefit that I'm certain it can include no hidden ad hoc pieces of code in addition to the rules themselves: the rules are the code.
This approach has recently allowed me to code ORk-relations deducible from eleven's 630 impossible patterns in a few days only (which no other solver is still able to do after 1+ year).

- SudoRules can mix different types of rules, in almost unlimited combinations: any types of chain rules, Subsets, exotic patterns...

- SudoRules is only a small part of CSP-Rules, which can be applied to any finite CSP. The SHC is Sudoku-specific.


2) The SHC:
The SHC has been developed by François Cordoliani (alias Defise on this forum) with a very specific goal: computing four ratings/classifications and computing them fast:
    the T&E-depth of any puzzle,
    the B classification for puzzles in T&E(1),
    the BpB classification for puzzles in T&E(2),
    the BpBB classification for puzzles in T&E(3).

The fundamental classification by T&E-depth has already proven to be very useful in the search for the hardest puzzles, with millions of new ones in T&E(3) found by mith.
The BpB classification of puzzles in T&E(2) should be as useful for finding hard puzzles in T&E(2). But it appeared there was no tool fast enough to allow doing this in any practical way. So, this should become the major use of the BpB classification. This was the main motivation for developing the SHC.
The BpBB classification of puzzles in T&E(3) is mainly intended to check if all the puzzles found in T&E'(3) are in B2BB, as all those found until now.

Of course, SudoRules already allowed to do all these calculations and it has been used in the past to do them on a large scale (see [PBCS] and [UMNR]), but it's too slow for being used in the process of generating puzzles. The SHC is now the proper tool for all these calculations.


I could continue the listing of differences, but this should be enough to see the main ones and to help you choose which tool to use for which purpose.
.
denis_berthier
2010 Supporter
 
Posts: 3972
Joined: 19 June 2007
Location: Paris

Re: CSP-Rules, SudoRules, KakuRules...

Postby denis_berthier » Sat Nov 11, 2023 9:17 am

.
Today's update on GitHub includes:

GENERIC:
- allow focusing in ORk-chains;
- splitting-rules can now act on up to 16 guardians (instead of 12 before);
- add pretty-print-RS at the end of each h phase in T&E, at any level.

SUDOKU:
- add function solve knowing-solution-sukaku-grid;
- add the detection of degenerate cyclic anti-tridagons and the assertion of corresponding ORk-relations.
.
denis_berthier
2010 Supporter
 
Posts: 3972
Joined: 19 June 2007
Location: Paris

Re: CSP-Rules, SudoRules, KakuRules...

Postby denis_berthier » Mon Dec 04, 2023 8:18 am

.
Today's update on GitHub includes SudoRules function for extracting puzzles that have a given rating or that have a rating above a given value.

(extract-puzzles-with-value ?puzzles-file-in ?values-file ?file-len ?value ?puzzles-file-out)
(extract-puzzles-with-value-greater ?puzzles-file-in ?values-file ?file-len ?value ?puzzles-file-out)
As usual:
?puzzles-file-in is the full path to the file of puzzles;
?values-file is the full path to the file of their values for some rating/classification system (or nb of clues....);
?file-len is the length of ?puzzles-file-in;
?value is the target value or the (inclusive) lower bound for it;
?puzzles-file-out is the full path to the file of puzzles that satisfy the criterion.

This may be useful e.g. for:
- extracting T&E(1) puzzles with a high W or B rating, or a high SER (or FPGX), or a high number of clues, or a high number of candidates after BRT (or W1) (knowing all their W/B/... ratings);
- extracting T&E(2) or T&E(3) puzzles from a mixed list of hard puzzles (knowing all their T&E-depths);
- for extracting T&E(2) puzzles with a high value of their BpB rating (knowing all their BpB ratings).

I have used these functions to analyse Hendrik, Paquita, Coloin and JPF recent collections.
.
denis_berthier
2010 Supporter
 
Posts: 3972
Joined: 19 June 2007
Location: Paris

Re: CSP-Rules, SudoRules, KakuRules...

Postby denis_berthier » Fri Jan 05, 2024 5:36 am

.
Two updates on GitHub today:

1) CSP-Rules (https://github.com/denis-berthier/CSP-Rules-V2.1):
- a few cosmetic changes
- cleaning of the statistical and comparison functions
- addition of statistical and comparison functions (yet to be documented in the Manual, but examples of use are present in the "CB-stats.clp" file of the Controlled-bias collection)

2) Controlled-bias collection (https://github.com/denis-berthier/Controlled-bias_Sudoku_generator_and_collection):
- addition of the gW ratings for the full collection
- detailed comparison with the W ratings
.
denis_berthier
2010 Supporter
 
Posts: 3972
Joined: 19 June 2007
Location: Paris

Re: CSP-Rules, SudoRules, KakuRules...

Postby denis_berthier » Sun Jan 14, 2024 7:54 am

.
In the CSP-Rules Examples (https://github.com/denis-berthier/CSP-Rules-Examples), I added the gB ratings for the cbg-000 collection.
.
denis_berthier
2010 Supporter
 
Posts: 3972
Joined: 19 June 2007
Location: Paris

Re: CSP-Rules, SudoRules, KakuRules...

Postby denis_berthier » Fri Jan 26, 2024 5:53 am

.
In order to allow the easy calculation of expansions of puzzles, I added to SudoRules (https://github.com/denis-berthier/CSP-Rules-V2.1) a function "record-expansions-n-grids-after-first-p-from-text-file", with syntax:

Code: Select all
(record-expansions-n-grids-after-first-p-from-text-file ?puzzles-file ?p ?n ?expansions-file)

As usual:
Code: Select all
?puzzles-file and ?expansions-file are file names
?p is the number of puzzles to be skipped (it will generally be 0)
?n is the number of puzzles to be expanded
?p + ?n is supposed to be ≤ the length of ?puzzles-file
the length of ?expansions-file will be ?n


Note that this function can be used for multiple purposes, depending on which rules are selected in the configuration file. The two most typical ones are:
- select only the rules in BRT (i.e. nothing in the configuration file) and you will get the file of expansions by Singles;
- select only DFS and you will get the file of solutions.

Warning: any other set of rules with the confluence property can be selected to make expansions with this function, but only the asserted values are taken into account in the results (eliminated candidates are not: i.e. the result is a Sudoku not a Sukaku). Whether such expansions may have any usefulness is up to the user to decide. IMO, they don't, because what they keep of the expansion process is arbitrary.
.
denis_berthier
2010 Supporter
 
Posts: 3972
Joined: 19 June 2007
Location: Paris

Re: CSP-Rules, SudoRules, KakuRules...

Postby denis_berthier » Mon Jan 29, 2024 11:41 am

.
I updated the Controlled Bias Collection (https://github.com/denis-berthier/Controlled-bias_Sudoku_generator_and_collection) by adding more gB-ratings.
The purpose is not to change the stats (they are already quite precise, but to find cases of largest differences between the 4 ratings (W, gW, B, gB). See http://forum.enjoysudoku.com/pattern-based-constraint-satisfaction-2nd-3rd-eds-t32567.html for comments about the reults.
The collection with computed gB ratings now has over 3M puzzles (more than half of the total collection).

[Edit 2024 Feb. 03: the gB ratings are now computed for the whole collection of ~6M puzzles.]
.
denis_berthier
2010 Supporter
 
Posts: 3972
Joined: 19 June 2007
Location: Paris

Previous

Return to Software