solving exact cover problem on distributed computing system

39 255 0
solving exact cover problem on distributed computing system

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

VIETNAM NATIONAL UNIVERSITY, HANOI UNIVERSITY OF TECHNOLOGY AND ENGINEERING Tuan Anh Nguyen SOLVING EXACT COVER PROBLEM ON DISTRIBUTED COMPUTING SYSTEM BACHELOR THESIS Faculty: Information technology HA NOI - 2010 1 VIETNAM NATIONAL UNIVERSITY, HANOI UNIVERSITY OF TECHNOLOGY AND ENGINEERING Tuan Anh Nguyen SOLVING EXACT COVER PROBLEM ON DISTRIBUTED COMPUTING SYSTEM BACHELOR THESIS Faculty: Information technology Department of Networks and Computer Communications Instructor: M.Sc. Phuong Ho Dac HA NOI - 2010 2 ABSTRACT This thesis depicts detail the way to design and implement a distributed computing system to solve exact cover problems based on Donald E. Knuth’s Dancing Links algorithm. A variation of these algorithms is developed which enables the problems to be distributed to a global network of computers using the JPPF Parallel computing framework. The ability of parallel and grid computing allow more complex and bigger problems to be solved in acceptable time. Exact cover is known as a general type of problem which can be represented to solve wide range ones such as N- queens, Pentomino tiling, Latin square puzzles, Sudoku, etc. The details of the modified Dancing Links algorithm and the implementation will be explained in detail as follows. A cluster of computers is used to examine the speed and efficiency of the algorithm. 3 TABLE OF CONTENTS CHAPTER 1: INTRODUCTION 6 1.1 OVERVIEW 6 1.2 RELATED WORK 6 1.3 N-QUEEN PROBLEM 6 CHAPTER 2: DANCING LINKS ALGORITHM 10 2.1 EXACT COVER 10 2.2 GENERALIZED COVER 11 2.3 ALGORITHM X 13 2.4 DACING LINKS ALGORITHM 16 2.4.1 DATA STRUCTURE 16 2.4.2 ALGORITHM 18 CHAPTER 3: IMPLEMENTATION DETAILS 23 3.1 A BRIEF VIEW ABOUT JPPF PARALLEL COMPUTING FRAMEWORK 23 3.2 ARCHITECTURE DETAILS 24 3.3 PARALLEL DANCING LINKS ALGORITHM 27 3.4 TRANSFORMS 28 3.4.1 N-QUEEN 28 3.4.2 MATRIX FILE FORMAT 30 3.4.3 BUILDING BOOLEAN MATRIX 30 CHAPTER 4: EXPERIMENTAL RESULTS 32 CHAPTER 5: CONCLUSION AND FUTURE WORK 37 5.1 CONCLUSION 37 5.2 FUTURE WORKS 37 Implement a new load-balancing algorithm 37 Implement more transforms 37 REFERENCES 38 4 TABLE OF FIGURES Figure 1 Board where the queens at B1 and H7 attack each other 7 Figure 2 One solution of the 8-queen problem 8 Figure 3 The two solutions S1 (left) and S2 (right) to the four4-queens problem 13 Figure 4 Algorithm X search tree for the example matrix 16 Figure 5 Doubly-linked list 17 Figure 6 Doubly-linked list with element x removed 17 Figure 7 Circular quad-linked list representation of the example matrix 18 Figure 8 The matrix before column A is covered 19 Figure 9 The matrix after column A has been covered. 20 Figure 10 JPPF network topology 23 Figure 11 JPPF Monitoring and Administration Tool 24 Figure 12 Simple architecture without Parallel computing framework. 25 Figure 13 DNS System full architecture. 26 Figure 14 Simulation Architecture 32 Figure 15 Non-parallel execution time 33 Figure 16 Execution time of parallel test compare with non-parallel test 33 Figure 17 Simulation Charts 34 Figure 18 Jobs executing in system 35 Figure 19 System settings. 36 5 ACKNOWLEDGEMENTS Firstly, I would like to express my gratefulness to my supervisor, M.Sc. Ho Dac Phuong, Department of Networks and Computer Communications, for his guidance, inspiration, and encouragement during the time I work on this thesis. Without his great help, I couldn’t finish my thesis. Secondly, I would like to thank the University of Technology and Engineering – Hanoi, Vietnam National University, where I have a chance to work and study in a good environment for four years. Last but not least, I would like to give my thanks to my family as well as my friends who always support, stand by me and encourage me a lot throughout my student life. They have been always the endless source of encouragement, ambition of my life. Ha Noi, June 2010 Nguyen Tuan Anh 6 CHAPTER 1: INTRODUCTION 1.1 OVERVIEW Exact cover is known as a general type of problem which can be represented to solve wide range ones such as N-queens, pentomino tiling, Latin square puzzles, Sudoku, etc. Solving high complexity exact cover problems is an interesting topic in mathematic field as well as computer science. Dr. Donald Knuth invented an algorithm called Dancing Links (DLX) [1] to solve them. Algorithm X is a recursive, nondeterministic, depth-first and backtracking algorithm that can find all solutions to any exact cover problem. However, a huge of computations must be process when the complexity of the problem increases. This cannot implement on a single computer system at a reasonable time. That is the reason why designing and implementing a distributed computing system for solving exact cover is the aim of this thesis. 1.2 RELATED WORK In recent years, there have been a large number of implementations of the Dancing Links algorithm available. In addition to Knuth’s own implementation, in CWEB [2] there are source codes for Java, Python, C, C++, Ruby, Lisp, Haskell, MATLAB, etc. Most of the implementations were aimed for a specific application: Sudoku and all these implementations share the common that none of them was designed for parallel processing. Alfred Wassermann and Matthew Wolff developed their own parallel algorithm to solve Knuth’s algorithm in [3] the n + k queen problem [6] by using PVM [4] and MPI [5]. However, they only published the solutions to their respective problems and not the actual implemented their research. The only available open source parallel version is written by Owen O’Malley for the Apache Hadoop project [7] in May 2007. His implementation used Hadoop, an implementation of MapReduce framework [8], a programming model suggested by Google for large-data processing, to do the computations in parallel. However, that what this implementation is and how it divides the problem into smaller pieces has not been published. 1.3 N-QUEEN PROBLEM Eight-queen problem is the classic problem, which has become very familiar with the field of computer science. However, we should also revise about eight-queen problem as well as tend to expand the problem. Historically, the problem was introduced in 1948 by Max Bezzel player, and many mathematicians later, like Gauss and Georg Cantor, have worked on the problem and its generalized-queens problem. The first algorithm was given by Franz Nauck in 1850 and he is also the person who generalized to N-queen problem. In 1874, S. Gunther offered a method for finding the solution by using the formula, and JWL Glaisher completed this method. 7 The eight-queen puzzle is the problem of placing eight chess queens on an 8×8 chessboard so that none of them is able to capture any others using the standard chess queen's moves. The queens must be placed in such a way that no two queens can attack each other. Thus, the solution requires that not any two queens share the same row, column, or diagonal. The eight-queen puzzle is an example of the more general n- queen problem of placing n queens on an n×n chessboard. Figure 1 shows an invalid solution because the queens at B1 and H7 attack each other. Figure 2 shows a valid solution to the eight-queen problem. Figure 1 Board where the queens at B1 and H7 attack each other 8 Figure 2 One solution of the 8-queen problem Depending on the symmetry of each solution, we can find out seven other solutions by rotating the board 90, 180, and 270 degrees. By transforming the upper and lower board and applying the rotation, we can find another four solutions. The eight-queen problem has total 92 solutions. N-Queen problem is the problem which is generalized from eight-queen problem. The problem set asks for the location n queens post on the board size n × n so that two queens cannot attack themselves. To solve the problem completely, we must use recursive method to find exhaustively possible outcomes of the problem. There do have many mathematicians as well as computer scientists researching and giving N- queen algorithm to the problem; one of the most common and simplest algorithms is backtrack searching algorithm. One of the characteristics of rotating backward search algorithm bases on the model search on the tree, and the number of nodes required have to increase as exponentially as the number of the depth of search tree do. Thus, the numbers of calculations to browse all the nodes on a tree are very large. In the process of finding and developing grid-computing applications, we chose N-Queen problem by the following compatible characteristics:  Be a simple, single solution algorithm and easy to install.  Be able to implement huge amount of computation.  Be able to compute parallel The remaining of my thesis is divided into four chapters:  Chapter 2: Dancing Links Algorithms I would like to give an overview of exact cover problem, Dr. Knuth’s algorithm X and its advantages and efficiencies when we use it to solve exact cover problem. 9  Chapter 3: Implementation Details This chapter describes about JPPF parallel computing framework protocol and detail architecture of Distributed N-Queen Solver (DNS).  Chapter 4: Testing and Results This chapter shows the results of my simulation in order to check the efficiency of the algorithm and DNS system.  Chapter 5: Conclusion and Future work The last chapter is the summary of this thesis and discuss about some work will be done in near future. [...]... more information about JPPF such as source code, binary distribution and detail documentations for developing an application on JPPF framework, please visit its homepage [11] 3.2 ARCHITECTURE DETAILS All problems belong to Generalized Cover class that means the problems can be converted to Generalized Cover problem and use common library Dancing Links to find all results of Generalized Cover problem The... TRANSFORMS As mentioned above, before applying to Dancing Links algorithm for solving Generalized Cover problems, we need a library to convert from a specific problem to a Generalized Cover matrix and another library switching back to final results With each problem, we will have different conversion algorithm, even the same problem can also convert in many ways, which depends on conventional represent... suitable to solve certain types of problems In many cases, the problem transformed to generalized cover form will be more convenient than the standard form Extract Cover Any generalized cover problem can be easily translated into an exact cover problem by adding additional rows The generalized cover problem divides the matrix into two kinds of columns, i.e primary columns and secondary columns, which are subject... the solutions back into a form suitable for the specific problem Divide Divide the problem into multiple smaller work units Merge Place all the solutions in a common place ready to be transformed Distributed Distribute the work units to systems sharing their computational power Collect Get solutions from each system until all work unit have been processed Conquer Process the work units on each system. .. to two different sets of constraints Each primary column in the solution must have exactly one non-zero element, as before However, each secondary column in the solution can have either zero or one non-zero element Let CP be the set of primary columns and C S the set of secondary columns in matrix A and B The subset of rows R B is an exact cover if both of the following equations are satisfied 11 𝑘 𝑘... diagonals and if we ignore each of the four corners diagonals, there is only a single square The way each diagonal is numbered is not as important as it is only needed to represent the problem and is not required to interpret the final solutions Therefore, the secondary columns from 9 to18 can represent 10 diagonal on the chessboard So, in the matrix we have 16 rows, corresponding to 16 cell positions... The cover( c) algorithm also increments the value of updates which is used to measure how many operations the search algorithm requires to complete One update equals four link modifications or one application of both the linked list removes and adds operations Attribute column header size is guaranteed by both cover and uncover algorithm so that the best search algorithm based on the evaluation function... explain what an exact cover problem is 2.1 EXACT COVER To represent an exact cover problem we use a binary matrix which each element is either zero or one (non-zero) This type of matrix is also called Boolean matrix, logical or {0, 1} matrix The word “matrix” in the rest of this thesis can be understood as a Boolean matrix that prevents ambiguity; the word “non-zero” is used instead of “one” to represent... The system has five logic layers as we can see The first layer is application layer where external applications produce exact cover problems and the final solutions end up The transformation layer is in which a problem is turned into an exact cover problem and outputs the matrix in a text file (See the detail format in section 3.4.2) This file is then handed to the next layer of where the DLX parallel... modifications to solve generalized cover problems, but the matrix construction procedure requires some minor adjustments (see Section 3.4.3) Example: To illustrate generalized cover problem, we review the four-queen puzzle The 4×4 board will have four rows and four columns Each of the four ranks (rows) and four files (columns) on the chessboard corresponds to a primary column in the exact cover matrix . need to explain what an exact cover problem is. 2.1 EXACT COVER To represent an exact cover problem we use a binary matrix which each element is either zero or one (non-zero). This type of. more convenient than the standard form Extract Cover. Any generalized cover problem can be easily translated into an exact cover problem by adding additional rows. The generalized cover problem. VIETNAM NATIONAL UNIVERSITY, HANOI UNIVERSITY OF TECHNOLOGY AND ENGINEERING Tuan Anh Nguyen SOLVING EXACT COVER PROBLEM ON DISTRIBUTED COMPUTING SYSTEM BACHELOR

Ngày đăng: 13/07/2014, 17:37

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan