do you drive? have you thought about how the route plan is created for you in the gps system? how...
TRANSCRIPT
![Page 1: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/1.jpg)
Do you drive? Have you thought about how the route plan is created for you in the GPS system?How would you implement a cross-and-nought computer program?
G51IAI – Search Space & Tree
![Page 2: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/2.jpg)
Introduction to Artificial Intelligence (G51IAI)
Dr Rong QuProblem Space and Search
Tree
![Page 3: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/3.jpg)
G51IAI – Search Space & Tree
Trees
Nodes Root node Children/parent of nodes Leaves
Branches
Average branching factor average number of branches of the nodes in
the tree
JB C
D
E
F
G
A
H
I
![Page 4: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/4.jpg)
G51IAI – Search Space & Tree
Problem Space
Many problems exhibit no detectable regular structure to be exploited, they appear “chaotic”, and do not yield to efficient algorithms
![Page 5: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/5.jpg)
G51IAI – Search Space & Tree
Problem Space
![Page 6: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/6.jpg)
G51IAI – Search Space & Tree
Problem Space
The concept of search plays an important role in science and engineering
In one way, any problem whatsoever can be seen as a search for “the right answer”
![Page 7: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/7.jpg)
G51IAI – Search Space & Tree
Problem Space
Search space Set of all possible solutions to a problem
Search algorithms Take a problem as input Return a solution to the problem
![Page 8: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/8.jpg)
G51IAI – Search Space & Tree
Problem Space
Search algorithms
Uninformed search algorithms (3 hours) Simplest naïve search
Informed search algorithms (2 hours) Use of heuristics that apply domain
knowledge
![Page 9: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/9.jpg)
G51IAI – Search Space & Tree
Problem Space
Often we can't simply write down and solve the equations for a problem
Exhaustive search of large state spaces appears to be the only viable approach
How?
![Page 10: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/10.jpg)
G51IAI – Search Space & Tree
Trees
Depth of a node Number of branches
away from the root node
Depth of a tree Depth of the deepest
node in the tree Examples: TSP vs. game
JB C
D
E
F
G
A
H
I
![Page 11: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/11.jpg)
G51IAI – Search Space & Tree
Trees Tree size
Branching factor b = 2 (binary tree)
Depth d
JB C
D
E
F
G
A
H
I
d nodes at d, 2d total nodes
0 1 1
1 2 3
2 4 7
3 8 15
4 16 31
5 32 63
6 64 127
Exponentially -Combinatorial explosion
![Page 12: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/12.jpg)
G51IAI – Search Space & Tree
Trees JB C
D
E
F
G
A
H
I
Exponentially -Combinatorial explosion
![Page 13: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/13.jpg)
JB C
D
E
F
G
A
H
I
G51IAI – Search Space & Tree
Search Tree
Heart of search techniques
Managing the data structure Nodes: states of problem Root node: initial state of the problem Branches: moves by operator Branching factor: number of
neighborhoods
![Page 14: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/14.jpg)
G51IAI – Search Space & Tree
Search Tree – Define a Problem Space
![Page 15: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/15.jpg)
G51IAI – Search Space & Tree
Search Tree – Example I
![Page 16: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/16.jpg)
G51IAI – Search Space & Tree
Search Tree – Example I
Compared with TSP tree?
![Page 17: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/17.jpg)
G51IAI – Search Space & Tree
Search Tree – Example II
1st level: 1 root node (empty board) 2nd level: 8 nodes 3rd level: 6 nodes for each of the node on the
2nd level (?) …
![Page 18: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/18.jpg)
G51IAI – Search Space & Tree
Search Trees
Issues Search trees grow very quickly The size of the search tree is governed by
the branching factor Even the simple game with branching factor
of 3 has a complete search tree of large number of potential nodes
The search tree for chess has a branching factor of about 35
![Page 19: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/19.jpg)
G51IAI – Search Space & Tree
Search Trees
Claude Shannon delivered a paper in 1949 at a New York conference on how a computer could play chess.
Chess has 10120 unique games (with an average of 40 moves - the average length of a master game).
Working at 200 million positions per second, Deep Blue would require 10100 years to evaluate all possible games.
To put this is some sort of perspective, the universe is only about 1010 years old and 10120 is larger than the number of atoms in the universe.
![Page 20: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/20.jpg)
G51IAI – Search Space & Tree
Implementing a Search- What we need to store
State This represents the state in the state space
to which this node corresponds
Parent-Node This points to the node that generated this
node. In a data structure representing a tree it is usual to call this the parent node
![Page 21: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/21.jpg)
G51IAI – Search Space & Tree
Operator The operator that was applied to generate
this node
Depth The number of branches from the root
Path-Cost The path cost from the initial state to this
node
Implementing a Search- What we need to store
![Page 22: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/22.jpg)
G51IAI – Search Space & Tree
Implementing a Search - Datatype
Datatype node Components:
STATE, PARENT-NODE, OPERATOR, DEPTH, PATH-COST
![Page 23: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/23.jpg)
G51IAI – Search Space & Tree
Using a Tree– The Obvious Solution?
It can be wasteful on space
It can be difficult to implement, particularly if there are varying number of children (as in tic-tac-toe)
It is not always obvious which node to expand next. We may have to search the tree looking for the best leaf node (sometimes called the fringe or frontier nodes). This can obviously be computationally expensive
![Page 24: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/24.jpg)
G51IAI – Search Space & Tree
Using a Tree– Maybe not so obvious
Therefore It would be nice to have a “simpler” data
structure to represent our tree And it would be nice if the next node to be
expanded was an O(1)* operation
*Big O: Notation in complexity theory How the size of input affect the algorithms
computational resource (time or memory) Complexity of algorithms
![Page 25: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/25.jpg)
G51IAI – Search Space & Tree
General Search Function GENERAL-SEARCH (problem, QUEUING-FN)
returns a solution or failure nodes = MAKE-QUEUE(MAKE-NODE(INITIAL-
STATE[problem])) Loop do
If nodes is empty then return failure node = REMOVE-FRONT(nodes) If GOAL-TEST[problem] applied to STATE(node)
succeeds then return node nodes = QUEUING-FN
(nodes,EXPAND(node,OPERATORS[problem])) End
End Function
![Page 26: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/26.jpg)
G51IAI – Search Space & Tree
General Search Function GENERAL-SEARCH (problem, QUEUING-FN)
returns a solution or failure nodes = MAKE-QUEUE(MAKE-NODE(INITIAL-
STATE[problem])) Loop do
If nodes is empty then return failure node = REMOVE-FRONT(nodes) If GOAL-TEST[problem] applied to STATE(node)
succeeds then return node nodes = QUEUING-FN
(nodes,EXPAND(node,OPERATORS[problem])) End
End Function
![Page 27: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/27.jpg)
G51IAI – Search Space & Tree
General Search Function GENERAL-SEARCH (problem, QUEUING-FN)
returns a solution or failure nodes = MAKE-QUEUE(MAKE-NODE(INITIAL-
STATE[problem])) Loop do
If nodes is empty then return failure node = REMOVE-FRONT(nodes) If GOAL-TEST[problem] applied to STATE(node)
succeeds then return node nodes = QUEUING-FN
(nodes,EXPAND(node,OPERATORS[problem])) End
End Function
![Page 28: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/28.jpg)
G51IAI – Search Space & Tree
General Search Function GENERAL-SEARCH (problem, QUEUING-FN)
returns a solution or failure nodes = MAKE-QUEUE(MAKE-NODE(INITIAL-
STATE[problem])) Loop do
If nodes is empty then return failure node = REMOVE-FRONT(nodes) If GOAL-TEST[problem] applied to STATE(node)
succeeds then return node nodes = QUEUING-FN
(nodes,EXPAND(node,OPERATORS[problem])) End
End Function
![Page 29: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/29.jpg)
G51IAI – Search Space & Tree
General Search Function GENERAL-SEARCH (problem, QUEUING-FN)
returns a solution or failure nodes = MAKE-QUEUE(MAKE-NODE(INITIAL-
STATE[problem])) Loop do
If nodes is empty then return failure node = REMOVE-FRONT(nodes) If GOAL-TEST[problem] applied to STATE(node)
succeeds then return node nodes = QUEUING-FN
(nodes,EXPAND(node,OPERATORS[problem])) End
End Function
![Page 30: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/30.jpg)
G51IAI – Search Space & Tree
General Search Function GENERAL-SEARCH (problem, QUEUING-FN)
returns a solution or failure nodes = MAKE-QUEUE(MAKE-NODE(INITIAL-
STATE[problem])) Loop do
If nodes is empty then return failure node = REMOVE-FRONT(nodes) If GOAL-TEST[problem] applied to STATE(node)
succeeds then return node nodes = QUEUING-FN
(nodes,EXPAND(node,OPERATORS[problem])) End
End Function
![Page 31: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/31.jpg)
G51IAI – Search Space & Tree
General Search Function GENERAL-SEARCH (problem, QUEUING-FN)
returns a solution or failure nodes = MAKE-QUEUE(MAKE-NODE(INITIAL-
STATE[problem])) Loop do
If nodes is empty then return failure node = REMOVE-FRONT(nodes) If GOAL-TEST[problem] applied to STATE(node)
succeeds then return node nodes = QUEUING-FN
(nodes,EXPAND(node,OPERATORS[problem])) End
End Function
![Page 32: Do you drive? Have you thought about how the route plan is created for you in the GPS system? How would you implement a cross-and- nought computer program?](https://reader035.vdocuments.net/reader035/viewer/2022062517/56649e945503460f94b991f0/html5/thumbnails/32.jpg)
G51IAI – Search Space & Tree
Summary of Problem Space
Search space Search tree (problem formulation) General search algorithm
Read Chapter 3 AIMA