CS B551: E LEMENTS OF A RTIFICIAL I NTELLIGENCE Instructor: Kris Hauser 1.

Slides:



Advertisements
Similar presentations
Numbers Treasure Hunt Following each question, click on the answer. If correct, the next page will load with a graphic first – these can be used to check.
Advertisements

EcoTherm Plus WGB-K 20 E 4,5 – 20 kW.
1 A B C
AGVISE Laboratories %Zone or Grid Samples – Northwood laboratory
Simplifications of Context-Free Grammars
Variations of the Turing Machine
Angstrom Care 培苗社 Quadratic Equation II
AP STUDY SESSION 2.
1
Slide 1Fig 25-CO, p.762. Slide 2Fig 25-1, p.765 Slide 3Fig 25-2, p.765.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
David Burdett May 11, 2004 Package Binding for WS CDL.
Create an Application Title 1Y - Youth Chapter 5.
Process a Customer Chapter 2. Process a Customer 2-2 Objectives Understand what defines a Customer Learn how to check for an existing Customer Learn how.
Add Governors Discretionary (1G) Grants Chapter 6.
CALENDAR.
1 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt BlendsDigraphsShort.
CHAPTER 18 The Ankle and Lower Leg
The 5S numbers game..
Media-Monitoring Final Report April - May 2010 News.
Break Time Remaining 10:00.
The basics for simulations
Turing Machines.
Table 12.1: Cash Flows to a Cash and Carry Trading Strategy.
PP Test Review Sections 6-1 to 6-6
MM4A6c: Apply the law of sines and the law of cosines.
Briana B. Morrison Adapted from William Collins
Operating Systems Operating Systems - Winter 2010 Chapter 3 – Input/Output Vrije Universiteit Amsterdam.
Exarte Bezoek aan de Mediacampus Bachelor in de grafische en digitale media April 2014.
Copyright © 2012, Elsevier Inc. All rights Reserved. 1 Chapter 7 Modeling Structure with Blocks.
Biology 2 Plant Kingdom Identification Test Review.
Adding Up In Chunks.
MaK_Full ahead loaded 1 Alarm Page Directory (F11)
1 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt Synthetic.
Artificial Intelligence
When you see… Find the zeros You think….
Before Between After.
12 October, 2014 St Joseph's College ADVANCED HIGHER REVISION 1 ADVANCED HIGHER MATHS REVISION AND FORMULAE UNIT 2.
Subtraction: Adding UP
1 Lab 17-1 ONLINE LESSON. 2 If viewing this lesson in Powerpoint Use down or up arrows to navigate.
: 3 00.
5 minutes.
1 Non Deterministic Automata. 2 Alphabet = Nondeterministic Finite Accepter (NFA)
1 hi at no doifpi me be go we of at be do go hi if me no of pi we Inorder Traversal Inorder traversal. n Visit the left subtree. n Visit the node. n Visit.
1 Let’s Recapitulate. 2 Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Essential Cell Biology
Converting a Fraction to %
Numerical Analysis 1 EE, NCKU Tien-Hao Chang (Darby Chang)
CSE20 Lecture 15 Karnaugh Maps Professor CK Cheng CSE Dept. UC San Diego 1.
Clock will move after 1 minute
famous photographer Ara Guler famous photographer ARA GULER.
PSSA Preparation.
Physics for Scientists & Engineers, 3rd Edition
Select a time to count down from the clock above
Copyright Tim Morris/St Stephen's School
1.step PMIT start + initial project data input Concept Concept.
1 Dr. Scott Schaefer Least Squares Curves, Rational Representations, Splines and Continuity.
1 Decidability continued…. 2 Theorem: For a recursively enumerable language it is undecidable to determine whether is finite Proof: We will reduce the.
1 Non Deterministic Automata. 2 Alphabet = Nondeterministic Finite Accepter (NFA)
CS B551: E LEMENTS OF A RTIFICIAL I NTELLIGENCE Instructor: Kris Hauser 1.
Bioinformatics Programming 1 EE, NCKU Tien-Hao Chang (Darby Chang)
Blind Search by Prof. Jean-Claude Latombe
1 Blind (Uninformed) Search (Where we systematically explore alternatives) R&N: Chap. 3, Sect. 3.3–5.
1 CS B551: Elements of Artificial Intelligence Instructor: Kris Hauser
Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 CS121 – Winter 2003.
Russell and Norvig: Chapter 3, Sections 3.4 – 3.6
Presentation transcript:

CS B551: E LEMENTS OF A RTIFICIAL I NTELLIGENCE Instructor: Kris Hauser 1

A GENDA Searching, data structures, and algorithms Breadth-first search Depth-first search Uniform-cost search 2

D EFINING A S EARCH P ROBLEM 3  State space S  Successor function: x  S  SUCC (x)  2 S  Initial state s 0  Goal test: x  S  GOAL? (x) =T or F  Arc cost S

S TATE G RAPH 4  Each state is represented by a distinct node  An arc (or edge) connects a node s to a node s’ if s’  SUCC (s)  The state graph may contain more than one connected component

S OLUTION TO THE S EARCH P ROBLEM  A solution is a path connecting the initial node to a goal node (any one)  The cost of a path is the sum of the arc costs along this path  An optimal solution is a solution path of minimum cost  There might be no solution ! 5 I G

S EARCH G RAPH != S TATE G RAPH If states are allowed to be revisited, the search tree may be infinite even when the state space is finite If states are allowed to be revisited, the search tree may be infinite even when the state space is finite

S EARCH G RAPH N ODE != S TATE 7 PARENT-NODE STATE Depth of a node N = length of path from root to N (depth of the root = 0) BOOKKEEPING 5Path-Cost 5Depth RightAction Expanded yes... CHILDREN

F RINGE OF S EARCH T REE The fringe is the set of all search nodes that haven’t been expanded yet

S EARCH S TRATEGY The fringe is the set of all search nodes that haven’t been expanded yet The fringe is implemented as a priority queue FRINGE INSERT(node,FRINGE) REMOVE(FRINGE) The ordering of the nodes in FRINGE defines the search strategy 9

S EARCH A LGORITHM #1 SEARCH#1 1. If GOAL?(initial-state) then return initial-state 2. INSERT(initial-node,FRINGE) 3. Repeat: 4. If empty(FRINGE) then return failure 5.N  REMOVE(FRINGE) 6.s  STATE(N) 7.For every state s’ in SUCCESSORS(s) 8.Create a new node N’ as a child of N 9.If GOAL?(s’) then return path or goal state 10.INSERT(N’,FRINGE) 10 Expansion of N

B LIND S EARCH S TRATEGIES 11

B LIND S TRATEGIES Breadth-first Bidirectional Depth-first Depth-limited Iterative deepening Uniform-Cost (variant of breadth-first) 12 Arc cost = 1 Arc cost = c(action)    0

B READTH -F IRST S TRATEGY New nodes are inserted at the end of FRINGE FRINGE = (1)

B READTH -F IRST S TRATEGY New nodes are inserted at the end of FRINGE 14 FRINGE = (2, 3)

B READTH -F IRST S TRATEGY New nodes are inserted at the end of FRINGE 15 FRINGE = (3, 4, 5)

B READTH -F IRST S TRATEGY New nodes are inserted at the end of FRINGE 16 FRINGE = (4, 5, 6, 7)

P ERFORMANCE M EASURES Completeness A search algorithm is complete if it finds a solution whenever one exists [What about the case when no solution exists?] Optimality A search algorithm is optimal if it returns a minimum-cost path whenever a solution exists Complexity It measures the time and amount of memory required by the algorithm 17

I MPORTANT P ARAMETERS Maximum number of successors of any state  branching factor b of the search tree Minimal length (≠ cost) of a path between the initial and a goal state  depth d of the shallowest goal node in the search tree 18

E VALUATION b: branching factor d: depth of shallowest goal node Breadth-first search is: Complete? Not complete? Optimal? Not optimal? 19

E VALUATION b: branching factor d: depth of shallowest goal node Breadth-first search is: Complete Optimal if step cost is 1 Number of nodes generated: ??? 20

E VALUATION b: branching factor d: depth of shallowest goal node Breadth-first search is: Complete Optimal if step cost is 1 Number of nodes generated: 1 + b + b 2 + … + b d = ??? 21

E VALUATION b: branching factor d: depth of shallowest goal node Breadth-first search is: Complete Optimal if step cost is 1 Number of nodes generated: 1 + b + b 2 + … + b d = (b d+1 -1)/(b-1) = O(b d )  Time and space complexity is O(b d ) 22

T IME AND M EMORY R EQUIREMENTS d# NodesTimeMemory msec11 Kbytes 411,1111 msec1 Mbyte 6~ sec100 Mb 8~ sec10 Gbytes 10~ hours1 Tbyte 12~ days100 Tbytes 14~ years10,000 Tbytes 23 Assumptions: b = 10; 1,000,000 nodes/sec; 100bytes/node

T IME AND M EMORY R EQUIREMENTS d# NodesTimeMemory msec11 Kbytes 411,1111 msec1 Mbyte 6~ sec100 Mb 8~ sec10 Gbytes 10~ hours1 Tbyte 12~ days100 Tbytes 14~ years10,000 Tbytes 24 Assumptions: b = 10; 1,000,000 nodes/sec; 100bytes/node

R EMARK If a problem has no solution, breadth-first may run forever (if the state space is infinite or states can be revisited arbitrary many times) ?

B IDIRECTIONAL S TRATEGY 26 2 fringe queues: FRINGE1 and FRINGE2 s Time and space complexity is O(b d/2 )  O(b d ) if both trees have the same branching factor b Question: What happens if the branching factor is different in each direction?

D EPTH -F IRST S TRATEGY New nodes are inserted at the front of FRINGE FRINGE = (1)

D EPTH -F IRST S TRATEGY New nodes are inserted at the front of FRINGE FRINGE = (2, 3)

D EPTH -F IRST S TRATEGY New nodes are inserted at the front of FRINGE FRINGE = (4, 5, 3)

D EPTH -F IRST S TRATEGY New nodes are inserted at the front of FRINGE

D EPTH -F IRST S TRATEGY New nodes are inserted at the front of FRINGE

D EPTH -F IRST S TRATEGY New nodes are inserted at the front of FRINGE

D EPTH -F IRST S TRATEGY New nodes are inserted at the front of FRINGE

D EPTH -F IRST S TRATEGY New nodes are inserted at the front of FRINGE

D EPTH -F IRST S TRATEGY New nodes are inserted at the front of FRINGE

D EPTH -F IRST S TRATEGY New nodes are inserted at the front of FRINGE

D EPTH -F IRST S TRATEGY New nodes are inserted at the front of FRINGE

E VALUATION b: branching factor d: depth of shallowest goal node m: maximal depth of a leaf node Depth-first search is: Complete? Optimal? 38

E VALUATION b: branching factor d: depth of shallowest goal node m: maximal depth of a leaf node Depth-first search is: Complete only for finite search tree Not optimal Number of nodes generated (worst case): 1 + b + b 2 + … + b m = O(b m ) Time complexity is O(b m ) Space complexity is O(bm) [or O(m)] [Reminder: Breadth-first requires O(b d ) time and space] 39

D EPTH -L IMITED S EARCH Depth-first with depth cutoff k (depth at which nodes are not expanded) Three possible outcomes: Solution Failure (no solution) Cutoff (no solution within cutoff) 40

I TERATIVE D EEPENING S EARCH Provides the best of both breadth-first and depth-first search Main idea: 41 IDS For k = 0, 1, 2, … do: Perform depth-first search with depth cutoff k (i.e., only generate nodes with depth  k) Totally horrifying !

I TERATIVE D EEPENING 42

I TERATIVE D EEPENING 43

I TERATIVE D EEPENING 44

P ERFORMANCE Iterative deepening search is: Complete Optimal if step cost =1 Time complexity is: (d+1)(1) + db + (d-1)b 2 + … + (1) b d = O(b d ) Space complexity is: O(bd) or O(d) 45

C ALCULATION db + (d-1)b 2 + … + (1) b d = b d + 2b d-1 + 3b d-2 +… + db = (1 + 2b b -2 + … + db -d )  b d  (  i=1,…,  ib (1-i) )  b d = b d (b/(b-1)) 2 46

