1 / 22

Polynomial Time Algorithms for the N-Queen Problem

Polynomial Time Algorithms for the N-Queen Problem. Rok sosic and Jun Gu. Outline. N-Queen Problem Previous Works Probabilistic Local Search Algorithms QS1, QS2, QS3 and QS4 Results. N-Queen Problem. A classical combinatorial problem n x n chess board n queens on the same board

yen
Télécharger la présentation

Polynomial Time Algorithms for the N-Queen Problem

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 Go through the attacking queen only Reduce cost of bookeeping 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

  18. Results – Time Complexity

  19. Results – Time Complexity

  20. Results – Time Complexity

  21. 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.

More Related