|
View previous topic :: View next topic |
Author |
Message |
| pirussas
| Joined: 14 Sep 2009 | Posts: 11 | : | | Items |
|
Posted: Mon Oct 19, 2009 6:14 pm Post subject: Algorithms |
|
|
Where can I find a good page with the advantages and disadvantages of the algorithms for solving sudoku? |
|
Back to top |
|
|
| Pete
| Joined: 09 Jun 2008 | Posts: 18 | : | Location: Somerset, NJ | Items |
|
Posted: Tue Oct 20, 2009 12:57 am Post subject: |
|
|
If you're looking for solving techniques, you might start with http://sudopedia.org/wiki/Solving_Technique
You can also google "sudoku solving techniques" or something similar. |
|
Back to top |
|
|
| pirussas
| Joined: 14 Sep 2009 | Posts: 11 | : | | Items |
|
Posted: Tue Oct 20, 2009 1:14 pm Post subject: |
|
|
I have seen this site but I want a site where I can see the advantages and disadvantages of the algorithms |
|
Back to top |
|
|
| Pete
| Joined: 09 Jun 2008 | Posts: 18 | : | Location: Somerset, NJ | Items |
|
Posted: Tue Oct 20, 2009 9:01 pm Post subject: |
|
|
I don't know of any such page on the Web. I'd like to help, but I'm not even sure what you're looking for.
What would you consider an "advantage" here? If an advantage is the ability to solve every possible sudoku, then you'd want a brute-force approach: either a straight depth-first search or maybe a slightly smarter search like dancing links. If advantage means that a technique can be easily used by human solvers, then those would be at the bottom of the list. |
|
Back to top |
|
|
| pirussas
| Joined: 14 Sep 2009 | Posts: 11 | : | | Items |
|
Posted: Wed Oct 21, 2009 7:51 pm Post subject: |
|
|
I seek advantages in solving sudoku nxn in the shortest time possible |
|
Back to top |
|
|
| Adak
| Joined: 27 Feb 2008 | Posts: 87 | : | | Items |
|
Posted: Thu Oct 22, 2009 3:44 am Post subject: |
|
|
pirussas wrote: | I seek advantages in solving sudoku nxn in the shortest time possible |
For the fastest solving techniques, I'd look at the fastest solvers, whose programs break down into 4 groups. This is roughly listed in order, from fastest to just faster:
1) based on bit fields: Brit's bb solver is the fastest we've seen so far. The program is short, but working with bit fields is challenging. Human logic or solving techniques, are not their goal.
2) based on the DLX algorithm. This relies heavily on using linked lists, and needs a bit of tweaking to be optimized for Sudoku. The programs are medium to long, in length. Again, they have no human solving logic.
3) based on human solving techniques, and highly optimized. Use brute force only for the more difficult puzzles. They have a large amount of code, to handle the large amount of human solving techniques.
4) based solely on brute force. They typically use several medium to large look up tables, and a very small and fast, inner loop. Their total amount of code is quite small.
The language for them varies, but they all clearly benefit by being compiled on faster compiler's, like C or C++, to name two favorites.
One question to consider is how can a brute force solver help you? After you solve the puzzle, can it help you become a better solver? Show you how it solved it so you can learn something?
No.
Brute force solvers (of whatever type), are only good for solving one or more puzzles, really fast. You need a more interactive program, with human logic functions, to help a human solver improve.
It is amazing to watch the fastest solvers run through thousands of puzzles, however.
For puzzles larger than 9x9, DLX becomes a more difficult algorithm to beat. The jury is still out on if and when bit fields might be overtaken by the DLX programs, on larger puzzle sizes. |
|
Back to top |
|
|
| ChPicard
| Joined: 12 Mar 2008 | Posts: 82 | : | Location: Montreal, Canada | Items |
|
Posted: Thu Oct 22, 2009 8:29 pm Post subject: BB_Solver and DLX |
|
|
Adak wrote: |
For the fastest solving techniques, I'd look at the fastest solvers, whose programs break down into 4 groups. This is roughly listed in order, from fastest to just faster:
1) based on bit fields: Brit's bb solver is the fastest we've seen so far. The program is short, but working with bit fields is challenging. Human logic or solving techniques, are not their goal.
2) based on the DLX algorithm. This relies heavily on using linked lists, and needs a bit of tweaking to be optimized for Sudoku. The programs are medium to long, in length. Again, they have no human solving logic.
|
Hi
I would like to know if BB_Solver uses DLX when it is time to guess.
Thank you for answer.
JPS |
|
Back to top |
|
|
| Adak
| Joined: 27 Feb 2008 | Posts: 87 | : | | Items |
|
Posted: Thu Oct 22, 2009 11:31 pm Post subject: |
|
|
No. BB_Solver uses it's own bit fields and arrays.
The DLX algorithm is a more general one, and the programs I've seen that use it, are substantially longer than Brit's programl. |
|
Back to top |
|
|
| briturner
| Joined: 14 Oct 2008 | Posts: 75 | : | | Items |
|
Posted: Fri Oct 23, 2009 1:26 am Post subject: |
|
|
Greetings,
Here are some notes on the algorithms I used:
First, as far as a guide, I used the guide at http://www.sudocue.net/guide.php. I found it extremely helpful, but that is just me. It will not help if you go with the DLX method.
I did timings using various methods. If the goal is strictly a fast solver, I recommend implementing Naked and Hidden Singles, as well as Locked Candidates.
Code: |
Times to solve top_1465 (in millisec) using different techniques:
(note: each technique also includes the ones above)
Naked / Hidden Singles : 94.630
Locked Candidates : 59.317
Disjoint Subsets : 204.561
Hidden/Naked Pairs/Triples/Quads
Fishies : 296.719
X-Wing/Swordfish/Jellyfish
1 Step Commonality : 1237.000
XY-Wing/many others
|
As you can see, the time needed to detect more complicated methods overwhelms the saving achieved.
Finally, on the DLX method. It truly is an elegant solution, and it is also a generic method that can solve other problems as well as Sudoku. Since it is a generic method, it can not take advantage of some of the techniques that are unique to Sudoku, and thus, at least with the standard 9x9 grids, Sudoku unique solutions can still be faster.
I suspect that larger Sudokus will the faster to solve with DLX, but I also suspect that there may be difficulties with getting the DLX algorithm to solve variations efficiently (for example, how would you express a Killer Sudoku, or a Greater-Than puzzle in terms of the DLX constraints). Though, I do admit that I am not an expert with using DLX.
Brit |
|
Back to top |
|
|
| pirussas
| Joined: 14 Sep 2009 | Posts: 11 | : | | Items |
|
Posted: Tue Oct 27, 2009 9:44 am Post subject: |
|
|
1) based on bit fields: Brit's bb solver is the fastest we've seen so far. The program is short, but working with bit fields is challenging. Human logic or solving techniques, are not their goal.
How does the technique Brit's bb? Where can I get information about it? |
|
Back to top |
|
|
| briturner
| Joined: 14 Oct 2008 | Posts: 75 | : | | Items |
|
Posted: Wed Oct 28, 2009 1:13 am Post subject: |
|
|
Greetings,
It really depends on your motivation:
If you want to learn about programming a sudoku solver, I recommend using a guide on human solvable techniques so you can understand the ideas behind the solvers and try a few yourself. Try implementing naked and hidden singles, along with a backtracker first. After you have a solver or two written yourself based on the guides, then start looking at how others did it. But by waiting until you tried a few things yourself, you avoid tunnel vision of just repeating other peoples work.
If you want to work on a generator, then grab the bb_sudoku files (there is a post in the programming sudoku forum with a link to the source code and executable), and link it in as a tester to run your puzzles through.
If you want to learn solving techniques only applicable for computers, study the DLX algorithm (Knuth has a good paper on it, though not specifically about sudoku).
If you want to do a vhdl based solver, or one for a gpu, then there is not alot of data to start from. These techniques are based on serial algorithms, vhdl is really more about doing things in parallel. You can use vhdl to verify a solution in a single clock (based really only on gate propagation delays).
So, it really depends on what you are after. Remember, the joy in writing a program is in the creation of something new. So, try some things out yourself before looking at what others have done.
Brit |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
Igloo Theme Version 1.0 :: Created By: Andrew Charron
|