Heuristic Search Overview Deskripsi Limitations of Uninformed Search
Total Page:16
File Type:pdf, Size:1020Kb
2/13/2012 Jurusan Teknik Informatika – Universitas Widyatama Overview • Deskripsi • Heuristic Search Heuristic Search – Generate-and Test – Hill Climbing – Best-First Search Pertemuan : 3 – Greedy Best-First-Search – A* Dosen Pembina : – Iterative Deeping A* Sriyani Violina • Latihan Praktikum III Danang Junaedi • Tugas Rumah III Susetyo Bagas Baskoro IF-UTAMA 1 IF-UTAMA 2 Deskripsi Limitations of uninformed search • Pertemuan ini mempelajari bagaimana memecahkan • 8-puzzle suatu masalah dengan teknik searching. – Avg. solution cost is about 22 steps • Metode searching yang dibahas pada pertemuan ini – branching factor ~ 3 adalah heuristic search atau informed search yang – Exhaustive search to depth 22: terdiri dari: • 3.1 x 10 10 states – Generate-and Test – E.g., d=12, IDS expands 3.6 million states on average – Hill Climbing – Best-First Search [24 puzzle has 10 24 states (much worse)] – Greedy Best-First-Search – A* – Iterative Deeping A* IF-UTAMA 3 IF-UTAMA 4 IF-UTAMA 1 2/13/2012 Recall tree search… Recall tree search… This “strategy” is what differentiates different search algorithms IF-UTAMA 5 IF-UTAMA 6 Informed methods add Heuristic domain-specific information Merriam-Webster's Online Dictionary • Add domain-specific information to select the best Heuristic (pron. \hy u-’ris-tik\): adj. [from Greek heuriskein to discover.] involving or serving as an aid to learning, discovery, or problem-solving by experimental and path along which to continue searching especially trial-and-error methods The Free On-line Dictionary of Computing (15Feb98) • Define a heuristic function h(n) that estimates the heuristic 1. <programming> A rule of thumb, simplification or educated guess that reduces or limits the search for solutions in domains that are difficult and poorly “goodness” of a node n. understood. Unlike algorithms, heuristics do not guarantee feasible solutions and – Specifically, h(n) = estimated cost (or distance) of minimal are often used with no theoretical guarantee. 2. <algorithm> approximation algorithm. cost path from n to a goal state . From WordNet (r) 1.6 • The heuristic function is an estimate of how close we heuristic adj 1: (computer science) relating to or using a heuristic rule 2: of or relating to a general formulation that serves to guide investigation [ant: algorithmic] n : a are to a goal, based on domain-specific information commonsense rule (or set of rules) intended to increase the probability of solving some problem [syn: heuristic rule, heuristic program] that is computable from the current state description. IF-UTAMA 7 IF-UTAMA 8 IF-UTAMA 2 2/13/2012 Heuristic function Heuristic functions for 8-puzzle • Heuristic: • 8-puzzle – Definition: “using rules of thumb to find answers” – Avg. solution cost is about 22 steps – branching factor ~ 3 • Heuristic function h(n) – Exhaustive search to depth 22: – Estimate of (optimal) cost from n to goal • 3.1 x 10 10 states. – h(n) = 0 if n is a goal node – A good heuristic function can reduce the search process. – Example: straight line distance from n to Bucharest • Note that this is not the true state-space distance • Two commonly used heuristics • It is an estimate – actual state-space distance can be higher – h1 = the number of misplaced tiles • h (s)=8 – Provides problem-specific knowledge to the search algorithm 1 – h2 = the sum of the distances of the tiles from their goal positions (Manhattan distance). • h2(s)=3+1+2+2+2+3+3+2=18 IF-UTAMA 9 IF-UTAMA 10 Heuristics Weak vs. strong methods • All domain knowledge used in the search is encoded in the heuristic function h() . • We use the term weak methods to refer to methods that are • Heuristic search is an example of a “ weak method ” because of extremely general and not tailored to a specific situation. the limited way that domain-specific information is used to • Examples of weak methods include solve the problem. – Means-ends analysis is a strategy in which we try to represent the current • Examples: situation and where we want to end up and then look for ways to shrink the differences between the two. – Missionaries and Cannibals: Number of people on starting river bank – Space splitting is a strategy in which we try to list the possible solutions to – 8-puzzle: Number of tiles out of place a problem and then try to rule out classes of these possibilities. – 8-puzzle: Sum of distances each tile is from its goal position – Subgoaling means to split a large problem into several smaller ones that • In general: can be solved one at a time. – h(n) ≥ 0 for all nodes n • Called “weak” methods because they do not take advantage of – h(n) = 0 implies that n is a goal node more powerful domain-specific heuristics – h(n) = ∞ implies that n is a dead-end that can never lead to a goal IF-UTAMA 11 IF-UTAMA 12 IF-UTAMA 3 2/13/2012 When to use ? Advantages • The input data are limited or inexact. • Simple to understand. • Optimization model can not be used as for complex • Easier to implement and explain. reality. • Save formulation time. • Reliable and exact algorithm is not available. • Save computer programming and storage requirements. • Save computational time and thus real time in decision making. • It is possible to improve the efficiency of the • Often produce multiple acceptable solution. optimization process. • Usually it is possible to state a theoretical or empirical measure of • Symbolic rather than numerical processing is involved. the solution quality. • Quick decision must be made . • Incorporate intellegence to guide the search. • Computerization is not feasible. • It is possible to apply efficient heuristics to models that could be solved with mathematical programming. IF-UTAMA 13 IF-UTAMA 14 Disadvantages Generate-and-Test • An optimal solution can not be guaranteed. • It is a depth first search procedure since complete solutions must be generated before they can be tested. • There may be too many exceptions to the rules. • In its most systematic form, it is simply an exhaustive search of the problem space. • Sequential decision choices may fail to anticipate • Operate by generating solutions randomly. the future consequences of each choice. • Also called as British Museum algorithm • The interdependencies of one part pf a system • If a sufficient number of monkeys were placed in front of a set of typewriters, and left alone long enough, then they would can sometime have a profound influence on the eventually produce all the works of shakespeare. whole system. • Dendral: which infers the struture of organic compounds using NMR spectrogram. It uses plan-generate-test. IF-UTAMA 15 IF-UTAMA 16 IF-UTAMA 4 2/13/2012 Generate-and-Test Algorithm Hill Climbing 1. Generate a possible solution. For some problems, this • Is a variant of generate-and test in which feedback from the test procedure is used to help the generator decide means generating a particular point in the problem which direction to move in search space. space. For others it means generating a path from a • The test function is augmented with a heuristic function start state that provides an estimate of how close a given state is to 2. Test to see if this is actually a solution by comparing the goal state. the chosen point or the endpoint of the chosen path to • Computation of heuristic function can be done with the set of acceptable goal states. negligible amount of computation. • Hill climbing is often used when a good heuristic 3. If a solution has been found, quit, Otherwise return to function is available for evaluating states but when no step 1. other useful knowledge is available. IF-UTAMA 17 IF-UTAMA 18 Hill climbing Hill climbing algorithm • Example: using the straight-line distance: 1. QUEUE <<----path only containing the root; SS 2. WHILE QUEUE is not empty • Perform depth-first, AND goal is not reached AA 10.4 DD 8.98.9 BUT : DODO remove the first path from the QUEUE ;; • instead of left-to-right create new paths (to all children); 6.96.9 selection, AA 10.4 EE reject the new paths with loops; • FIRST select the child sort new paths (HEURISTIC) ;; with the best heuristic add the new paths to front of QUEUE ;; 6.76.7BB FF 3.03.0 value GG 3. IFIF goal reached THEN success; ELSE failure; IF-UTAMA 19 IF-UTAMA 20 IF-UTAMA 5 2/13/2012 Simple Hill Climbing Algorithm Simple Hill Climbing 1. Evaluate the initial state. If it is also goal state, then return it and • The key difference between Simple Hill climbing quit. Otherwise continue with the initial state as the current state. and Generate-and-test is the use of evaluation 2. Loop until a solution is found or until there are no new function as a way to inject task specific operators left to be applied in the current state: a. Select an operator that has not yet been applied to the current state and knowledge into the control process. apply it to produce a new state • Is on state better than another ? For this algorithm b. Evaluate the new state i. If it is the goal state, then return it and quit. to work, precise definition of better must be ii. If it is not a goal state but it is better than the current state, then make it the current state. provided. iii. If it is not better than the current state, then continue in the loop. IF-UTAMA 21 IF-UTAMA 22 Algorithm: Steepest -Ascent Hill Steepest-Ascent Hill Climbing Climbing • This is a variation of simple hill climbing which 1. Evaluate the initial state. If it is also a goal state, then return it and quit.