Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky Uninformed Search Lecture 4 What are common search strategies that operate given only a search problem ? How do they compare ? Uninformed Search May 22, 2017 1
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky Agenda • A quick refresher • DFS, BFS, ID-DFS, UCS • Unification! Uninformed Search May 22, 2017 2
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky Search Problem Formalism Defined via the following components: • The initial state the agent starts in • A successor/transition function – S (x) = {action+cost->state} • A goal test , which determines whether a given state is a goal state • A path cost that assigns a numeric cost to each path A solution is a sequence of actions leading from initial state to a goal state ( optimal = lowest path cost) Together the initial state and successor function implicitly define the state space , the set of all reachable states Uninformed Search May 22, 2017 3
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky State Space Graph • State space graph: A mathematical representation of a search problem – Nodes are (abstracted) world G configurations a – Arcs represent successors c b (action results) – The goal test is a set of goal e node(s) d f • In a search graph, each state S h occurs only once! p r q • We can rarely build this full graph in memory (i.e. it’s too big), but it’s a useful idea Uninformed Search May 22, 2017 4
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky Search Tree • A “what if” tree of plans and their outcomes “N”, 1.0 “E”, 1.0 • The start state is the root node • Children correspond to successors • Nodes show states, but correspond to PLANS that achieve those states • For most problems, we can never actually build the whole tree Uninformed Search May 22, 2017 5
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky Searching for Solutions Basic idea: incrementally build a search tree until a goal state is found • Root = initial state • Expand via transition function to create new nodes • Nodes that haven’t been expanded are leaf nodes and form the frontier ( open list ) • Different search strategies choose next node to expand (as few as possible!) • Use a closed list to prevent expanding the same state more than once Uninformed Search May 22, 2017 6
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky General Algorithm Queue (FIFO) Stack (LIFO) Priority Queue Uninformed Search May 22, 2017 7
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky Evaluating a Search Strategy Solution Efficiency • Completeness : does it • Time Complexity : always find a solution if number of nodes one exists? generated/expanded • Optimality : does it • Space Complexity : always find a least-cost maximum number of solution? nodes in memory Uninformed Search May 22, 2017 8
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky Depth-First Search (DFS) Uninformed Search May 22, 2017 9
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky DFS Example Strategy: expand a G a a deepest node first c c b b e e Implementation: d d f f Fringe is a LIFO stack S h h p p r r q q S e p d q e h r b c h r p q f a a q c p q f G a q c G a Uninformed Search May 22, 2017 10
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky Let’s Evaluate! Uninformed Search May 22, 2017 11
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky Search Tree Properties 1 node b b nodes … • B ranching factor b 2 nodes • M aximum depth m tiers • Solutions at various depths b m nodes Number of nodes in the tree? 1 + b + b 2 + …. b m = O(?) b m Uninformed Search May 22, 2017 12
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky DFS Evaluation Time 1 node b • Expands left b nodes … – Could be whole tree! b 2 nodes • Assuming finite depth, O(b m ) m tiers Space • Only siblings on path, O(bm) b m nodes Complete • Only if finite Optimal • No, ”left-most” w/o regard to cost/depth Uninformed Search May 22, 2017 13
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky Breadth-First Search (BFS) Uninformed Search May 22, 2017 14
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky BFS Example G a Strategy: expand a c b shallowest node first e d f Implementation: Fringe S h is a FIFO queue p r q S e p d Search q e h r b c Tiers h r p q f a a q c p q f G a q c G a Uninformed Search May 22, 2017 15
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky BFS Evaluation Time 1 node b • Processes all nodes b nodes … above shallowest s tiers b 2 nodes solution, O(b s ) b s nodes Space • Has roughly the last tier, so O(b s ) b m nodes Complete • Yes! Optimal • Only if all costs equal (more later) Uninformed Search May 22, 2017 16
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky DFS vs. BFS Empty-DFS Empty-BFS Maze-DFS Maze-BFS Uninformed Search May 22, 2017 17
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky Grounding the Branching Factor Depth Nodes Time Memory 2 110 0.11 msecs 107 KB 4 11,110 11 msecs 10.6 MB 10 6 6 1.1 secs 1 GB 10 8 8 2 mins 103 GB 10 10 10 3 hours 10 TB 10 12 12 13 days 1 PB 14 10 14 3.5 years 99 PB 16 10 16 350 years 10 EB Assumptions • b = 10 Memory often • 1 million nodes/second becomes the limiting factor • 1000 bytes/node Uninformed Search May 22, 2017 18
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky Iterative Deepening DFS (ID-DFS) • Basic idea: DFS b memory with BFS … time/shallow solution – DFS up to 1 – DFS up to 2 – …. • Generally most work happens in the lowest level searched, so not too wasteful Uninformed Search May 22, 2017 19
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky Cost-Sensitive Search GOAL a 2 2 c b 3 2 1 8 2 e d 3 f 9 8 2 START h 4 2 1 4 p r 15 q • BFS finds the shortest path in terms of number of actions, but it does not find the least-cost path. • We will now cover a similar algorithm which does! Uninformed Search May 22, 2017 20
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky Uniform-Cost Search (UCS) Uninformed Search May 22, 2017 21
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky UCS Example 2 G a c b 8 Strategy: expand a cheapest 1 2 2 e node first 3 d f 9 2 8 S Fringe is a priority queue h 1 (priority: cumulative cost) 1 p r q 15 0 S 9 e p 3 d 1 q 5 17 11 e h r b 4 c 11 16 Cost 7 6 13 h r p q f a a contours q c 8 p q f G a q c 11 10 G a Uninformed Search May 22, 2017 22
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky UCS Evaluation Time b c £ 1 … • O(b C*/ 𝜁 ) c £ 2 C*/ e “tiers” c £ 3 (effective Space depth) • O(b C*/ 𝜁 ) Complete • Yes! Assume optimal solution costs C* and arcs cost at least 𝜁 Optimal • Yes! Uninformed Search May 22, 2017 23
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky UCS vs. DFS vs. BFS • UCS is good and c £ 1 … optimal c £ 2 c £ 3 • However, it still moves in every direction – it’s not informed about goal direction… Empty-UCS Maze-UCS MazeCost-DFS Start Goal MazeCost-BFS MazeCost-UCS Uninformed Search May 22, 2017 24
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky Unification • All these search algorithms are the same except for fringe strategies • Conceptually, all fringes are priority queues (i.e. collections of nodes with attached priorities) • Practically, for DFS and BFS, you can avoid the log(n) overhead from an actual priority queue, by using stacks and queues Uninformed Search May 22, 2017 25
Wentworth Institute of Technology COMP3770 – Artificial Intelligence | Summer 2017 | Derbinsky Uninformed Search Search given only the problem definition DFS BFS UCS Fringe LIFO (stack) FIFO (queue) PQ (path cost) Complete X X Optimal X 𝒫(𝑐 ( ∗ /+ ) 𝒫(𝑐 % ) 𝒫(𝑐 ' ) Time 𝒫(𝑐 ( ∗ /+ ) 𝒫(𝑐 ' ) Space 𝒫(𝑐𝑛) Assumptions: potentially infinite depth, arbitrary positive action costs Uninformed Search May 22, 2017 26
Recommend
More recommend