Download presentation
Presentation is loading. Please wait.
Published byBrittney Lawson Modified over 9 years ago
1
More on A*; Preview of Logic; Local Search Henry Kautz
2
A* Search start.dist := 0; insert(start, h(start), heap); while (! empty(heap)) do node := deleteMin(heap); if GoalTest(node) then return node; for each edge do if (child is new or node.dist + length < child.dist) then child.dist = node.dist + length; child.prev = node; if (child is in the heap) then decreaseKey(child, child.dist+h(child), heap); else insert(child, child.dist+h(child), heap); end return FAIL;
3
A* Search start.dist := 0; insert(start, h(start), heap); while (! empty(heap)) do node := deleteMin(heap); if GoalTest(node) then return node; for each edge do if (child is new or node.dist + length < child.dist) then child.dist = node.dist + length; child.prev = node; if (child is in the heap) then decreaseKey(child, child.dist+h(child), heap); else insert(child, child.dist+h(child), heap); end return FAIL; if a goal node is removed from the heap, the shortest path has been found
4
A* Search start.dist := 0; insert(start, h(start), heap); while (! empty(heap)) do node := deleteMin(heap); if GoalTest(node) then return node; for each edge do if (child is new or node.dist + length < child.dist) then child.dist = node.dist + length; child.prev = node; if (child is in the heap) then decreaseKey(child, child.dist+h(child), heap); else insert(child, child.dist+h(child), heap); end return FAIL; child might have already been removed from heap; if so, it will be added to the heap again
5
Details A node is never added to the heap twice if h is admissible and monotonic for all nodes n for all edges h(n) c + n Never becomes less accurate (more optimistic) as it nears a goal –Manhattan distance is monotonic –Book calls this condition “consistent”
6
Example: Non-Monotonic, Admissible Heuristic S AB G 41 1 8 h=10 h=5h=9
7
Example: Non-Monotonic, Admissible Heuristic S AB G 41 1 8 h=10 h=5h=9
8
Example: Non-Monotonic, Admissible Heuristic S AB G 41 1 8 h=10 h=5h=9
9
Example: Non-Monotonic, Admissible Heuristic S AB G 41 1 8 h=10 h=5h=9
10
Example: Non-Monotonic, Admissible Heuristic S AB G 41 1 8 h=10 h=5h=9
11
Example: Non-Monotonic, Admissible Heuristic S AB G 41 1 8 h=10 h=5h=9
12
Search and Reasoning State-space search can be viewed as a special kind of logical reasoning Explicitly representing problems logically, however, has many advantages: –Clarifies thinking –Increased expressivity –Tap into rich set of algorithms for logical inference
13
Reasoning and Search Logical reasoning can be viewed as a special kind of state space search –State = agent’s explicit beliefs –Operator = making a logical deduction Thinking in terms of state space search will help us understand how to create practical inference algorithms
14
Propositional Logic Sentence Translation N-Queens
15
Greedy Local Search state = start; while ! GoalTest(state) do state := arg min { h(s) | s in Neighbors(state) } end return state; Terminology: –“neighbors” instead of “children” –heuristic h(s) is the “objective function”, no need to be admissible No guarantee of finding a solution –sometimes: probabilistic guarantee Best goal-finding, not path-finding Many variations
16
N-Queens Local Search state = start; while ! GoalTest(state) do state := arg min { h(s) | s in Neighbors(state) } end return state; start = put down N queens randomly GoalTest = Board has no attacking pairs h = number of attacking pairs neighbors = move one queen randomly
17
N-Queens Local Search state = start; while ! GoalTest(state) do state := arg min { h(s) | s in Neighbors(state) } end return state; Alternative: start = put a queen on each square with 50% probability GoalTest = Board has N queens, no attacking pairs h = number of attacking pairs + | #queens – N | neighbors = add or delete one queen
18
Sudoku
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.