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   

QWH, order 30
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Puzzles
View previous topic :: View next topic  
Author Message
dukuso

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

Items
PostPosted: Sat Dec 03, 2005 4:54 am    Post subject: Reply with quote

take the problem to place the 12 pentominoes into a 6*10 rectangle.
How would you solve it ?
Fill it top to bottom with the long side vertical.
This is much faster than taking the small side vertical !

Now you can encode this problem as a SAT-instance.
But how can the solver know, what's the long side of the
rectangle ? All it can see are the clauses.

I feel, that there could be a similar problem with
solving sudokus and QWHs or even SAT-instances in general.
When you have a large sudoku or QWH, you would concentrate
to fill some regions as strategic goal. OK, "tactically"
you would try to complete cells or constraints
with only few candidates, but when there are several
possibilities you would prefer a cell in a dense area
hoping that the whole area might collaps earlier or
later to trivial placements (singles).

We have to tell this strategy somehow to the solver !
Ideas ?


-Guenter
Back to top
View user's profile Send private message Send e-mail Visit poster's website
frisch

Joined: 16 Nov 2005
Posts: 55
:
Location: Paris, France

Items
PostPosted: Tue Dec 06, 2005 8:39 am    Post subject: Reply with quote

Why could'nt a SAT solve infer some topological properties about variables? Also, I'm not sure about what is a good notion of locality between cells in sudoku.

I updated the list of minimal 30x30 QWH in my web pages. It now contains 18 puzzles.
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: Tue Dec 06, 2005 2:02 pm    Post subject: Reply with quote

frisch wrote:
Why could'nt a SAT solve infer some topological properties about variables? Also, I'm not sure about what is a good notion of locality between cells in sudoku.

I updated the list of minimal 30x30 QWH in my web pages. It now contains 18 puzzles.



I'd use constraints (3*30*30 in QWH30)
and placements (30*30*30) rather than varibles.
We have a bipartite graph, which placement satisfies
which constraint (the exact cover matrix).
The metrik is now the distance in this graph

timings for your 18 QWH30 are dominated by #10, which takes
200s with SATZ and 1100s with SATZOO


average number of holes in random minimal QWHs : 1.33*n^1.65
average number of holes in random minimal sudokus : 1.1*n^1.8
Back to top
View user's profile Send private message Send e-mail Visit poster's website
frisch

Joined: 16 Nov 2005
Posts: 55
:
Location: Paris, France

Items
PostPosted: Tue Dec 06, 2005 5:26 pm    Post subject: Reply with quote

So it seems your notion of metrics can directly be defined
in terms of the constraints under consideration (and I guess this metrics should evolve while the problem is further reduced). A SAT solver could probably use this kind of information as additional heuristics, if this is relevant (but I'm yet to be convinced this is the case).
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: Fri Dec 09, 2005 5:11 am    Post subject: Reply with quote

I have another idea, on how to improve your weighting function.

It is well known, that QWHs with a balanced spread of holes are much
harder than random QWHs.
See the lsencode-package from Gomes's webpage which I recommend
to download, if you haven't already.

Now, we can measure the "balancedness" of a puzzle to predict
its hardness.
E.g. walk through the constraints c and measure
the deviation of the number of matching placements N(c).
(exact cover formulation with n^3 placements and 3*n^2 contraints)

Or compute the minimum number M of placements per constraint
M = MIN {|N(c)|, c in _C}
Then compute the number Z of constraints with M placements.
Z = |{c in _C , |N(c)|=M }|
Maximize the pair (-M,Z)
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gsf

Joined: 18 Aug 2005
Posts: 411
:
Location: NJ USA

Items
PostPosted: Fri Dec 16, 2005 10:46 pm    Post subject: Reply with quote

dukuso wrote:
frisch wrote:

I updated the list of minimal 30x30 QWH in my web pages. It now contains 18 puzzles.

timings for your 18 QWH30 are dominated by #10, which takes
200s with SATZ and 1100s with SATZOO

here are the timings for my latest solver on 2.8Ghz p4
can you post the SATZ timings?
Code:

   seconds     nodes depth puzzle:line
   1.226814      529   8   1
   6.257049     2539   4   2:32
   0.938857      363   6   3:63
   1.743735      744   6   4:94
  11.357273     5126   8   5:125
   5.211208     2013   6   6:156
   1.645750      556  11   7:187
   0.791880      304   6   8:218
  39.098056    13278  11   9:249
 147.020650    60867  16   10:280
   0.042993       11   7   11:311
   5.886104     2338   9   12:342
   0.271959      101   7   13:373
  33.285941    11700  11   14:404
   3.110527     1436   7   15:435
   0.011998        1   1   16:466
  22.750541     8859  10   17:497
   0.039994       15   5   18:528
0/s puzzles 18 seconds 280.692329 nodes 110780 propagations 512866634
Back to top
View user's profile Send private message Visit poster's website
dukuso

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

Items
PostPosted: Fri Dec 16, 2005 11:06 pm    Post subject: Reply with quote

you're trying to beat Satz on QWHs ?!
will your algo work for SAT-instances and you make a SAT-solver
to challenge those in the SAT-competions with a modified
sudoku-solver ?! That would be funny :-)

Satz on those 18 with 2.6GHz

0.385
12.088
1.209
0.110
6.429
4.505
8.791
0.110
21.758
195.824
1.978
4.725
8.956
2.967
1.538
0.055
9.451
0.989
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gsf

Joined: 18 Aug 2005
Posts: 411
:
Location: NJ USA

Items
PostPosted: Fri Dec 16, 2005 11:24 pm    Post subject: Reply with quote

dukuso wrote:
you're trying to beat Satz on QWHs ?!
will your algo work for SAT-instances and you make a SAT-solver
to challenge those in the SAT-competions with a modified
sudoku-solver ?! That would be funny Smile

ha
we are pushing around the same bits after all but at this point I'm not interested in general SAT
head-to-head on sudoku/qwh? sure

the interesting (and annoying) thing for me is that 9x9 sudoku magic cells
are equivalent to SAT/CSP backdoors
for the order ~30 QWHs it looks like the backdoor size is ~4-5
i.e., 5 solved cells that solve the entire QWH
this helps to explain wild swings in backtrack behavior
there's hidden backdoor structure waiting to be illuminated
Back to top
View user's profile Send private message Visit poster's website
dukuso

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

Items
PostPosted: Sat Dec 17, 2005 7:47 am    Post subject: Reply with quote

I see, you at least read something about SAT-solving already.
I probably also read something, but forgot most.

What's "backdoor" ? I remember "backbone".
Are you saying the magic cells are useful to speed up the solver
or predict it's hardness ?

I'm wondering, why #10 is so hard. Is this "intrinsic" hardness,
or could it be that we might be able to solve it quickly if we
only concentrated on this one with some special strategies ?

What is it, that makes it so much harder than the others ?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gsf

Joined: 18 Aug 2005
Posts: 411
:
Location: NJ USA

Items
PostPosted: Sat Dec 17, 2005 11:55 am    Post subject: Reply with quote

dukuso wrote:

What's "backdoor" ? I remember "backbone".

backbone -- set of variables with the same value in all solutions
not much help for sudoku/qwh with only one solution

backdoor -- the solver is assumed to have a function that propagates constraints at each backtrack
the backdoor is a small subset of variables that, when solved, allow the problem to be solved by the propagation function without further backtracking
dukuso wrote:

Are you saying the magic cells are useful to speed up the solver
or predict it's hardness ?

yes
suppose a solver knows a-priori a backdoor/magic cell set but not the values for the cells
it could limit its search to just those cells
or
suppose you at least have a predictor of backdoor size for a given N
you could limit a random search to a depth epsilon larger than the backdoor size

I believe that the problems that crack easy either have many backdoors
so that even lousy guesses lead to them, or they have backdoors that are exposed by the cell/variable heuristics applied, or they have very small backdoors -- or combinations of all in a continuum

harder problems have less backdoors, or large backdoors, or backdoors that defy heuristics

9x9 sudokus seem to have backdoor size <= 2
most random 9x9 are trivially solved
a backtrack search with 1 level forward check with learning solves
most 9x9 during the first forward check before the first guess
for example, my solver only makes 20 guesses to solve all of your top1465
I think frisch's makes no guesses (can we confirm this?)


Last edited by gsf on Sat Dec 17, 2005 3:41 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
frisch

Joined: 16 Nov 2005
Posts: 55
:
Location: Paris, France

Items
PostPosted: Sat Dec 17, 2005 2:36 pm    Post subject: Reply with quote

My solver is a backtracking solver, so it makes guesses, as far as I understand what a guess is. The solver also does 1-lookahed at each step to reduce the number of candidates.

I've looked a little bit at SAT solvers. It seems that one of their basic techniques is to avoid discarding everything when backtracking occurs but instead keep the information learned when it does not depend on the wrong assumption. This might be equivalent to adding clauses to witness failures.
Is it what you call learning?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gsf

Joined: 18 Aug 2005
Posts: 411
:
Location: NJ USA

Items
PostPosted: Sat Dec 17, 2005 4:08 pm    Post subject: Reply with quote

frisch wrote:
My solver is a backtracking solver, so it makes guesses, as far as I understand what a guess is. The solver also does 1-lookahed at each step to reduce the number of candidates.

yes, "guess" w.r.t. logic is problematic on this forum
but for backtrackers its pretty clean cut
"20 guesses to solve all of dukosu's top1465" means that for all 1465 puzzles
my backtracker had to make a total of 20 guesses (some of those may have been the correct guess and only wrong guesses would require backtracking)
the point being that the 1 level forward check eliminated almost all of the guesswork
does your solver require any backtrack guessing on the top1465?
I recall that yours may do less guessing than mine and I wanted to isolate the diff
frisch wrote:
I've looked a little bit at SAT solvers. It seems that one of their basic techniques is to avoid discarding everything when backtracking occurs but instead keep the information learned when it does not depend on the wrong assumption. This might be equivalent to adding clauses to witness failures.

aha, I had been stuck on this
when a problem only has one solution then all backtracks are caused by wrong assumptions
frisch wrote:
Is it what you call learning?

I believe its equivalent to what your solver does
successes and failures noted in the current grid for all descendants
there is no propagation to the backtrack parent grid
Back to top
View user's profile Send private message Visit poster's website
frisch

Joined: 16 Nov 2005
Posts: 55
:
Location: Paris, France

Items
PostPosted: Sat Dec 17, 2005 8:10 pm    Post subject: Reply with quote

gsf wrote:

does your solver require any backtrack guessing on the top1465?


Yes, five of these puzzles cannot be solved without guessing (-logic option of the solver).
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gsf

Joined: 18 Aug 2005
Posts: 411
:
Location: NJ USA

Items
PostPosted: Sun Dec 18, 2005 5:02 pm    Post subject: Reply with quote

frisch wrote:
gsf wrote:

does your solver require any backtrack guessing on the top1465?


Yes, five of these puzzles cannot be solved without guessing (-logic option of the solver).

I found out why mine backtracked on 13 of them.
As you noted the forward check can reduce the candidate lists and number of holes in its search for the best next move. At the end of this search another round of forward checking (another iteration) may provide further reductions.
A solver without the forward check iteration backtracks on 13 of the top1465 with 22 backtrack guesses and a solver with forward check iteration backtracks on only 4 with a total of 5 backtrack guesses.

Although it reduces the number of backtrack nodes forward check iteration is fairly expensive and doesn't seem to pay off for higher order qwh/sudoku.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Puzzles All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
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