1 / 21

N -Queens via Relaxation Labeling

N -Queens via Relaxation Labeling. Ilana Koreh ( 307247262 ) Luba Rashkovsky ( 308820695 ). N -Queens problem. Place N queens on a NxN chessboard, so that no queens can take each other.

macy
Download Presentation

N -Queens via Relaxation Labeling

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. N-Queens via Relaxation Labeling Ilana Koreh ( 307247262 ) Luba Rashkovsky ( 308820695 )

  2. N-Queens problem • Place N queens on a NxN chessboard, so that no queens can take each other. • Queens can move horizontally, vertically, and diagonally only one queen can stand per row and per column and no two queens can find themselves on the same diagonal. • Computationally expensive problem - NP-Complete.

  3. Naïve Solution for N-Queens • Building a search tree, where each node represents a valid position of a queen on the chessboard. • Nodes at the first level correspond to one queen on the board. Nodes at the second level represent boards containing two queens in valid locations, and so on. • When a tree of depth N is found then we have a solution for positioning N queens on the board.

  4. Partial search tree for 8-queen problem Queens are added on successive rows of the board, so as the search progresses down, we cover more rows of the board. When the search reaches a leaf at the Nth level, a solution has been found.

  5. Examples of solution for this problem 4 Queens 6 Queens 5 Queens

  6. Relaxation labeling algorithm • Relaxation labeling is a general name for group of methods for assigning labels to set of objects using contextual constraints. • Works with set of objects - Each object should get one of the possible labels - • Initialization of this algorithm sets value for each object labeled by each label. This value is the measured confidence that object should be labeled by label .

  7. Formulas used by the algorithm • - thestrength of compatibility between hypotheses " has label " and “ has label “. • For each iteration the algorithm calculates the support for label for object : • Update rule – probability for labeling object with label • Average Local Consistencyof the assignment -

  8. Relaxation Labeling Algorithmand N-Queens Problem

  9. Relaxation labeling algorithm - vision world • N-Queens problem - computer science world • This project is an implementation of reduction from algorithm from vision world to problem from other world.

  10. The Reduction • Objects the queens, what means the algorithm will work with N objects. • Labels assignments of queens. The labels that will be choose by the algorithm, will determine does the problem has consistent solution. •  for the first queen we choose the assignment randomly. This label will get the highest probability. All other queens will get some label (also randomly) that is consistent with the first queen.

  11. The Reduction (cont) •  this value between queen i and queen j, calculated accordingly to the given constraints for N-Queens problem. •  the “stop” condition of the algorithm.

  12. How do we decide what will be the assignment for the queens? • For each queen we choose the best label. • This label is the assignment this queen will get. • Best label is chosen by maximal probability for each queen. In case that there are more than one label that got same probability, best label will be chosen randomly.

  13. Simulator • Running the algorithm on different Ns. • Running “step by step” or “until convergence”. • Show visual and textual results of each iteration. • Statistics

  14. Demo

  15. Results • Running of the simulator for different Ns (from 4 to 15), 100 problems for each.

  16. As N increases, the number of solved problemsdecreases. The main reason for this is different purpose of the two problems (will be explained in "Problems" part). • As N increases, the time to converge (or solving) the problem increases also.

  17. Problems • Different purposes of two algorithms N-Queens - find consistent solution. The algorithm should stop when it finds at least one consistent solution. Relaxation Labeling - find some assignments of labels to objects, such that the solution will converge to max average local consistency. This difference causes to the relaxation labeling algorithm to stop (when it converges) even if current assignment of labels to queens doesn't make consistent solution (in terms of N-Queens problem).

  18. Problems - cont • In N-Queens problem, each object is affected by all other objects. In that case, the support for assignment of label to queen can be very high (if it consistent with most of the queens), even if it doesn't consistent with all the queens. When the support is high, there is no reason for the relaxation labeling algorithm to change the probability for next iteration, and the problem can converge, but in terms of N-Queens the solution doesn't consistent.

  19. Problems - cont • Many possibilities for equal values Relaxation labeling algorithm don't handle this problem. We solved this problem by using the random method (but maybe it's not the best method). • Solution != Convergence Solution of the problem doesn't means convergence for the relaxation labeling, so the algorithm will continue running, even if the solution was found. 5. Random in C# - not really random.

  20. Conclusion • For make a decision if relaxation labeling algorithm is good for the N-Queens problem, many another experiments should be done. • Probably Relaxation labeling algorithm not the best choice algorithm for solving N-Queens problem. Solving it with backtracking methods gave much better results. But for being sure, many additional experiments are needed.

  21. The End.

More Related