較高維度演繹競局問題最佳演算法之設計與分析
全文
(2) 摘要 隨著眾多領域中最佳化問題的逐步探索,發現許多重要的問題都能被轉換成 演繹競局問題(deductive game)的模型,例如編碼理論(coding theory)、電路測試 (circuit testing)、密碼系統破解(differential cryptanalysis)、附加條件搜尋(additive search problem)等問題。換言之,在演繹競局問題上的研究將使其他相關領域問 題的求解露出希望曙光,因此發展有效解決演繹競局問題的方法變得不容遲緩。 在過去數十年間,有許多針對演繹競局問題的研究產生。Mastermind 與 AB game(或稱為 Bulls and Cow)是最有名的兩種演繹競局問題,知名的電腦科學家 Donald E. Knuth 在 1976 年於論文中介紹此二者並針對 Mastermind 做相關研究。 在本論文中,我們提出一系列理論剪裁(theoretical-pruning)的最佳化方法與數學 證明來解決這兩種問題。 在運用這些新方法到欲解決的問題後,我們得到下列新的成果: (1) 我們提出一個適用於各種演繹競局問題的 admissible heuristic。同時,我 們根據此 admissible heuristic, 提 出 一 個 更 有 效 率 的 演 算 法 來 解 決 Mastermind,最後亦得到 Mastermind 在平均狀況下的最佳策略。 (2) 針對 AB game,我們提出一個更精緻的剪裁演算法(pruning algorithm)來 處理它。很幸運地,最後我們得到 AB game 在平均狀況下的最佳策略且 其平均猜測次數為 5.213。 (3) 我們針對在最差狀況下 3×n AB games 的最佳策略做理論性的分析。最 後我們成功地導出一個計算最差狀況下的最佳猜測次數之公式。 (4) 我們研究一個 AB game 的變型,稱為容許一次錯誤回應之 AB game。 最終我們求得其最佳猜測次數為 8。. 關鍵字:AB game、分支界定法、演繹競局問題、競局樹、Mastermind、最佳策 略、搜尋演算法、理論剪裁、錯誤回應。.
(3) 誌謝 轉眼間即將結束博士班的學習生涯,在這四年的時光中,我很感謝指導教授 林順喜博士的諄諄教誨與論文指導,使我對學術研究有更直接、更深刻的體認, 過程中亦獲益匪淺。除了研究上的指導,學生對老師治學與做事嚴謹的態度及原 則深有體會,亦為學生個人做事所效法之準則。. 感謝口試委員許舜欽教授、葉耀明教授、吳毅成教授、徐讚昇教授、趙坤茂 教授與陳善泰教授、對學生研究成果的肯定,並提出諸多寶貴的指正與建議,使 整個研究與論文品質能更趨於完善。另外也感謝陳世旺教授、黃文吉教授與陳柏 琳教授於論文計畫口試提出的建議與教導,使得論文整體架構能更加完整。另外 要特別謝謝陳善泰教授在研究初始階段的指導與幫忙,其對研究執著認真的態 度,是學生研究路途上的標竿。. 感謝我們研究群中所有學長與學弟在研究上的建議與幫忙,尤其特別感謝士 傑學長與雲青在研究上提供的諸多見解與協助。最後也感謝聖群、俊廷、信翰、 傑淳與昱臣在口試事務上的幫忙,使口試能順利完滿結束。. 最重要的就是感謝我的家人在背後默默的支持,使我可以專心的從事研究, 並順利完成這份論文。尤其感謝太太麗華在精神上的鼓勵支持與實際上的協助, 還有我們家小寶貝彧宸天真笑容的陪伴,此為督促我持續努力的最佳動力。. 其他尚有許多人在無形中對此研究提供諸多協助。在此一併感謝。最後懷著 感恩的心結束博士班生涯,期許自己未來在職場上能更加努力。.
(4) The Design and Analysis of Optimal Algorithms for Deductive Games with Higher Dimensions. A dissertation proposed by Li-Te Huang. to the Department of Computer Science and Information Engineering. in partial fulfillment of the requirements. for the degree of Doctor of Philosophy. in the subject of. Computer Science. National Taiwan Normal University Taipei, Taiwan, R.O.C. 2009.
(5) Abstract With the increasing exploration of optimization problems in numerous fields, many critical issues, such as coding theory, circuit testing, differential cryptanalysis, and additive search problem, can be modeled as deductive games. In other words, the research of these games has led to the hope that the fruitful solutions of problems in related areas may be obtained. Thus, it becomes urgent to develop efficient mechanisms for deductive games. Over the last few decades, considerable concern has arisen in solving a number of deductive games. Mastermind and AB game (or “Bulls and Cows”), which were introduced by the famous scientist, Donald E. Knuth, in 1976, are the most well-known ones. In this dissertation, we aim to present a series of theoretical-pruning optimization approaches and mathematical proofs to solve both of the two. As a result of applying these novel methods, the following new results have been obtained. (1) An admissible heuristic for deductive games is presented. Meanwhile, a more efficient algorithm based on it is introduced to solve Mastermind and an alternative optimal strategy in the expected case is gained eventually. (2) A refined pruning algorithm is demonstrated to address AB game. Fortunately, an optimal strategy for AB game in the expected case is acquired finally and its expected number of queries is 5.213. (3) Analyses of playing 3×n AB games in the worst case optimally are conducted. Furthermore, a worthwhile formula for calculating the optimal numbers of queries in the worst case is derived successfully. (4) A variation of AB game, AB game with an unreliable response, is surveyed. Finally, an exact bound of the number of queries for the game is achieved and its value is 8..
(6) Keywords: AB game, branch-and-bound, deductive game, game tree, Mastermind, optimal strategy, search algorithm, theoretical pruning, unreliable response..
(7) Contents List of Figures List of Tables Chapter 1 1.1. Introduction ....................................................................................................................1 Deductive Games ..................................................................................................................1. 1.1.1. Discussed Categories of Deductive Games ......................................................................1. 1.1.1.1. The Family of Mastermind.................................................................................................... 2. 1.1.1.2. The Family of AB game........................................................................................................ 3. 1.1.1.3. Deductive Games with Unreliable Responses....................................................................... 4. 1.1.2 1.2. Search Space of Discussed Deductive Games ..................................................................4 The Classification of Proposed Algorithms...........................................................................6. 1.2.1. Computer-aided Proof ......................................................................................................6. 1.2.2. Branch-and-bound Algorithm...........................................................................................6. 1.2.3. Approximate algorithm.....................................................................................................7. 1.2.4. Theoretical pruning...........................................................................................................8. 1.3. Preliminaries of Related Work ..............................................................................................9. 1.4. Research History of Deductive Games................................................................................11. 1.5. Terminologies of Deductive Games ....................................................................................13. 1.6. Organization of the Dissertation..........................................................................................16. Chapter 2. Depth-First Backtracking Algorithm with Branch-and-Bound Pruning ................18. 2.1. Introduction .........................................................................................................................18. 2.2. The Depth-first Backtracking Algorithm with Branch-and-Bound Pruning........................19. 2.2.1. The Framework of DBB .................................................................................................20. 2.2.2. DBB for Mastermind in the Expected Case....................................................................22 I.
(8) 2.2.2.1. DBB for Mastermind .......................................................................................................... 22. 2.2.2.2. The Admissible Heuristic for Deductive Games................................................................. 23. 2.3. Experimental Results........................................................................................................... 26. 2.4. Chapter Conclusion .............................................................................................................28. Chapter 3. Refined Branch-and-Bound Algorithm with Speed-up Techniques.........................29. 3.1. Introduction .........................................................................................................................30. 3.2. A Refined Branch-and-Bound Algorithm with Speed-up Techniques ................................31. 3.2.1. The Fundamental Framework in Terms of Branch-and-Bound Pruning ........................31. 3.2.2. The State-of-the-Art Techniques ....................................................................................35. 3.2.2.1. Technique 1: Incremental Updates of the Lower Bounds ................................................... 35. 3.2.2.2. Technique 2: Earlier Terminations...................................................................................... 37. 3.2.2.3. Technique 3: Reductions of Equivalent Queries ................................................................. 41. 3.3. Experimental Results and Discussions ................................................................................43. 3.3.1. The Effects of the Three Useful Techniques ..................................................................43. 3.3.2. Performances and Results of RBB for Solving Mastermind and AB Game...................46. 3.4 Chapter 4. Chapter Conclusion .............................................................................................................47 Structural-reduction Approach...................................................................................49. 4.1. Introduction .........................................................................................................................49. 4.2. Optimal Analyses for the Codebreaker and the Codemaker................................................51. 4.2.1. Analyses of the Optimal Queries for the Codebreaker ...................................................52. 4.2.2. The Devil’s Strategy for the Codemaker ........................................................................58. 4.3. An Illustrative Example of the Pessimistic Situation ..........................................................59. 4.4. Chapter Conclusion .............................................................................................................60. Chapter 5. Optimization Algorithm and Verification Algorithm................................................62. II.
(9) 5.1. Introduction .........................................................................................................................62. 5.2. Two-Phase Optimization Algorithm....................................................................................66. 5.2.1. The Structure of TPOA...................................................................................................66. 5.2.2. Hash Collision Groups....................................................................................................69. 5.2.3. TPOA for AB game with an Unreliable Response .........................................................70. 5.2.4. The Hashing Function and the Heuristic of Evaluation ..................................................72. 5.2.5. Experiment Results of TPOA .........................................................................................73. 5.3. Pigeonhole-principle-based Verification Algorithm ...........................................................74. 5.4. Chapter Conclusion .............................................................................................................78. Chapter 6. Conclusion and Future Work ......................................................................................79. 6.1. Concluding Remarks ...........................................................................................................79. 6.2. Future Work ........................................................................................................................81. Bibliography..........................................................................................................................................83 Appendix A.. Equivalence Transformations for AB Game at the Second Query......................88. Appendix B.. Optimal Strategy for AB Game in the Expected Case..........................................99. Appendix C.. Publication List ...................................................................................................... 103. III.
(10) List of Figures Figure 1. The screenshot of 4×6 Mastermind ...........................................................................................3 Figure 2. The screenshot of 4×10 AB game .............................................................................................4 Figure 3. A strategy for 3×4 AB game ...................................................................................................15 Figure 4. The scenario of branch-and-bound pruning ............................................................................20 Figure 5. The depth-first backtracking algorithm with branch-and-bound pruning................................21 Figure 6. The game tree of Mastermind by applying DBB ....................................................................23 Figure 7. An example of the calculation of the admissible heuristic for Mastermind ............................25 Figure 8. The game tree of AB game by applying DBB directly ...........................................................33 Figure 9. An example of the calculation of the admissible heuristic for AB game ................................34 Figure 10. A situation that depicts the exploring process.......................................................................36 Figure 11. An optimal strategy for a state with a size of 2 .....................................................................37 Figure 12. All possible game trees for a state with a size of 3................................................................38 Figure 13. Mapping from codes in C[2,0] to those in C[1,0] for 3×5 AB game..........................................51 Figure 14. The scenario of the pessimistic situation of a 3×20 AB game ..............................................60 Figure 15. A game tree for the 1×3 game with an unreliable response ..................................................63 Figure 16. The construction for TPOA+ (k, d) tree .................................................................................67 Figure 17. The sketch of TPOA..............................................................................................................68 Figure 18. The relation between HCGs and equivalent classes..............................................................70 Figure 19. The game tree expanded by TPOA .......................................................................................71 Figure 20. The sketch of the PPV algorithm ..........................................................................................76 Figure 21. The transformation between the game tree and its corresponding representation............... 100. IV.
(11) List of Tables Table 1. The search space of discussed deductive games.........................................................................5 Table 2. The classification of proposed algorithms ..................................................................................8 Table 3. Significant research of deductive games ..................................................................................12 Table 4. The volumes of 14 classes calculated by Get_volume function ...............................................24 Table 5. The experimental results of two versions of Mastermind.........................................................27 Table 6. The volumes of 14 classes in AB game....................................................................................34 Table 7. 20 equivalent sets of the 209 codes at the second query...........................................................42 Table 8. The running time of exploring some states after making 1st query...........................................44 Table 9. The numbers of the descendant states with a size of 3 .............................................................45 Table 10. The numbers of hits and misses by using the hash table ........................................................45 Table 11. The numbers of choices at the first four queries.....................................................................46 Table 12. The minimum number of queries for 3×n AB games in the worst case .................................61 Table 13. The upper bound derived by our program ..............................................................................74 Table 14. Equivalence transformations ..................................................................................................88 Table 15. The mapping between responses and representative letters....................................................99. V.
(12) Chapter 1 Introduction. 1.1 Deductive Games Deductive games are zero-sum games of imperfect information. Two opponents are involved in deductive games. One opponent serves as a codemaker, who thinks of a secret code in mind, and the other is a codebreaker, who has to acquire the code by making queries iteratively. Each query is a guess for a possible secret code. After a query is made in each ply, the codemaker will give a response. The goal of the codebreaker is to identify the code in the fewest queries in accordance with previous information. The game proceeds in turn until the secret code is eventually obtained by the codebreaker. The original versions of deductive games, Mastermind and AB game (or “Bulls and Cows”), were first introduced by the famous scientist, Donald E. Knuth, in 1976 [45]. Detailed descriptions and categories of deductive games will be introduced in the follow-up paragraphs.. 1.1.1 Discussed Categories of Deductive Games Generally speaking, an m×n deductive game means that each possible secret code in the game is composed of m digits while every digit has n possibilities (symbols). Without loss of generality, the set of these n symbols is defined as S = {0, 1, 2, ..., n − 1}. Suppose that the codemaker has a secret code c = c1c2 Kcm in mind and the 1.
(13) codebreaker makes a query g = g1 g 2 K g m , where ci , g j ∈ S , ∀i, j . Then, the. codemaker will give a response [x, y], where x and y are defined as follows. . x = {i : ci = g i }, ∀i = 1,K, m . Thus, x means the number of symbols which. appear in both c and g and meanwhile, every symbol occupies the same position in both c and g. . y = ∑ j = 0 min ( p j , q j ) − x , where p j = {i : ci = j} and q j = {i : g i = j} . In n. other words, y represents the number of symbols which occur in both c and g but the positions of these symbols in c and g do not match. Note that for convenience, [x, y] is called xAyB as well. In this notation, the corresponding part can be omitted if x or y equal to 0. For instance, we can say 1A1B instead of [1, 1] while [0, 1] is also called 0A1B or 1B simply. A deductive game has ended if the codebreaker figures out the secret code, i.e., a response [m, 0] is received by the codebreaker. Besides the above definitions, there is one additional characteristic to distinguish two families of deductive games. That is whether repeated symbols are allowed in each secret code or not. One of the two is the family of Mastermind, in which repeated symbols are permitted in a secret code. The other is the family of AB game, in which all symbols within a code are distinct. The following subsection will offer additional introductions to the two families of deductive games and one of their variants.. 1.1.1.1 The Family of Mastermind In this kind of deductive games, a symbol may appear several times within a secret code. The most popular version of Mastermind is 4×6 Mastermind, which is well-known around the world since its appearance in 1972. A secret code in it consists of 4 digits with 6 possible symbols, e.g., 0, 1, …, 5. This is a topic that will be first 2.
(14) investigated in the study. In order to simplify its name, 4×6 Mastermind is simply called Mastermind in the later discussion if we do not stress its dimension. Figure 1 shows the screenshot of 4×6 Mastermind, which was captured from [23].. Figure 1. The screenshot of 4×6 Mastermind. 1.1.1.2 The Family of AB game The kind of deductive games is an ancient game that may date back a century or more and Mastermind also resembles it. The family of AB game is innately the same as that of Mastermind except the distinct symbols in a code. 4×10 AB game is the most common version and widespread in Asia and England. A secret code in it is composed of 4 digits while there are 10 possible symbols, i.e. 0, 1, …, 9, in each digit. In this study, we focus on 4×10 AB game and a generalized version, 3×n AB games, and for the sake of simplicity, AB game is usually referred to as 4×10 AB game if the dimension is not mentioned. Figure 2 exhibits the screenshot of 4×10 AB game, which was captured from [57]. 3.
(15) Figure 2. The screenshot of 4×10 AB game. 1.1.1.3 Deductive Games with Unreliable Responses In normal deductive games, the codemaker will always give a correct response when the codebreaker makes a query. In order to fit in with the area of fault tolerance, a variant model of deductive games, called deductive games with unreliable responses, was first demonstrated by Huang et al. [38]. In other words, it is the same as the original one but the codemaker is allowed to offer incorrect responses at most e times, where the value of e is greater than zero. In [38], 4×6 Mastermind with an unreliable response has been solved completely. In this dissertation, a harder problem, 4×10 AB game with an unreliable response, will be considered and likewise, every code in it has 4 digits with 10 possible symbols. We call it AB game with an unreliable response for short as well.. 1.1.2 Search Space of Discussed Deductive Games Before the addressed deductive games are discussed, solid analyses of search 4.
(16) space for these problems are necessary. Assume that an m×n deductive game is taken into account. The numbers of all valid responses given by the codemaker and all possible queries the codebreaker can make are offered here. . Note that there exists 1 + 2 + 3 + L + (m + 1) = (m + 1)(m + 2 ) 2 combinations of the values of x and y for m digits but the response [m − 1, 1] is impossible. Therefore, there are at most. (m + 1)(m + 2) − 1 = m(m + 3) 2. 2. legal responses. In. other words, the codebreaker may receive one of these responses which are [m, 0], [m − 1, 0], [m − 2, 2], [m − 2, 1], [m − 2, 0], ..., [m − i, i], ..., [m − i, 0], ..., [0, m], ..., [0, 0]. . All possible guesses the codebreaker can query are same as all valid secret codes the codemaker can choose. Obviously, there are n m secret codes in the family of Mastermind and n! (n − m )! codes in the family of AB game. Thus, so are their numbers of all possible queries.. Table 1 summarizes the search space of every deductive games discussed in this study with the use of above formulas. Note that the number of pessimistic queries for these games means the worst-case number of queries required for the codebreaker. In the column “# of pessimistic queries”, each value from top to down is referenced from [45], [18], Chapter 4, and Chapter 5 of this study respectively. Table 1. The search space of discussed deductive games deductive games. # of valid secret codes. # of legal responses. Pessimistic # of queries. Search space. 4×6 Mastermind. 6 4 = 1296. 14. 5. (1296×14)5 ≈ 1021. 4×10 AB game. 10! (10 − 4)! = 5040. 14. 7. (5040×14)7 ≈ 1034. 3×n AB game. n! (n − 3)! = n 3 − 3n 2 + 2n. 9. ⎣(n + 1) 3⎦ + 3. 4×10 AB game with an unreliable response. 10! (10 − 4)! = 5040. 14. 8. 5. (9n. 3. − 27n 2 + 18n. )⎣(. n +1) 3 ⎦+3. (5040×14)8 ≈ 1039.
(17) 1.2 The Classification of Proposed Algorithms In order to investigate the above games, several kinds of algorithms have been proposed. We therefore give a comprehensive introduction to their classification and major properties.. 1.2.1 Computer-aided Proof A computer-aided proof (or called computer-assisted proof, computational method) is a paradigm of proofs, which has been partially or fully generated by computer. Most computer-aided proofs are implemented with numerous case-by-case exhaustion for desired problems. Sometimes, some theorems seem concise in nature whereas their mathematical proofs rely on heavy analyses of different configurations [69]. Thus, the computing power of computers is necessary to do an exhaustive verification. In fact, not only the use of computers can make the analyses of complicated algorithms fun but also the results may not be gained in a reasonable time without the assistance of computers [65][66]. Historically, there were many significant results proven by this approach such as the four-color theorem [4][5], the Kepler conjecture [32], Connect-Four [1][2], Connect-Five [3], checkers [63] and so on.. 1.2.2 Branch-and-bound Algorithm The branch-and-bound algorithm was first demonstrated by Land and Doig in 1960 [49] and its appearance is common in the modern textbooks as well [52]. Another similar algorithm is named as A* search [62] and previous study reveals that the two types of algorithms are essentially identical and they only differ at the interpretation level [48]. Thus, the two terms will be alternatively used below according to the concept we intend to express. 6.
(18) In general, the branch-and-bound algorithm is a general search algorithm for finding optimal solutions of various optimization problems. The key idea is that if a branch is encountered in the search process, the algorithm decides whether the branch should be cut or not in accordance with the value of the admissible heuristic (or called bound function), which represents a lower bound to the goal. Good admissible heuristics of a certain problem are usually hard to discover, but are just the core of a branch-and-bound algorithm. Hence, they play significant roles in this kind of methods. On the other hand, admissible heuristics are worth discovering because they also have desirable properties in various search algorithms [56].. 1.2.3 Approximate algorithm Approximate algorithms are developed to solve optimization problems in practice. They sacrifice the guarantee of finding optimal solutions for the sake of getting feasible solutions in a significantly reduced amount of time. Approximate methods are usually distinguished between constructive methods and local search methods. The former ones generate solutions from scratch by adding components (or called moves) until a solution is complete. On the other hand, the latter ones start from some initial solution and iteratively try to replace the current solution by a better one. However, both methods may easily be trapped into local optima. To escape from local optima, a new kind of approximate algorithms has emerged in the past three decades. These algorithms try to combine basic heuristic methods in higher-level framework aimed at efficiently and effectively exploring a search space. Examples of these algorithms based on local search methods are genetic algorithms [36], simulated annealing [44], tabu search [26][27], ant colony optimization [22], and iterated greedy [60]. On the other hand, examples of algorithms based on constructive 7.
(19) methods are iterative sampling [33], HBSS [13], sampling and clustering [19], selective-sampling simulation [10], adaptive sampling [41][61], GRASP [24][55], block search [35], and Monte-Carlo Tree Search [20]. The main difference between these algorithms is the mechanisms used to guide the tree search.. 1.2.4 Theoretical pruning Given a huge search space of a problem, the forward pruning is a common scheme if a search algorithm is adopted to handle this problem. It is able to prune some useless branches in the search to speed up the work. Recently, some new forward-pruning mechanisms are presented such as null move [21], multi-cut [11], and AEL pruning [34]. Although these new approaches can acquire better results in less computation time, they still fail to guarantee the optimal outcomes. Therefore, the mechanism of the theoretical pruning, whose key idea is to conduct a forward pruning based on optimal analyses, is suggested in the research. Since this kind of pruning certified by optimal analyses omits the expansion of some branches, it can not only accelerate the speed of searching but also ensure the acquisition of best results. Table 2 lists the classification of all algorithms appearing in the study and each algorithm is marked with the corresponding classification. The column “Position” shows in which chapter each algorithm is presented. Table 2. The classification of proposed algorithms Algorithms. Computer-aided Branch and bound proof. Mathematical Theoretical Approximate proof pruning. Position. DBB. √. √. √. Chapter 2. RBB. √. √. √. Chapter 3. √. SR. √. TPOA PPV. Chapter 4. √. √. Chapter 5 √. 8. Chapter 5.
(20) 1.3 Preliminaries of Related Work Mastermind and AB game, whose dimensions are 4×6 and 4×10 respectively, are widely known throughout the world. The former is popular in America while the later, which is called “Bulls and Cows” in some places as well, is widespread in England and Asia. AB game is an ancient game and Mastermind, which resembles AB game, was invented in 1970. They were first stressed by the notable scientist, Knuth [45]. A strategy of Mastermind for minimizing the number of queries was also proposed by him and has achieved the optimal result in the worst case, where the maximum number of queries needed is 5. Meanwhile, its number of queries in the expected case is 4.478. Plenty of studies on finding better strategies of Mastermind in the expected case arose from then on. Irving [39], Norvig [54], and Neuwirth [53] enhanced the results, in which the bounds of expected numbers of queries are 4.369, 4.47, and 4.364, respectively. Flood [25], Ko and Teng [46] thus defined general notations for m×n deductive games and proposed some improved strategies. Eventually, Koyama and Lai [47] introduced an optimal strategy in the expected case for it in 1993 while the expected number of queries is about 4.34. Rosu [59] also proposed a faster algorithm and obtained the optimal strategy as well. A thorough introduction to Mastermind and a new heuristic approach were demonstrated by Barteld [6]. Chen et al. [16] demonstrated 2×n Mastermind and solved it completely with the graph-partition approach and Goddard [28] also obtained the same results for this problem independently. On the other hand, there is another variation called static Mastermind, where the codebreaker has to make all queries at once and has to uniquely decide the secret code after receiving all answers. Greenwell [31] derived some results of the game for small cases and provided some upper bounds of the game in a few cases. Afterwards, Goddard [29] completely solve static mastermind 9.
(21) for at most 3 digits, and for some cases of 4 digits. Huang et al. [38] also presented a variation, called Mastermind with an unreliable response, and obtained an optimal strategy for it. In 2006 the Mastermind Satisfiability Problem has been shown to be NP-complete [70]. Jäger and Peczarski [40] investigated the generalized Mastermind and used the computer aided methods and mathematical proofs to decide the optimal number of queries in the worst case for 3×n Mastermind and to derive the lower and upper bounds of the numbers of queries for 4×n Mastermind, m×2 Mastermind, and m×n Mastermind. Goodrich [30] studied the algorithmic complexity of Mastermind with single-dimensional responses, which means that there is only one number (the value of x) in each response. Much more efficient meta-heuristic algorithms, which produced comparable results with less running time in various dimensions of Mastermind, were investigated by Bernier et al. [9], Bento et al. [7], Kalisker and Camens [43], Singley [68], Ugurdag et al. [73], and Berghman et al. [8]. Although these methods are often efficient and effective, they are not able to attain the optimal strategy of Mastermind. Chen et al. [17] described a systematic method to address 4×6 Mastermind and it can achieve a near-optimal result in the expected case. There are some scientists that emphasized the efficiency of acquiring the good results, such as Shapiro [67], Swaszek [71], Rosu [59], Temporel and Kovacs [72]. However, the qualities of strategies they discovered may usually be incomparable with those of other carefully considered approaches due to quick selections of queries. Compared to 4×6 Mastermind, there is less research on 4×10 AB game because of its huge search space although 4×10 AB game has longer history. Chen et al. [15] introduced 2×n AB game, and found the optimal number of queries in both the worst and the expected cases. Moreover, Chen et al. [18] first proved the exact number of queries in the worst case to identify a secret code for 4×10 AB game and showed that 10.
(22) the number is 7. Merelo et al. [51] indicated that many critical issues, such as coding theory, circuit testing, differential cryptanalysis, and additive search problem, can be modeled as deductive games. In other words, the research of these games has led to the hope that the fruitful solutions of problems in related areas may be obtained.. 1.4 Research History of Deductive Games Table 3 has concluded with a series of significant progressive and conclusive results of deductive games since Knuth [45] stressed two famous deductive games, Mastermind and AB game, in 1976. Progressive results mean that the research of the handled problem has acquired better results but it may be refined again in the future. Conclusive results represent that a complete conclusion (often refers to as an optimal strategy) is obtained via the stressed problem. The field “Problem” is the game that paper dealt with. If it writes “Several dimensions of Mastermind”, then there are several versions of Mastermind surveyed in that paper. We can observe that many variations of deductive games are included as well. Moreover, the field “Case” indicates which condition the addressed problem is considered. The terms, “Worst” and “Expected”, mean that the problem is taken into account in the worst case and in the expected case. Note that “NP-C” is filled in the field if the game was proven to be an NP-Complete problem in that study while “Fixed” is used in static Mastermind and indicates a fixed number of queries is required. The field “Author” shows the scholars who conducted this research. Because of space restrictions, we omit each citation of the corresponding paper in Table 3, readers can reference the previous subsection for more information. Furthermore, it deserves to be mentioned that our contributions to the area of deductive games are also highlighted with gray backgrounds in Table 3. 11.
(23) Table 3. Significant research of deductive games Year. Conclusive results. Progressive results Problem. Case. Author. 1978. 4×6 Mastermind. Expected. Irving [39]. 1982. 4×6 Mastermind. Expected. Neuwirth [53]. 1983. 4×4, 4×5 Mastermind. Expected. Shapiro [67]. 4×6 Mastermind. Expected. 1976. Problem. Case. Author. 4×6 Mastermind. Worst. Knuth [45]. 1984. Norvig [54]. 1986. Several dimensions of Mastermind Expected. Ko and Teng [46]. 1988. Several dimensions of Mastermind Expected. Flood [25]. Several dimensions of Mastermind Expected. Bernier et al. [9]. Several dimensions of Mastermind Expected. Bento et al. [7]. 1993. 4×6 Mastermind. Expected Koyama and Lai [47]. 1996 1999. 4×6 Mastermind. Expected. Rosu [59]. 2000. 2003. 3×n static Mastermind. Fixed. 4×6 Mastermind. Expected. Swaszek [71]. 4×6 static Mastermind. Fixed. Greenwell [31]. 4×n static Mastermind. Fixed. Goddard [29]. Several dimensions of Mastermind Expected. Goddard [29]. Several dimensions of Mastermind Expected. 2×n AB game 2004 2×n Mastermind. Worst, expected Worst,. Chen et al. [16],. expected. Goddard [28] 4×6 Mastermind. 2006. Satisfiability Problem 4×6 Mastermind with. [70] Huang et al. [38]. 4×10 AB game. Worst. Chen et al. [18]. 4×6 Mastermind. Expected. Huang et al.. 3×n Mastermind. Worst. Mastermind with 2009. Stuckman and Zhang. Worst. an unreliable response 2007. NP-C. Jäger and Peczarski [40]. NP-C. Goodrich [30]. 4×10 AB game. Expected. Huang et al.. 3×n AB game. Worst. Huang and Lin. Worst. Huang and Lin. black-peg results. 4×10 AB game with an unreliable response. [72] Kalisker and Camens [43]. Chen et al. [15]. 2005 Mastermind. Temporel and Kovacs. Expected. Barteld [6]. Several dimensions of Mastermind Expected. Singley [68]. Several dimensions of Mastermind Expected. Ugurdag [73]. 4×6, 5×8 Mastermind. Expected. Merelo et al. [51]. 4×6 Mastermind. Expected. Chen et al. [17]. 4×n, m×2, and m×n Mastermind. Worst. Jäger and Peczarski [40]. Several dimensions of Mastermind Expected Berghman et al. [8]. 12.
(24) 1.5 Terminologies of Deductive Games There are two issues for optimizing deductive-game problems. One is to minimize the queries made by the codebreaker in the worst case, and the other is to minimize that in the expected case. An optimal strategy in the worst case is a strategy which minimizes the maximum number of queries needed by the codebreaker for any secret code chosen by the codemaker. An optimal strategy in the expected case is a strategy which minimizes the expected number of queries required with considerations of all possible codes. Note that a uniform distribution over all the codes the codemaker may choose is assumed. An alternative aspect of viewing the optimization for strategies of deductive games as a game-tree search is adopted in this study. In order to formulate the problem precisely, some general definitions used in the entire study are listed as follows while other specific terms are defined in each chapter individually, if necessary. Definition 1. A secret code is eligible if it is compatible with all queries and the. corresponding responses given so far. Definition 2. A set, which contains some eligible codes, is referred to as a state. Definition 3. For an m×n deductive game, a state with only one eligible code, which. has also been queried by the codebreaker now, is defined as a final state. That is to say that the secret code has been identified and the game is over. Definition 4. If finding an optimal strategy for a deductive game is regarded as a. game-tree search, then each internal node of the game tree indicates a state while every leaf represents a final state. 13.
(25) Definition 5. The external path length (or called EPL for short) is the sum of the. depth of all leaves of the game tree. Definition 6. The number of queries needed by the codebreaker in the expected case. (also called the expected number of queries) is L/k, where L is the external path length of the game tree formed by the codebreaker’s strategy and k is the number of all possible codes in the game. Definition 7. A strategy discussed in the study refers to one of the options that the. codebreaker can choose. Each strategy has its corresponding game tree. Trivially, the codebreaker has a lot of possible strategies. Definition 8. An optimal strategy in the expected case is the strategy which has the. minimum expected number of queries. In other words, the external path length of the game tree should be minimized. Definition 9. An optimal strategy in the worst case is the strategy which has the. minimum pessimistic number of queries. Hence, the height of the game tree should be minimized. Definition 10. An equivalence transformation is defined as a composition of a. permutation on the set of symbols and a permutation on the set of digits. Thus, a query g1 is said to be equivalent to another query g2 if there exists an equivalence transformation t such that g 2 = t (g1 ) . This concept is presented by Neuwirth [53]. Definition 11. Suppose the codebreaker has made i-1 queries, named as g1, g2, …, gi-1,. then two codes u1 and u2 at the i-th query are called strategy equivalent if. g1 , g 2 ,..., g i−1 , u2 = t ( g1 , g 2 ,..., g i−1 , u1 ) . In other words, we can 14.
(26) only take u1 as a representative for computing an optimal strategy if u1, u2, …, and uj are strategy equivalent. 012. 3A. 012. 3B 120 2A. 3A. 120. 3B 201 013. 1A2B. 3A. 3A. 201. 013. 1A1B 032. 3A. 032. 1A1B 021. 3A. 021. 312. 3B 1A1B. 102. 3A. 3A. 312. 102. 3B 023. 3A. 023. 210. 3B 302. 3A. 3A. 210. 302. 1A1B 031 2B. 3A. 031. 2B 213. 2B 132. 3A. 3A. 213. 132. 2B 103. 3A. 103. 310. 3A. 310. 2A 123. 3A. 123. 1A1B. 1A2B. 203. 130. 3A. 3A. 203. 130. 3B. 2B. 301 230. 3A. 3A. 301. 230. 2A 231. 3A. 231. 1A2B 2B. 320 321. 3A 3A. Figure 3. A strategy for 3×4 AB game 15. 320 321.
(27) Figure 3, which is used for illustrating the above terminologies, is a codebreaker’s strategy for 3×4 AB game. In the game, the codemaker comes up with a secret code consisting of 3 digits out of 4 symbols, i.e., 0, 1, 2, and 3. A response, which is one of [3, 0], [2, 0], [1, 2], [1, 1], [0, 3], and [0, 2], is received by the codebreaker in each ply. Consequently, the codebreaker entails investigating the code with making use of those responses. Each circle appearing in Figure 3 represents a state and the number in it is a query made by the codebreaker at that moment while this state is encountered. Every double-lined square means a leaf of the game tree or a final state. The text above each arrow means the response offered by the codemaker. Note that the same notations will be adopted in the following discussions. Some phenomena are able to be verified easily from Figure 3. First, there are totally 24 possible secret codes as the game starts and thus, these 24 codes are eligible at that moment. Meanwhile, the set yielded by the 24 codes is the state at the beginning. It is also obvious that the 24 leaves in the tree imply final states. Moreover, Figure 3 exhibits that the external path length is 1×1 + 2×5 + 3×9 + 4×9 = 74 and the expected number of queries required by the codebreaker is equal to 74/24 ≈ 3.083 as well. Meanwhile, the pessimistic number of queries is 4 since the height of the game tree is 4.. 1.6 Organization of the Dissertation This research proposes a series of theoretical-pruning optimization algorithms and mathematical proofs for deductive games and therefore, the following studies are composed of five major parts. In Chapter 2, a complete search algorithm, depth-first backtracking algorithm with branch-and-bound pruning, is introduced to address Mastermind. Meanwhile, an admissible heuristic, which can be applied to various deductive games, is presented as well. Chapter 3 demonstrates a refined 16.
(28) branch-and-bound algorithm with speed-up techniques for AB game in the expected case. Three useful techniques for accelerating the speed of the search algorithm are brought up. In Chapter 4, 3×n AB games is investigated and a sophisticated method, called structural reduction, is developed to explain the worst situation in this game. Chapter 5 presents a variation of AB game, AB game with an unreliable response. An important theorem for deductive games is proven and two algorithms based on it, which are two-phase optimization algorithm with theoretical pruning and pigeonhole-principle-based verification algorithm with theoretical pruning, are proposed. Fortunately, an exact bound of the number of queries needed for the problem is achieved because the upper and lower bounds resulting from the two methods are equal. Chapter 6 concludes with remarkable results in our study and some future work. Moreover, two appendixes, which contain the detailed information on some proofs, are attached at the end of the dissertation.. 17.
(29) Chapter 2 Depth-First Backtracking Algorithm with Branch-and-Bound Pruning. An optimal strategy in the expected case for Mastermind has already been proposed by Koyama and Lai [47] in 1993 by using an exhaustive search but that study took too much time to search the strategy. Therefore, a more efficient algorithm, called depth-first backtracking algorithm with branch-and-bound pruning or abbreviated to DBB, is developed for solving Mastermind in this chapter. Compared to other heuristic methods, DBB can guarantee to yield the optimal tactic if the search procedure finishes. Moreover, an admissible heuristic, which can be applied to various deductive games, is presented as well. Section 2.1 gives an intuitive concept of our proposed approach. Section 2.2 introduces our depth-first backtracking algorithm with branch-and-bound pruning for Mastermind. In Section 2.3, some experimental results are discussed. Section 2.4 summarizes our concluding remarks in the chapter and a critical issue is mentioned for future research.. 2.1 Introduction Mastermind, whose dimension is 4×6, is a two-player game and both of two 18.
(30) players involved are the codemaker and the codebreaker. Suppose that the set of the six symbols, which may appear in secret codes, is S = {0, 1, 2, 3, 4, 5}. Thus, there are 64 = 1296 valid secret codes in Mastermind. Meanwhile, there are also 14 legal responses, which are [4, 0], [3, 0], [2, 2], [2, 1], [2, 0], [1, 3], [1, 2], [1, 1], [1, 0], [0, 4], [0, 3], [0, 2], [0, 1], and [0, 0]. The other definitions and properties are described in Chapter 1 and so, they are omitted here. A complete algorithm with a novel pruning technique, named as a depth-first backtracking algorithm with branch-and-bound pruning (DBB), is proposed to solve the problem. The idea of our scheme is similar to the admissible heuristic in the A* search. The A* search is a tree search algorithm which finds a best path from a given initial state to a given goal with the lowest cost. The algorithm will terminate if a best solution is found. However, a complete search is conceptually required for our problem. Hence, DBB will search the full game tree and prune the unnecessary queries by using an admissible heuristic. The following sections will demonstrate the sophisticated algorithm and its power of searching.. 2.2 The Depth-first Backtracking Algorithm with Branch-and-Bound Pruning A large number of real-world problems can be modeled as optimization problems or games. A search algorithm is therefore a general approach for them. Unfortunately, most of these problems are NP-hard or PSPACE. In other words, it has to take exponential time to search for an optimal solution. Thus, there are plenty of pruning techniques published in the literature such as A* search [62], branch-and-bound pruning [52], and so on. Previous pruning approaches are appropriate for optimization problems since 19.
(31) their goal is to find a best solution in the search space. So, the search ends when it is found. A complete search is theoretically required to our problem because of the considerations of the optimal strategy in the expected case. Hence, traditional pruning approaches may not easily be applied to our problem directly. A novel pruning technique based on the admissible heuristic in the A* search is proposed to solve the problem. In Section 2.2.1, the framework of our depth-first backtracking algorithm with branch-and-bound pruning (DBB) is introduced. Section 2.2.2 illustrates the detailed operations of our scheme.. 2.2.1 The Framework of DBB The idea of our scheme is similar to the admissible heuristic in the A* search. The A* search is a tree (graph) search algorithm which finds a best path from a given initial state to a given goal with the lowest cost. The algorithm will terminate if a best solution is found. However, a complete search is conceptually required for our problem. Hence, DBB will search the full game tree and prune the unnecessary queries by using an admissible heuristic. Notice that a solution described here means a strategy for the codebreaker to identify a secret code with respect to our problem.. ... .... h' current state estimated cost = h' + h*. q1. s = actual cost. q2. ... h *: the theoretical lower bound. .. final state final state. Figure 4. The scenario of branch-and-bound pruning 20.
(32) Figure 4 shows a scenario of DBB. Suppose that h’ is the cost from the root to the current state and h* is the cost from the current state to the final state. Then, h* is called admissible if it never overestimates the cost to reach the final state. In other words, the actual cost is less than or equal to h’ + h*. It can also be viewed as a theoretical lower bound for the problem we deal with. Our scheme traverses the game tree in depth-first fashion until a final state is reached. It then gets an actual cost s which is initially assigned to be the current-best solution. Note that the actual cost s results from the query q1 in its traversed path. Afterwards, it soon backtracks to its parent, e.g., the current state, and picks one of the other queries, e.g., the query q2, and uses an admissible heuristic to estimate the cost h* of q2. The search continues if s is larger than h’ + h*. Otherwise, a cut happens because s is less than or equal to h’ + h*. In other words, there is no need to expand the branch of q2 and the correctness of the algorithm is still maintained. This continues in a similar manner until the full game tree is searched. DBB (state v) 01. if (a final state is reached) then return the current-best solution s;. 02. Expand v;. 03. for (each branch q of v). 04. h = ESTIMATE( q);. // ESTIMATE is an admissible heuristic of predicting the cost from q to a final state.. 05. if (h' + h* < s) then. // h' is the actual cost from the start state tov.. 07 08. // Each q is a branch of v.. *. 06. // Final state indicates the leaf of the game tree.. DBB (the states resulting from q);. // Search recursively from the states resulting from q.. Cut the branch q;. // A cut happens if h' + h * ≥ s.. else. Figure 5. The depth-first backtracking algorithm with branch-and-bound pruning A rough sketch of the entire algorithm is exhibited in Figure 5. It is especially important to notice that DBB always maintains a current-best solution s during the search. Hence, DBB goes through the downward direction at first until a final state is reached. It therefore gets a current-best solution (s is updated). Then, DBB backtracks 21.
(33) and starts to estimate h* in each of the other queries. Unnecessary branches of the queries will never be expanded. Note that it updates s constantly when final states are encountered. So, DBB will finally obtain an optimal solution when the full game tree has been traversed completely.. 2.2.2 DBB for Mastermind in the Expected Case In this section, we will deal with Mastermind in the expected case. First, the pruning technique applied to Mastermind is introduced in Section 2.2.2.1. Second, the admissible heuristic we used is designed and explained carefully in the follow-up section. Eventually, an optimal strategy is found as a result of applying DBB to this problem.. 2.2.2.1 DBB for Mastermind According to the analyses in Table 1, the search space for Mastermind is (1296×14)5 ≈ 1021. Therefore, it takes much time to find an optimal strategy by searching the game tree completely. A pruning technique adopted by DBB is used to save a lot of time instead of making an exhaustive search. Figure 6 shows the game tree of Mastermind by applying DBB. The circles in the Figure 6 mean the states which are the sets of eligible secret codes while the diamonds are the possible queries the codebreaker can choose (1296 valid queries in each ply). In the game tree, the 14 branches produced by the codemaker’s responses should be traversed completely and the 1296 branches expanded by the codebreaker may be pruned by the admissible heuristic since we are aiming at finding an optimal strategy for the codebreaker. Let’s consider the situation exhibited in Figure 6. The traversal to the subtrees of q1 (in bold style) is just finished and q2 is now taken into account. An estimated value h* is obtained with the use of the admissible function. The subtrees below q2 do not have to be expanded if the result of expanding q1 is better than h*. This is the key idea of DBB 22.
(34) and the search can thus be completed in a more reasonable time. Note that the correctness of DBB is preserved because of the admissible heuristic.. Figure 6. The game tree of Mastermind by applying DBB. 2.2.2.2 The Admissible Heuristic for Deductive Games Now the most critical issue is how to design an admissible heuristic function to estimate the theoretical lower bound h*. Note that minimizing the number of queries in the expected case is the same as minimizing the external path length of the game tree. So, the concept of volumes introduced by Huang et al. [38] is involved to get the theoretical maximum bounds for the 14 classes (responses). In order to make sense, the term, “response”, is replaced by “class” here. We know that different queries in a certain ply result in distinct distributions of the eligible codes in 14 classes. The distribution discussed here is the sizes of 14 classes resulting from a certain query. Thus, the volume of a class [x, y] is defined as the maximum value of the numbers of the eligible codes when the codebreaker makes all the valid queries in one ply and the codemaker responses with [x, y]. In the beginning, at the root of Figure 6, there is a 23.
(35) total of 1296 secret codes. While the first query is considered, there are 5 nonequivalent queries in 1296 possible codes, i.e., “0000”, “0001”, “0011”, “0012”, and “0123” for the codebreaker [47]. If the codebreaker queries “0000” and the codemaker gives the response [1, 0], then we can derive that there are 500 possible secret codes. Similarly, if the codebreaker queries “0001”, “0011”, “0012”, or “0123”, and the codemaker gives the response [1, 0], then we can derive that there are 317, 256, 182, and 108 possible secret codes, respectively. So, the volume of the class [1, 0] is set to be 500, the maximum value of these numbers: 500, 317, 256, 182, and 108. With the use of Get_volume function (see Huang et al. [38]) based on the above idea, the volumes of the 14 classes (responses) are obtained as in Table 4. Table 4. The volumes of 14 classes calculated by Get_volume function class volume. [4, 0] [2, 2] [1, 3] [0, 4] [3, 0] [2, 1] [1, 2] [0, 3] [2, 0] [1, 1] [0, 1] [0, 2] [1, 0] [0, 0] 1. 6. 8. 9. 20. 48. 132. 136. 150. 252. 308. 312. 500. 625. The same principle of the extended pigeonhole principle presented by Chen et al. [18] is therefore employed to estimate the lower bounds of the queries needed. However, there are major differences between the problem in the previous study (Chen et al. [18]) and this problem we consider now. Only the worst case among the 14 classes is considered for the codemaker in that paper. The so-called “worst case” denotes the response (class) which will result in the maximum number of queries required by the codebreaker. But each class should be taken into account for our problem. The heuristic function here has to calculate the “theoretical optimal” number of queries in the expected case for a certain query (or called the lower bound of a certain query) for the codebreaker. Suppose that the lower bound of a query q is assessed by the codebreaker. The query q results in 14 classes. It will assume that there exists an 24.
(36) optimal strategy such that all of the eligible codes in each class may be divided evenly in the following queries. The rated value calculated by this heuristic for a state (one of the 14 classes) is the external path length (EPL) of the subtree that is yielded by the theoretical optimal strategy we imagine. So, the actual expected number of queries is thus larger than or equal to the estimated value. Trivially, the heuristic is admissible because a theoretical optimal strategy is assumed to rate the EPL of the subtree of each class formed by q. Moreover, it can be applied to any deductive games by adjusting the number of legal classes (the number of legal responses the codemaker can give) and its volume of each legal class since any other specific knowledge do not have to be considered. In other words, the lower bound of a query q by utilizing this heuristic is equal to the summation of each EPL with respect to 14 classes plus the size of the state, which is the original state before q is made.. Figure 7. An example of the calculation of the admissible heuristic for Mastermind A simple example to illustrate the calculation of the EPL regarding some class (state) yielded by q is shown in Figure 7 with the use of the proposed admissible heuristic. Given a state with a size of 17, as shown in Figure 5, we imagine that the theoretical optimal strategy will divide the 17 eligible codes into 14 classes evenly without exceeding the corresponding volumes. The number in the lower half of the 25.
(37) circle is the volume of each class and the number in the upper half is the number of eligible codes in it. Since there is 1 leaf at level 1, 13 leaves at level 2, and 3 leaves at level 3, it is obvious that the external path length of the tree is 1×1 + 2×13 + 3×3 = 36 in the ideal situation. Thus, the external path length of the example must be smaller than or equal to the actual expected number of queries. It is therefore easy to see that the heuristic is admissible because it never overestimates the expected number of queries.. 2.3 Experimental Results In order to analyze the performance of the proposed DBB, we demonstrate the results of the original version of Mastermind (4×6 Mastermind) and another version of Mastermind, which is 3×5 Mastermind. 3×5 Mastermind has smaller search space in the case of 3 digits with 5 possible symbols. That is to say that it has 53 = 125 possible secret codes totally. Note that the equivalent properties proposed by Neuwirth [53] are able to reduce the search space. For example, “0000” is equivalent to “1111” at the first query because the numbers, 1 and 2, are both not used before. With the considerations of the properties, there are five nonequivalent queries at the first query, which are “0000”, “0001”, “0011”, “0012”, and “0123”. The branching factor in the first ply changes from 14×1296 to 14×5 eventually. This technique has also been implemented in our programs in order to speed up the search. Besides the comparison between 3×5 Mastermind and 4×6 Mastermind, we also investigate the effect of the traversing order during the search. In other words, we have to decide which query is promising when several queries are encountered after the current state is visited. To deal with this issue, we estimate the lower bounds of the child states by making use of the admissible heuristic before they are expanded. We sort their lower bounds and traverse these queries order-by-order in accordance 26.
(38) with their values. The smaller the value is, the earlier the traversal is. All experiments were run on a dedicated PC with an AMD Opteron 252 processor. The experimental results are exhibited in Table 5. Table 5. The experimental results of two versions of Mastermind 3×5. 4×6. Mastermind. Mastermind. DFS. > 10 hr.. > 10 days. DBB. 38.68 sec.. 43.76 hr.. DBB (promising query). 11.21 sec.. 9.5 hr.. External path length. 451. 5625. DFS is the abbreviation of depth-first search while the term, “promising query”, means that DBB expands the queries in nondecreasing order according to the values of lower bounds. We can see that DBB is able to obtain the optimal strategies for the two versions and their corresponding external path length is 451 and 5625, respectively. This means that the expected number of queries is about 4.34 (≈5625/1296) for Mastermind if we apply the optimal strategy in the expected case. The results also show that DBB with the considerations of promising queries has the best performance. Without the judgement of promising queries, DBB will traverse a lot of useless queries. That is to say that most queries will be cut if DBB expands queries in the correct order. From the experimental results, DFS has very poor performance doubtlessly since it is certainly an exhaustive search. Hence, DFS can not search the full game tree in a reasonable time and the total number of the states it has to expand is still unknown. On the other hand, DBB is significantly superior to and is over 25 times faster than DFS. Totally, there are 137834651 states expanded by DBB. The results also reveal that the larger the search space is, the more important the pruning technique is. 27.
(39) 2.4 Chapter Conclusion Previously, an exhaustive search was applied to find the optimal strategy for Mastermind. But it may not be adopted in other harder problems or games because of its huge search time. In this chapter, a more efficient depth-first backtracking algorithm with branch-and-bound pruning (DBB) for Mastermind in the expected case is introduced, and an alternative optimal strategy is obtained eventually. Moreover, an admissible heuristic, which can be applied to various deductive games, is presented as well. From the experimental results, the effect of expanding promising queries during the search is significant to the performance of DBB. Meanwhile, DBB is significantly superior to and is over 25 times faster than the traditional search algorithm. How to design a more precise admissible heuristic is yet another critical issue. Furthermore, it may be interesting to compare our method with other search algorithms or other heuristics mentioned in the previous studies with the consideration of the qualities of solutions and the search time.. 28.
(40) Chapter 3 Refined Branch-and-Bound Algorithm with Speed-up Techniques. Another famous deductive game is AB game, which is popular in Asia and England. However, to date, there have been no optimal expected-case strategies for AB game in formal literature since its appearance. Since the complexity of these deductive games grows at an exponential rate with higher dimensions, DBB can not be directly applied to efficiently solve AB game in the expected case. In this chapter, a refined branch-and-bound algorithm with speed-up techniques, which is abbreviated to RBB, is demonstrated for AB game in the expected case. This algorithm is based on DBB and three useful techniques such as the incremental update of the lower bounds, the hashing technique, and the reduction of equivalent queries are invented to integrate with it. Therefore, RBB will lead to the hope that the optimal tactic of AB game in the expected case is attained. Section 3.1 reviews our handled problem and compares the search space between Mastermind and AB game. Section 3.2 introduces a refined branch-and-bound algorithm while new techniques and significant improvements are demonstrated here as well. In Section 3.3, some experimental results and discussions are given. Section 3.4 summarizes the 29.
(41) remarkable results in this chapter.. 3.1 Introduction AB game, which is also called “Bulls and Cows” in England, is another popular deductive game around the world for decades as well. Its dimension is 4×10 and there are also two opponents involved in this game, which are called the codemaker and the codebreaker respectively. There are ten symbols appearing in possible secret codes of AB game, e.g., 0, 1, 2, …, and 9. Note that the repeated symbols are not allowed in a single secret code. Thus, there are 10!/(10-4)! = 5040 valid secret codes in AB game. Meanwhile, the 14 legal responses of AB game, which are [4, 0], [3, 0], [2, 2], [2, 1], [2, 0], [1, 3], [1, 2], [1, 1], [1, 0], [0, 4], [0, 3], [0, 2], [0, 1], and [0, 0], are the same as those of Mastermind. The accurate definitions are exhibited in Chapter 1 and therefore, these descriptions are omitted here. The search space, which means all possible strategies the codemaker and the codebreaker can adopt, for 4×6 Mastermind and 4×10 AB game is compared in the following equation:. (5040 ×14)7 (1296 ×14)5. > 1012. Notice that the upper part of the equation is the search space for 4×10 AB game while the lower one is that for 4×6 Mastermind. Clearly, the search space for 4×10 AB game is far larger than that for 4×6 Mastermind. Moreover, the search space represents the required time to discover an optimal strategy for the codebreaker since the expected number of queries is considered. Hence, it is clear that the difficulty of solving AB game is much harder than that of solving Mastermind. To the best of our knowledge, the optimal strategy of 4×10 AB game for the codebreaker has never been discovered and meanwhile, its corresponding expected 30.
(42) number of queries has not been determined yet due to its difficulty. In Chapter 2, a fruitful pruning framework, DBB, relied upon the admissible heuristic in the A* search was proposed to solve 4×6 Mastermind. However, it is not capable of solving 4×10 AB game right away since it has much huger search space than 4×6 Mastermind. In this chapter, our goal aims at finding an optimal strategy of 4×10 AB game for the codebreaker to minimize the expected number of queries.. 3.2 A Refined Branch-and-Bound Algorithm with Speed-up Techniques A full search is theoretically conducted to our problem so as to consider the optimal tactic in the expected case. Because DBB can not solve the concerned problem directly, a refined approach based on it is demonstrated. Furthermore, the idea of DBB will be introduced briefly to make this chapter self-contained.. 3.2.1 The Fundamental Framework in Terms of Branch-and-Bound Pruning Although DBB proposed in Chapter 2 can not explore the game tree directly within a reasonable time, it remains a vital basis for us. Therefore, a brief introduction to DBB is still given here. DBB and the A* search act in a similar way. The A* search is regarded as a tree (graph) search algorithm which looks for a path from an initial state to a final goal with the lowest cost. It will terminate if a best solution is obtained. However, a full search is necessarily engaged in dealing with our problem because we need to calculate the value of the external path length of the game tree. Hence, DBB will carry out a search of the whole game tree and prune the useless states by taking advantage of an admissible heuristic. Notice that a solution described here denotes a 31.
(43) strategy for the codebreaker to identify a secret code with respect to our problem. Let h’ denote the cost from the root to the current state and h* be an estimated cost from the current state to a final state. Then, h* is called admissible if it never overrates the cost to reach the final state. In other words, the actual cost is less than or equal to h’ + h*. It can also be viewed as a theoretical lower bound for the problem we cope with. DBB first traverses the game tree in depth-first fashion until a final state is reached. It then gets an actual cost s which is initially assigned to be the current-best solution. Note that the actual cost s results from the query q1 in its traversed path. Afterwards, it soon backtracks to the current state, and picks one of the other queries, e.g., the query q2, and uses an admissible heuristic to estimate the cost h* of q2. The search continues if s is larger than h’ + h*. Otherwise, a cut happens because s is less than or equal to h’ + h*. This continues in a similar manner until the full game tree is searched. Figure 4 shows roughly the scenario and Figure 5 exhibits this algorithm. The current state is what we consider presently. An admissible heuristic will be used to estimate its cost h* and thus, h’ + h* is compared with the actual cost s to determine whether it should be cut or not. In accordance with the analyses in Table 1, the search space for AB game is (5040×14)7 ≈ 1034. Figure 8 shows the game tree of AB game by applying DBB directly. The circles in Figure 8 mean the states which are the sets of eligible secret codes while the diamonds are the valid queries the codebreaker can choose (5040 queries in each ply). In the game tree, the 14 branches yielded by the codemaker’s responses should be traversed completely and the 5040 branches expanded by the codebreaker may be pruned by the admissible heuristic since we are aiming at finding an optimal strategy for the codebreaker. Let’s take the situation exhibited in Figure 8 into account. The search to the subtrees of q1 (in bold style) is just finished and q2 is 32.
(44) now considered. An estimated value h* is obtained by using the admissible function. The subtrees below q2 do not have to be expanded if the result of expanding q1 is better than h*.. Figure 8. The game tree of AB game by applying DBB directly The admissible heuristic presented in Section 2.2.2.2 with slight modifications of the volume of each legal class is utilized to estimate the lower bounds of the numbers of queries. Likewise, different queries in a certain ply result in different distributions of the eligible codes in the 14 responses. Similarly, the volume of a response [x, y] is also defined as the maximum value of the numbers of the eligible codes when the codemaker responses with [x, y]. The first query made by the codebreaker has only one choice here because all of the queries are equivalent at the first query. As a result,. g = “0123” is selected as the representative for the first query. The numbers of eligible codes of each class after g is made form these volumes are concluded in Table 6. From the analyses in Section 2.2.2.2, the actual expected number of queries is thus larger than or equal to the value of estimations. An example to illustrate the 33.
(45) calculation of the EPL about some class (state) is shown in Figure 9. Notice that the only difference between Figure 7 and Figure 9 is their volumes. Providing a state with a size of 17, as shown in Figure 9, we imagine that the theoretical optimal strategy will distribute the 17 codes into 14 responses evenly without exceeding the corresponding volumes and so does the optimal strategy in each of the following levels of the game tree. The number in the lower half of the circle is the volume of each response and the number in the upper half is the number of secret codes in it. Since there is 1 leaf at level 1, 13 leaves at level 2, and 3 leaves at level 3, it is obvious that the external path length of the tree is 1×1 + 2×13 + 3×3 = 36. Thus, the actual external path length of a state with a size of 17 must be larger than or equal to 36. The heuristic is therefore admissible because it never overrates the expected number of queries. Table 6. The volumes of 14 classes in AB game class volume. [4, 0] [3, 0] [2, 2] [2, 1] [2, 0] [1, 3] [1, 2] [1, 1] [1, 0] [0, 4] [0, 3] [0, 2] 1. 24. 6. 72. 180. 8. 216. 720. 480. 9. 264. 1260. [0, 1] [0, 0] 1440. 360. 17. 2 6. 1 6. 2 8. 1 6. 2 9. 1 24. 1 72. 1 180. 1 216. 1 264. 1 360. 1 480. 1 720. 1. 1260. 1. 1440. 1 6. Figure 9. An example of the calculation of the admissible heuristic for AB game 34.
(46) 3.2.2 The State-of-the-Art Techniques The fundamental framework has been reviewed in Section 3.2.1. It has been proven dramatically that the algorithm is highly suitable for addressing deductive games. However, it is not enough to handle AB game in the expected case. Some attributions of the game are observed seriously so that three critical challenges are summarized as follows. . How to increase the precision of the lower bound?. . How to avoid expanding the redundant states?. . How to prune the equivalent queries?. An optimal strategy will be discovered providing that these challenges are able to be coped with totally. Fortunately, a refined branch-and-bound algorithm with. speed-up techniques (RBB) is designed and three useful techniques contained in it are introduced and discussed among the follow-up contents.. 3.2.2.1 Technique 1: Incremental Updates of the Lower Bounds During the gaming process, there will be generally 5040 queries for the codebreaker in each ply. When a new state is met, a current best solution s is acquired after DBB undertakes a search to one of the 5040 branches. Thus, DBB has to check other queries and two possible cases are going to take place. One case is that the rated lower bound of the query is less than s, and then the search into it occurs. The other case is that the search will be omitted according to branch-and-bound pruning because. s outperforms this rated lower bound. Obviously, this mechanic of the process comes up with a new idea naturally. The percentage of the cutoffs is going to increase markedly if the estimated lower bounds become higher by calculating it more accurately. Concrete steps are offered below. Suppose that the current best solution s is provided by the query g. There is 35.
(47) another query called g* that we analyze now and moreover, s* refers to the lower bound which has been rated by the admissible heuristic H at the beginning. Assume that s* is less than s. It is clear that the subtree yielded by g* has to be explored in accordance with our proposed manner. However, we come up with an idea to update the lower bound incrementally during the exploring process of g* so as to stop searching as soon as possible providing that s* becomes equal to or larger than s. In the detailed considerations, g* divides the current state into 14 classes (responses) so that H is able to rate its external path length (EPL) with the 14 classes. Hence, s* is summed with the 14 rated numbers. When every class has been traversed, a real EPL of this class is available as well. Once a real cost of exploring the class has been acquired, an update to s* happens immediately. Furthermore, s* grows gradually as we explore these classes one by one.. .... g. g*. s* s. s* grows gradually during the search to this subtree.. Figure 10. A situation that depicts the exploring process When an update happens, s competes with the up-to-date s* at the same time. The exploring process of g* stops if s* is equal to or larger than s. Otherwise, it keeps on 36.
Outline
相關文件
Here, a deterministic linear time and linear space algorithm is presented for the undirected single source shortest paths problem with positive integer weights.. The algorithm
In the algorithm, the cell averages in the resulting slightly non-uniform grid is updated by employing a finite volume method based on a wave- propagation formulation, which is very
In particular, we present a linear-time algorithm for the k-tuple total domination problem for graphs in which each block is a clique, a cycle or a complete bipartite graph,
Then, it is easy to see that there are 9 problems for which the iterative numbers of the algorithm using ψ α,θ,p in the case of θ = 1 and p = 3 are less than the one of the
Although we have obtained the global and superlinear convergence properties of Algorithm 3.1 under mild conditions, this does not mean that Algorithm 3.1 is practi- cally efficient,
In summary, the main contribution of this paper is to propose a new family of smoothing functions and correct a flaw in an algorithm studied in [13], which is used to guarantee
• The randomized bipartite perfect matching algorithm is called a Monte Carlo algorithm in the sense that.. – If the algorithm finds that a matching exists, it is always correct
• The randomized bipartite perfect matching algorithm is called a Monte Carlo algorithm in the sense that.. – If the algorithm finds that a matching exists, it is always correct