Download presentation

Presentation is loading. Please wait.

Published byDanny Dearborn Modified over 4 years ago

1
Polynomial Time Algorithms for the N-Queen Problem Rok sosic and Jun Gu

2
Outline N-Queen Problem Previous Works Probabilistic Local Search Algorithms QS1, QS2, QS3 and QS4 Results

3
N-Queen Problem A classical combinatorial problem n x n chess board n queens on the same board Queen attacks other at the same row, column or diagonal line No 2 queens attack each other

4
A Solution for 6-Queen

5
Previous Works Analytical solution Direct computation, very fast Generate only a very restricted class of solutions Backtracking Search Generate all possible solutions Exponential time complexity Can only solve for n<100

6
QS1 Data Structure The i-th queen is placed at row i and column queen[i] 1 queen per row The array queen must contain a permutation of integers {1,…,n} 1 queen per column 2 arrays, dn and dp, of size 2n-1 keep track of number of queen on negative and positive diagonal lines The i-th queen is counted at dn[i+queen[i]] and dp[i-queen[i]] Problem remains Resolve any collision on the diagonal lines

7
QS1 Pseudo-code

8
QS1 Gradient-Based Heuristic

9
QS2 Data Structure Queen placement same as QS1 An array attack is maintained Store the row indexes of queens that are under attack

10
QS2 Pseudo-code

11
QS2 Reduce cost of bookeeping Go through the attacking queen only C2=32 to maximize the speed for small N, no effect on large N

12
QS3 Improvement on QS2 Random permutation generates approximately 0.53n collisions Conflict-free initialization The position of a new queen is randomly generated until a conflict-free place is found After a certain of queens, m, the remaining c queens are placed randomly regardless of conflicts

13
QS4 Algorithm same as QS1 Initialization same as QS4 The fastest algorithm 3,000,000 queens in less than one minute

14
Results – Statistics of QS1 Collisions for random permutation Max no. and min no. of queens on the most populated diagonal in a random permutation Permutation Statistics Swap Statistics

15
Results – Statistics of QS2 Permutation Statistics Swap Statistics

16
Results – Statistics of QS3 Swap Statistics Number of conflict-free queens during initialization

17
Results – Time Complexity

22
References R. Sosic, and J. Gu, “A polynomial time algorithm for the n-queens problem,” SIGART Bulletin, vol.1(3), Oct. 1990, pp.7-11. R. Sosic, and J. Gu, “Fast Search Algorithms for the N-Queens Problem,” IEEE Transactions on Systems, Man, and Cybernetics, vol.21(6), Nov. 1991, pp.1572- 1576. R. Sosic, and J. Gu, “3,000,000 Queens in Less Than One Minute,” SIGART Bulletin, vol.2(2), Apr. 1991, pp.22-24.

Similar presentations

OK

ICS-271:Notes 5: 1 Lecture 5: Constraint Satisfaction Problems ICS 271 Fall 2008.

ICS-271:Notes 5: 1 Lecture 5: Constraint Satisfaction Problems ICS 271 Fall 2008.

© 2018 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google