52
1 Chapter 2 Heuristic Search Techniques

Chapter 2 Heuristic Search Techniques

  • Upload
    ora

  • View
    55

  • Download
    1

Embed Size (px)

DESCRIPTION

Chapter 2 Heuristic Search Techniques. Defining the problem. A water jug problem: 4-gallon and 3-gallon no marker on the bottle pump to fill the water into the jug How can you get exactly 2 gallons of water into the 4-gallons jug?. 4. 3. A state space search. (x,y) : order pair - PowerPoint PPT Presentation

Citation preview

  • Chapter 2Heuristic Search Techniques

  • Defining the problemA water jug problem: 4-gallon and 3-gallon

    no marker on the bottlepump to fill the water into the jugHow can you get exactly 2 gallons of water into the 4-gallons jug? 4

    3

  • A state space search(x,y) : order pair x : water in 4-gallons x = 0,1,2,3,4 y : water in 3-gallons y = 0,1,2,3start state : (0,0)goal state : (2,n) where n = any value

    Rules : 1. Fill the 4 gallon-jug (4,-) 2. Fill the 3 gallon-jug(-,3) 3. Empty the 4 gallon-jug(0,-) 4. Empty the 3 gallon-jug(-,0)

  • Water jug rules1 (x,y)(4,y)Fill the 4-gallon jug if x < 42 (x,y)(x,3)Fill the 3-gallon jun if y < 33 (x,y)(x d,y)Pour some water out of if x > 0 the 4-gallon jun4 (x,y)(x,y d)Pour some water out of if y > 0the 3-gallon jun5 (x,y)(0,y)Empty the 4-gallon jun if x > 0on the ground6 (x,y)(x,0)Empty the 3-gallon jun if y > 0on the ground

  • Water jug rules7 (x,y) (4,y (4 - x))Pour water from the if x+y >= 4 and y > 03-gallon jug into the 4-gallon jug until the 4-gallon jug is full8 (x,y) (x (3 - y),3)Pour water from the if x+y >= 3 and y > 0 4-gallon jug into the 3-gallon jug until the 3-gallon jug is full9 (x,y) (x+y,0)Pour all water from the if x+y 0from the 3-gallon juginto the 4-gallon jug10 (x,y) (0,x + y ) Pour all water from the if x + y 0 from the 4-gallon juginto the 3-gallon jug11 (0,2) (2,0) Pour the 2 gallons from the 3-gallon jug into the 4-gallon jug12 (2,y) (0,y)Empty the 2 gallons inthe 4-gallon jug on the ground

  • A water jug solution4-Gallon Jug3-Gallon JugRule Applied00032309332427025 or 12209 or 11 Solution : path / plan

  • Formal description of a problem Define a state space that contains all the possible configurations of the relevant objects.Specify state/states that describes the situation of start state.Specify state/states that describes the situation of goal state.Specify the set of rules.assumption, generalization

  • Search Tree

    Water jug problem.

  • Search GraphWater jug problem.CycleWhen will the search terminate?

  • Homework 2 (1%)Is there any other solution for a water jug problem?If there is some other solution, describe in an order pair of how to solve it.due date ................................

  • Question answering questionMarcus was a man.Marcus was a Pompeian.Marcus was born in 40 A.D.All men are mortal.All Pompeians died when the volcano erupted in 79 A.D.No mortal lives longer than 150 years.It is now 1991 A.D.

    Is Marcus alive?

  • Solution 11. Marcus was man. axiom 14. All men are mortal. axiom 48. Marcus is mortal. 1,43. Marcus was born in 40 A.D. axiom 37. It is now 1991 A.D. axiom 79. Marcus age is 1951 years. 3,76. No mortal lives longer than 150 years axiom 610. Marcus is dead. 8,6,9

  • 7. It is now 1991 A.D. axiom 75. All Pompeians died in 79 A.D. axiom 511. All Pompeians are dead now. 7,5 2. Marcus was a Pompeian. axiom 212. Marcus is dead. 11,2Solution 2

  • The bank president ate a dish of pasta salad with the fork.Understanding a sentence bank = financial institution / a side of a riverdish = eat dish / eat pastapasta salad : dog food food with dog meat?with a fork : with ....her friend. / with vegetable.

    solution : state of the world

  • A blocks worldon(c,a). on(b,d).ontable(a).ontable(d).clear(b).clear(c). hand_empty. acdb

  • Seven problem characteristicsDecomposable ProblemBlock world problemCan solution steps be ignored or undone?Ignorable : theorem provingsolution steps can be ignoredRecoverable : 8 puzzle solution steps can be undone (backtracking)Irrecoverable : chesssolution steps can not be undone

  • Seven problem characteristics3. Is the universe predictable?8-puzzel (yes)bridge (no) but we can use probabilities of each possible outcomescontrolling robot arm gear of the arm might stuckhelping the lawyer to decide how to defend his client against a murder charge.4. Is a good solution absolute or relative? - formal inference methods - More than one solution? - traveling salesman problem

  • Seven problem characteristics5. Is the solution a state or a path?- consistent interpretation for the sentence- water jug problem path / plan6. What is the role of knowledge?knowledge for perfect program of chess (need knowledge to constrain the search)newspaper story understanding (need knowledge to recognize a solution)7. Does the task require interaction with a person? solitary/ conversational

  • Production systemA set of rules.Knowledge contains information for a particular task.A control strategy.resolve conflict rule.Breadth-first searchDepth-first search

  • Breadth-first searchAlgorithm BFS:Create a variable called NODE-LIST and set it to the initial state.Until a goal state is found or NODE-LIST is empty do:Remove the first element from NODE-LIST and call it E. If NODE-LIST was empty, quit.For each way that each rule can match the state described in E do:Apply the rule to generate a new state.If the new state is a goal state, quit and return this state.Otherwise, add the new state to the end of NODE-LIST.

  • Advantage BFSwill not trapped exploring a blind alley ( )if there is a solution, DFS is guaranteed to find it.if there are multiple solutions, a minimum solution will be found.

  • Depth-first searchAlgorithm DFS:If the initial state is a goal state, quit and return success.Otherwise, do the following until success or failure is signaled:Generate a successor, E, of the initial state. If there are no more successors, signal failure.Call Depth-First Search with E as the initial state.If success is returned, signal success. Otherwise continue in this loop.

  • Advantage DFSrequire less memory may find a solution without examining much of the search space.

  • Production SystemWorking memoryProduction set = Rules Figure 5.3Trace Figure 5.4Data driven Figure 5.9Goal driven Figure 5.10Iteration #Working memoryConflict setsRule fired

  • Production System

  • Production System

  • Production System

  • Production System

  • And-Or Graph start

    Data driven Goal drivenbcdefgoal

  • Heuristic SearchHeuriskein to discover (Greek word)Heuristic is a technique that improves the efficiency of the search process. - It is often useful to introduce heuristics based on relatively unstructured knowledge.- can not use Mathematical analysis.Heuristic function : is the function that maps from problem state descriptions to measures of desirability, usually represent as number guide the most profitable direction

  • Generate-and-testGenerate all possible solutionsDFS + backtrackingGenerate randomlyTest function ANSWER yes/noAlgorithm page 64....

  • Hill ClimbingSimilar to generate-and-testTest function + heuristic function Tell how close to the goal stateEX : In unfamiliar city without a map... downtown = tall building... heuristic function = distance between downtown and tall buildingStop Goal state meetNo alternative state to move

  • Simple Hill ClimbingTask specific knowledge into the control processIs one state better than anotherIf the new state is ...better... than the current state then make it the current stateAlgorithm page 66.....

  • Steepest-Ascent Hill ClimbingConsider all moves from the current stateSelect the best one as the next stateAlgorithm page 67....

  • Hill Climbing CharacteristicLocal methodIt decides what to do next by looking only at the immediate consequences of its choice (rather than by exhaustively exploring all of the consequence)Look only one more ahead

  • Local heuristic functionBlock world figure 3.1 p. 69....Local heuristic function1. Add one point for every block that is resting on the thing it is supposed to be resting on.2. Subtract one point for every block that is sitting on the wrong thing.Initial state score = 4 (6-2)C,D,E,F,G,H correct = 6 A,B wrong = -2Goal state score = 8 A,B,C,D,E,F,F,H all correct

    Heuristic function : max value

  • Local heuristic functionCurrent state : figure 3.1 A B C D E F G H Score = 6 (B C D E F G H correct)Block world figure 3.2 p. 69case a : Next state score = 4 (6-2)case b : Next state score = 4 (6-2)case c : Next state score = 4 (6-2)All 3 cases a,b,c ...have no better score than the current state = 6 so we... Stop Local minimum problem local Heuristic function : max value

  • Global heuristic functionBlock world figure 3.1 p. 69....Global heuristic functionFor each block that has the correct support structure ()add one point for every block in the support structure. For each block that has an incorrect support structure, subtract one point for every block in the existing support structure.

  • Global heuristic functioninitial state score = -28C = -1, D = -2, E = -3, F = -4, G = -5, H = -6, A = -7C 1 D 2 ...

    Goal state score = 28B = 1, C = 2, D = 3, E = 4, F = 5, G = 6, H = 7B 1 C 2 ....Heuristic function : max value

  • Global heuristic functionCurrent state : figure 3.1 A B C D E F G H Score = -21 (C = -1, D = -2, E= -3, F = -4, G= -5, H = -6)Block world figure 3.2 p. 69Next state : move to case(c)case a = -28 same as initial statecase b = -16 (C = -1, D = -2, E= -3, F = -4, G= -5, H = -1)case c = -15 (C = -1, D = -2, E= -3, F = -4, G= -5) No Local minimum problem Its workHeuristic function : max value

  • New heuristic function1. Incorrect structure are bad and should be taken apart.More subtract score 2. Correct structure are good and should built up.Add more score for the correct structure.

    How to find a perfect heuristic function? dead end

  • Best first searchHeuristic function : min valuepage 74

  • OR GRAPH : each of its branches represents an alternative problem-solving patternwe assumed that we could evaluate multiple paths to the same node independently of each otherwe want to find a single path to the goaluse DFS : select most promising path use BSF : when no promising path/ switch part to receive the better value old branch is not forgottensolution can be find without all completing branches having to expanded

    Best first search

  • f = g + h g: cost from initial state to current state h: estimate cost current state to goal statef: estimate cost initial state to goal stateOpen node : most promising nodeClose node : keep in memory, already discover node.Best first search

  • Best First Search Algorithmpage 75-76

  • A* algorithmh : count the nodes that we step down the path, 1 level down = 1 point, except the root node.Underestimate : we generate up until f (F)= 6 > f (C) =5 then we have to go back to C.1 level2 level3 levelf(E) = f(C) = 5 f = g + h Heuristic function : min value

  • A* algorithm f = g + h 1 level2 level3 level Overestimate : Suppose the solution is under D but we will not generate D because f(D) = 6 > f(G) = 4.page 76Heuristic function : min value

  • And-Or Graph / Treecan be solved by decomposing them into a set of smaller problems And arcs are indicated with a line connecting all the components

  • And-Or Graph / Treeeach arc with the successor has a cost of 1

    3+4+1+115+10+1+19+27+1+1choose lowest value = f(B) = 5+1ABEF = 17 + 1Heuristic function : min value

  • And-Or Graph / Tree

  • To solve a problemDefine the problem precisely. Specify the problem space, and the starting and goal state (s).Analyze the problem to determine where it falls with respect to seven important issues.Identify and represent the knowledge required by the task.Choose one or more techniques for problem solving , and apply those techniques to the problem.