Sudoku Programmers Forum Index

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log inLog in          Games  Calendar

Log in to check your private messagesLog in to check your private messages   

Nodes per second
Goto page 1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Programming sudoku
View previous topic :: View next topic  
Author Message
abik

Joined: 10 Sep 2005
Posts: 18
:
Location: Santa Clara

Items
PostPosted: Sat Sep 10, 2005 4:28 am    Post subject: Nodes per second Reply with quote

Because I just wrote a simple Sudoku solver, I was wondering what the approximate state-of-the-art search rate in nodes-per-second is? I was able to search about 9.6 million nodes-per-second on a 3GHz Pentium 4 processor (see http:/www.aartbik.com/MISC/sudoku.html for some details) with a straightforward backtracking algorithm that visits nodes in increasing order of remaining possibilities. Are there any benchmarks for the quality of solvers that balance the quality of pruning the state space vs. the raw nodes-per-second rating?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dukuso

Joined: 14 Jul 2005
Posts: 424
:
Location: germany

Items
PostPosted: Sat Sep 10, 2005 6:26 am    Post subject: Reply with quote

I have ~200000 nodes per second,
where a node is a placement of a digit.
I use only the 324 basic constraints,
usually called "naked single", "hidden single" here.
How long do you need to solve the puzzles from :
http://magictour.free.fr/top95
me:0.15s with 2.6GHz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
abik

Joined: 10 Sep 2005
Posts: 18
:
Location: Santa Clara

Items
PostPosted: Sat Sep 10, 2005 7:08 am    Post subject: Reply with quote

The link does not seem to work. I typically use an "underspecified" puzzle with many solutions to test raw nodes-per-second speed. An example follows. How much time does your solver take to go through all these?


Code:

PROBLEM:
  +---+---+---+
  |536| 2 |9  |
  |  8|   |   |
  |   |   |   |
  +---+---+---+
  |6  |285|  9|
  |   |9 3|   |
  |8  |761|  4|
  +---+---+---+
  |   |   |   |
  |  4|   |   |
  |2 1|   |  7|
  +---+---+---+


SOLUTIONS=957263 DIFFICULTY=3

nodes=13767709 clocks=4043451768 secs=1.3430 cpn=293.0 Knps=10251.46
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dukuso

Joined: 14 Jul 2005
Posts: 424
:
Location: germany

Items
PostPosted: Sat Sep 10, 2005 7:22 am    Post subject: Reply with quote

abik wrote:
The link does not seem to work. I typically use

** oops. It's case-sensitive. top95 and TOP95 work both now.
** http://magictour.free.fr/top95

an "underspecified" puzzle with many solutions to test raw nodes-per-second speed. An example follows. How much time does your solver take to go through all these?


Code:

PROBLEM:
  +---+---+---+
  |536| 2 |9  |
  |  8|   |   |
  |   |   |   |
  +---+---+---+
  |6  |285|  9|
  |   |9 3|   |
  |8  |761|  4|
  +---+---+---+
  |   |   |   |
  |  4|   |   |
  |2 1|   |  7|
  +---+---+---+


SOLUTIONS=957263 DIFFICULTY=3

nodes=13767709 clocks=4043451768 secs=1.3430 cpn=293.0 Knps=10251.46



**957263 solutions, 11520645 nodes, 17.6 sec.

** hey, some people (well, one at least) are actually using my
** program for lengthy statistical calculations, (e.g. finding a 16-clue-sudoku) can you provide your
** program for this ? That should save us hours !
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Nick70

Joined: 08 Jun 2005
Posts: 160
:

Items
PostPosted: Sat Sep 10, 2005 9:26 am    Post subject: Reply with quote

I fit in the middle with 7.5 seconds on a P4 2400 using vanilla Knuth's dancing links.
Back to top
View user's profile Send private message
dukuso

Joined: 14 Jul 2005
Posts: 424
:
Location: germany

Items
PostPosted: Sat Sep 10, 2005 9:49 am    Post subject: Reply with quote

what language, what compiler, what CPU ?

you get a factor of 2 just because you let the links dance ?
(mine are static)
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Nick70

Joined: 08 Jun 2005
Posts: 160
:

Items
PostPosted: Sat Sep 10, 2005 2:22 pm    Post subject: Reply with quote

dukuso wrote:
what language, what compiler, what CPU ?

C, GCC compiler, P4 2400 as already stated.
Back to top
View user's profile Send private message
dukuso

Joined: 14 Jul 2005
Posts: 424
:
Location: germany

Items
PostPosted: Sat Sep 10, 2005 3:04 pm    Post subject: Reply with quote

Nick70 wrote:
dukuso wrote:
what language, what compiler, what CPU ?

C, GCC compiler, P4 2400 as already stated.


is source available ?
sorry, if it was already asked/answered. So many posts...
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Nick70

Joined: 08 Jun 2005
Posts: 160
:

Items
PostPosted: Sat Sep 10, 2005 4:55 pm    Post subject: Reply with quote

dukuso wrote:
is source available ?

For the whole program no, sorry, it's still very much work in progress.

However the function you are interested in is just this one:

