Nodes are (abstracted) world configurations Arcs represent ...
Transcript of Nodes are (abstracted) world configurations Arcs represent ...
![Page 1: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/1.jpg)
Today
Uninformed Search Methods:
Depth-First Search
Breadth-First Search
Uniform-Cost Search
Informed Search:
A* or “A star”.Sirius? Brightest star in sky.No! search! Main idea: Heuristics.
Admissible.Graph Search: Consistent.
![Page 2: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/2.jpg)
State Space Graphs
State space graph: A mathematicalrepresentation of a search problem
I Nodes are (abstracted) world configurations
I Arcs represent successors (action results)
I The goal test is a set of goal nodes (maybeonly one)
In a state space graph, each state occursonly once!
We can rarely build this full graph in memory (it’stoo big), but it’s a useful idea.
![Page 3: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/3.jpg)
Search Trees
This is now / start
“E”“N”
Possible futures.
A search tree:
A “what if” tree of plans and theiroutcomes
The start state is the root node
Children correspond to successors
Nodes show states, butcorrespond to PLANS that achievethose states
For most problems, we can neveractually build the whole tree
![Page 4: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/4.jpg)
State Space Graphs vs. Search Trees
Each NODE in search tree is an entire PATH in state space graph.
We construct both on demand – and we construct as little as possible.
![Page 5: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/5.jpg)
Tree Search: example.
![Page 6: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/6.jpg)
Depth-First Search
![Page 7: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/7.jpg)
Depth-First Search
Strategy: expand a deepest node first.
Implementation: Fringe is a LIFO stack
![Page 8: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/8.jpg)
Tree Search: example.
![Page 9: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/9.jpg)
Search Algorithm Properties
![Page 10: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/10.jpg)
Search Algorithm Properties
Complete: Guaranteed to find asolution if one exists?
Optimal: Guaranteed to find theleast cost path?
Time complexity?
Space complexity?
Sketch of search tree:b is the branching factorm is the maximum depthsolutions at various depths
Number of nodes in entire tree?1+b+b2 + · · · = O(bm)
![Page 11: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/11.jpg)
Depth-First Search (DFS) Properties
Which nodes expanded?
Some left prefix of the tree.
Could process the whole tree!
If m is finite, takes time O(bm)
How much space does the fringetake?
Only has siblings on path to root,so O(bm)
Is it complete?
m could be infinite, so only if we prevent cycles (more later)
Is it optimal?
No, it finds the “leftmost” solution, regardless of depth or cost
![Page 12: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/12.jpg)
Breadth-First Search
![Page 13: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/13.jpg)
Breadth-First Search
Strategy: expand a shallowestnode first
Implementation: Fringe is a FIFOqueue
![Page 14: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/14.jpg)
Breadth-First Search (BFS) Properties
What nodes does BFS expand? Processes all nodes aboveshallowest solution
Let depth of shallowest solution be sSearch takes time O(bs)
How much space does the fringe take?Has roughly the last tier, so O(bs)
Is it complete?s must be finite if a solution exists,
so yes!
Is it optimal?Only if costs are all 1 (more on costs later).
![Page 15: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/15.jpg)
Quiz: DFS vs BFS
![Page 16: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/16.jpg)
DFS vs BFS
When will BFS outperform DFS?When will DFS outperform BFS?[Demo:dfs/bfsmaze water (L2D6)]
Space versus Time or Quality of Solution.
![Page 17: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/17.jpg)
Video of Demo Maze Water DFS/BFS (part 1)
![Page 18: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/18.jpg)
Video of Demo Maze Water DFS/BFS (part 2)
![Page 19: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/19.jpg)
Next Up.
Iterative Deepening.
Uniform Cost Search.
![Page 20: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/20.jpg)
Iterative Deepening
Idea: get DFS’s space advantagewith BFS’s time / shallow-solutionadvantages
Run a DFS with depth limit 1.If no solution...
Run a DFS with depth limit 2.If no solution ...
Run a DFS with depth limit 3. ....
Isn’t that wastefully redundant?
Generally most work happens in the lowest level searched, so not sobad!
![Page 21: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/21.jpg)
Cost-Sensitive Search
BFS finds the shortest path in terms of number of actions.
It does not find the least-cost path. We will now cover a similaralgorithm which does find the least-cost path.
How?
![Page 22: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/22.jpg)
Uniform Cost Search (Djikstra’s algorithm.)
![Page 23: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/23.jpg)
Uniform Cost Search
Strategy: expand a cheapestnode first:
Fringe is a priority queue (priority:cumulative cost)
![Page 24: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/24.jpg)
Uniform Cost Search (UCS) Properties
What nodes does UCS expand?All nodes cheaper than solution!Solution cost C∗ and arc cost ≥ ε:
depth O(C∗/ε).Time: O(bC∗/ε).
How much space does the fringe take?Last Tier Space: O(bC∗/ε).
Is it complete?Finite solution cost/positive arc weights?Then yes.
Is it optimal?Yes.
![Page 25: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/25.jpg)
Uniform Cost Issues
Remember: UCS exploresincreasing cost contours.
The good:UCS is complete and optimal!
The bad:Goes in every “direction”.
The ugly?Huh?
No information about goal location.
We’ll fix that soon!
[Demo: empty grid UCS (L2D5)][Demo: maze with deep/shallow water DFS/BFS/UCS (L2D7)]
![Page 26: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/26.jpg)
Video of Demo Empty UCS
![Page 27: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/27.jpg)
Video of Demo Maze with Deep/Shallow Water —DFS, BFS, or UCS? (part 1)
![Page 28: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/28.jpg)
Video of Demo Maze with Deep/Shallow Water —DFS, BFS, or UCS? (part 2)
![Page 29: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/29.jpg)
Video of Demo Maze with Deep/Shallow Water —DFS, BFS, or UCS? (part 3)
![Page 30: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/30.jpg)
The One QueueAll these search algorithms are the same except for fringe strategies.
Conceptually, all fringes are priority queues (i.e. collections of nodeswith attached priorities)
Practically, for DFS and BFS, you can avoid the log(n) overhead froman actual priority queue, by using stacks and queues
Can even code one implementation that takes a variable queuingobject.
![Page 31: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/31.jpg)
Search and Models
Search operates over models (state spaces) of the world
The agent doesn’t actually try all the plans out in the real world!
Planning is all “in simulation”
Your search is only as good as your models. . .
![Page 32: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/32.jpg)
Search Gone Wrong?
Model or State Space gone wrong!
![Page 33: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/33.jpg)
![Page 34: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/34.jpg)
CS 188: Artificial Intelligence
Informed Search
![Page 35: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/35.jpg)
Informed Search
Informed SearchHeuristicsGreedy SearchA* SearchGraph Search
![Page 36: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/36.jpg)
Recap: Search
![Page 37: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/37.jpg)
Recap: Search
Search problem:States (configurations of the world)Actions and costsSuccessor function (world dynamics)Start state and goal test
Search tree:Nodes: represent plans for reaching statesPlans have costs (sum of action costs)
Search algorithm:Systematically builds a search treeOrders the fringe (unexplored nodes)
Complete: finds a plan.Optimal: finds least-cost plans
![Page 38: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/38.jpg)
Example: Pancake Problem
Cost: Number of pancakes flipped
![Page 39: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/39.jpg)
Example: Pancake Problem
![Page 40: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/40.jpg)
Example: Pancake Problem
State space graph with costs as weights.
![Page 41: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/41.jpg)
General Tree Search
Action: flip top twoCost: 2
Action: flip all fourCost: 4
Path to reach goal:Flip four, flip three
Total cost: 7
![Page 42: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/42.jpg)
The One Queue
Our search algorithms are thesame except for fringe strategies
I All fringes are priorityqueues: states with priorities.
I DFS, BFS a bit faster usingsimple stack/queues.
I Can code oneimplementation with variablequeuing object.
![Page 43: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/43.jpg)
Uninformed Search
![Page 44: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/44.jpg)
Uniform Cost Search
Strategy: expand lowest path cost.
The good: Complete and optimal!
The bad: Explores options in every“direction”
No information about goal location
![Page 45: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/45.jpg)
Informed Search
![Page 46: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/46.jpg)
Search Heuristics
11.25
10
A heuristic is:
I A function that estimates how close a stateis to a goal
I Designed for a particular search problem
I Examples: Euclidean distance for pathing.Manhattan distance.
![Page 47: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/47.jpg)
Example: Heuristic Function
![Page 48: Nodes are (abstracted) world configurations Arcs represent ...](https://reader030.fdocuments.us/reader030/viewer/2022012806/61bd3e5961276e740b10cd7b/html5/thumbnails/48.jpg)
Example: Heuristic Function
Heuristic: the number of the largest pancake that is still out of place