N UMBER OF G ENERATED N ODES (B READTH - F IRST & I TERATIVE D EEPENING ) d = 5 and b = 2 47 BFID 11 x 6 = 6 22 x 5 = x 4 = x 3 = x 2 = x 1 = /63 ~ 2

N UMBER OF G ENERATED N ODES (B READTH - F IRST & I TERATIVE D EEPENING ) d = 5 and b = BFID ,0003,000 10,00020, , ,111123, ,456/111,111 ~ 1.111

R ECAP BFS: Complete, optimal O(b d ) time and space DFS: Not complete nor optimal O(bd) space, unbounded time ID: Complete, optimal O(bd) space, O(b d ) time 49

R ELATED T OPICS Non-unit costs Revisited states Heuristic search 50

N ON - UNIT C OSTS Each arc has cost c   > 0 The cost of the path to each node N is g(N) =  costs of arcs Breadth-first is no longer optimal 51 Why?

U NIFORM -C OST S EARCH Expand node in FRINGE with the cheapest path 52 S 0 1 A 5 B 15 C SG A B C G 11 G 10 Suboptimal path!

S EARCH A LGORITHM #2 SEARCH#2 1. If GOAL?(initial-state) then return initial-state 2. INSERT(initial-node,FRINGE) 3. Repeat: 4. If empty(FRINGE) then return failure 5.N  REMOVE(FRINGE) 6.s  STATE(N) 7.If GOAL?(s) then return path or goal state 8.For every state s’ in SUCCESSORS(s) 9.Create a new node N’ as a child of N 10.INSERT(N’,FRINGE) 53 The goal test is applied to a node when this node is expanded, not when it is generated.

R EVISITED S TATES 54 8-queens No assembly planning Few puzzle and robot navigation Many search tree is finitesearch tree is infinite

A VOIDING R EVISITED S TATES Requires comparing state descriptions Breadth-first search: Store all states associated with generated nodes in VISITED If the state of a new node is in VISITED, then discard the node 55

A VOIDING R EVISITED S TATES Requires comparing state descriptions Breadth-first search: Store all states associated with generated nodes in VISITED If the state of a new node is in VISITED, then discard the node 56 Implemented as hash-table or as explicit data structure with flags

E XPLICIT D ATA S TRUCTURES Robot navigation VISITED: array initialized to 0, matching grid When grid position (x,y) is visited, mark corresponding position in VISITED as 1 Size of the entire state space! 57

H ASH T ABLES N-1 VISITED: Hash table of size N Hash function: map from S to {0,…,N-1} If hash function is chosen carefully to minimize chance of collision, then membership testing on M states averages O(M/N) time

A VOIDING R EVISITED S TATES Depth-first search: Solution 1: Store all states associated with nodes in current path in VISITED If the state of a new node is in VISITED, then discard the node ?? 59

A VOIDING R EVISITED S TATES Depth-first search: Solution 1: Store all states associated with nodes in current path in VISITED If the state of a new node is in VISITED, then discard the node Only avoids loops Solution 2: Store all generated states in VISITED If the state of a new node is in VISITED, then discard the node Same space complexity as breadth-first ! 60

A VOIDING R EVISITED S TATES IN U NIFORM -C OST S EARCH For any state S, when the first node N such that STATE(N) = S is expanded, the path to N is the best path from the initial state to S So: When a node is expanded, store its state into VISITED When a new node N is generated: If STATE(N) is in VISITED, discard N If there exits a node N’ in the fringe such that STATE(N’) = STATE(N), discard the node -- N or N’ -- with the highest- cost path 61

S EARCH A LGORITHM #3 SEARCH#3 1. If GOAL?(initial-state) then return initial-state 2. INSERT(initial-node,FRINGE) 3. Repeat: 4. If empty(FRINGE) then return failure 5.N  REMOVE(FRINGE) 6.s  STATE(N) 7.Add s to VISITED 7.If GOAL?(s) then return path or goal state 8.For every state s’ in SUCCESSORS(s) 9.Create a new node N’ as a child of N 10.If s’ is in VISITED then discard N’ 11.If there is N’’ in FRINGE with STATE(N’)=STATE(N’’) 12. If g(N’’) is lower than g(N’) then discard N’ 13.Otherwise discard N’’ 14.INSERT(N’,FRINGE) 62

H OMEWORK Readings: R&N Ch