Code:
int solve_dancing_links(int max_solutions, int *solution_buffer)
{
   struct dancing_column *col, *best_col;
   int best_len;
   struct dancing_node *node, *n;
   int level = 0;
   struct dancing_node *choice[CELLS];
   int solutions = 0;

forward:
   if (dancing_root.right == &dancing_root)
   {
      if (solutions == 0 && solution_buffer)
      {
         int i;

         for (i = 0; i < level; i++)
         {
            node = choice[i];
            solution_buffer[node->cell] = node->val;
         }
      }
      solutions++;

      goto backtrack;
   }

   for (col = dancing_root.right, best_col = col, best_len = best_col->len; col != &dancing_root; col = col->right)
   {
      if (col->len < best_len)
      {
         best_col = col;
         best_len = best_col->len;

         if (best_len == 0)
            break;
      }
   }

   if (best_len == 0)
      goto backtrack;

   node = best_col->head.down;
   unlink_col(best_col);

advance:
   choice[level] = node;
   n = node->right;
   while (n != node)
   {
      unlink_col(n->column);
      n = n->right;
   };

   level++;
   goto forward;


backtrack:
   if (level == 0)
      return solutions;

   level--;

   node = choice[level];
   best_col = node->column;

   n = node->left;
   while (n != node)
   {
      relink_col(n->column);
      n = n->left;
   };

   if (max_solutions && solutions >= max_solutions)
      goto quickquit;

   node = node->down;
   if (node != &best_col->head)
      goto advance;

quickquit:
   relink_col(best_col);
   goto backtrack;
}
Back to top
View user's profile Send private message
abik

Joined: 10 Sep 2005
Posts: 18
:
Location: Santa Clara

Items
PostPosted: Sat Sep 10, 2005 6:58 pm    Post subject: Reply with quote

I was able to optimize the raw speed of the solver a little more (see below). On the top 95, I was not doing so well due to the time it takes to read the puzzles from file. How is the typical benchmarking done (read the puzzles from file/stdin or memory, and then output the solutions or just count them)?

Code:


PROBLEM:
  +---+---+---+
  |536| 2 |9  |
  |  8|   |   |
  |   |   |   |
  +---+---+---+
  |6  |285|  9|
  |   |9 3|   |
  |8  |761|  4|
  +---+---+---+
  |   |   |   |
  |  4|   |   |
  |2 1|   |  7|
  +---+---+---+


SOLUTIONS=957263 DIFFICULTY=3

nodes=13767709 clocks=3750594784 secs=1.2500 cpn=272.0 Knps=11014.2
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dukuso

Joined: 14 Jul 2005
Posts: 424
:
Location: germany

Items
PostPosted: Sat Sep 10, 2005 7:57 pm    Post subject: Reply with quote

for me time needed for input and output is almost negligable,
but for you it could be different.

Well, assume the sudokus are in memory, then start the clock,
count the solutions, stop the clock.

Many puzzles are better for benchmarking, because
solvers can differ a lot on single puzzles due to
ordering of the constraints.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
abik

Joined: 10 Sep 2005
Posts: 18
:
Location: Santa Clara

Items
PostPosted: Sat Sep 10, 2005 10:01 pm    Post subject: Reply with quote

The IO was indeed not really the performance bottleneck: my solver does not reach peak nodes-per-second rating for several single-solution puzzles but, more importantly, probably considers too many nodes due to the simplicity of pruning. Can you please show the total number of nodes considered by your solver for the whole tour, so we can compare if your pruning algorithm is superior?

Code:

sudoku.exe < tour.txt

#PUZZLES=95 #SOLUTIONS=95

nodes=2319758 clocks=885243200 secs=0.2810 cpn=381.0 Knps=8255.4
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dukuso

Joined: 14 Jul 2005
Posts: 424
:
Location: germany

Items
PostPosted: Sat Sep 10, 2005 11:34 pm    Post subject: Reply with quote

66000 nodes, can be 50000 or 80000 on the same puzzles rotated.
these are collected hard puzzles.

You can also try the 1011 instances from the contest:
http://magictour.free.fr/msk_009
for a more random sample of sudokus.

114000 nodes and 0.3s with 2.6 GHz here,
counting the solutions.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
abik

Joined: 10 Sep 2005
Posts: 18
:
Location: Santa Clara

Items
PostPosted: Sat Sep 10, 2005 11:44 pm    Post subject: Reply with quote

The solver does much better here
(by the way, reading in data is included in timing as well now):

Code:

sudoku.exe < tourbig.txt

#PUZZLES=1011 #SOLUTIONS=1011

nodes=867861 clocks=253296472 secs=0.0930 cpn=291.0 Knps=9331.8
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dukuso

Joined: 14 Jul 2005
Posts: 424
:
Location: germany

Items
PostPosted: Sat Sep 10, 2005 11:54 pm    Post subject: Reply with quote

you still have 8 times more nodes here than me,
while in earlier examples with multiple solutions
it was almost the same



here are the timings from the contest with 2.5GHz,
subtract 50% or such for poor in/output timing
finding the solution was sufficient

Code:


Username   VB Version   Total Time (IDE)   Total Time (Compiled)

Brick1                  6   7.824347          0.38939
bpd                  6   1.93226625          0.33901571
Merri                  6   3.264567          0.170920885
kaffenils          6   41.600266          4.907671
Raedwulf          6   18.43646273          0.578268467
eyeRmonkey          6   20.194833          1.779405 (not all solved!)

ntg                  .Net     0.77159332          0.62759289

Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Programming sudoku All times are GMT
Goto page 1, 2, 3, 4, 5  Next
Page 1 of 5

 
Jump to:  
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
Sudoku Programmers topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group

Igloo Theme Version 1.0 :: Created By: Andrew Charron