Professional Documents
Culture Documents
Search
Searching
Reflex Agent:
Choose action base on current percept (and
maybe memory)
May have memory or a model of the world’s
current state
Do not consider the future consequences of
their actions
Planning Agent:
Look into future: What if ?
Decisions plan with considerations a
consequence
Think by having a model of the world/actions
Have a goal
State space
“N”, 1.0
Transition Function
“E”, 1.0
How to model the world
Example: Traveling in Romania
Space:
Cities
Transition function:
Roads: Go to adjacent city with cost =
distance
Start:
Arad
End:
Is state == Bucharest?
Solution?
What’s in a State Space?
Fully Observable
How many
Full space:
120x(230)x(122)x4
Path finding:
120
Eating all dots:
120x(230)
Safety path planning
Problem: Ăn hết các chấm + luôn để các con ghost sợ hãi (N = 10)
How we define a state?
(agent position, dot booleans, big dot booleans, remaining scared time)
Graph Search Space vs Tree Search Space
State Space Graphs
Possible futures
a G d e p
b c
b c e h r q
e
d f a a h r p q f
S h
p q f q c G
p q r
q c G a
a
Đồ thị không gian trạng thái vs. Cây tìm kiếm
S G
Main approach:
Go from start
Expand the nodes which are not expanded
Avoid repeating nodes
Pseudocode
d e p
b c e h r q
a a h r p q f
p q f q c G
q c G a
a
DFS is good or bad?
Search Properties
Completeness: Always find a solution if it exists
Optimal: Always find the best solution
Run time
Memory b
1 node
… b nodes
b2 nodes
Parameters:
m tiers
b: chỉ số rẽ nhánh - branching factor
m: độ sâu is the maximum depth
Lời giải có thể nằm ở các độ sâu khác nhau
bm nodes
bm nodes
Completeness
Need m < infinity
Optimal
No
Breadth-First Search
Breadth-First Search
Use: queue a G
b c
Instead stack
e
d f
S h
p q r
d e p
Increase
b c e h r q
level of
searching
a a h r p q f
p q f q c G
q c G a
a
BFS properties
Time complexity:
O(bs) 1 node
b
If s < m, then we have advantage over DFS … b nodes
s
Memory complexity? b2 nodes
O(bs)
bs nodes
Store the last row
Completeness:
Yes bm nodes
Optimal
Find the least edges path
Quiz: DFS vs BFS
DFS vs BFS
p 4 r
15
q
Uniform Cost Search
Uniform cost search - UCS
UCS, a.k.a Dijkstra
2 a G
Uniform cost search - UCS b c
1 8 2
Go from nodes with least 2 e
3 d f
cost 9 2
S h 8
1
1 p q r
15
S 0
d 3 e 9 p 1
b 4 c e 5 h 17 r 11 q 16
11
Boundary a 6 a h 13 r 7 p q f
Of search
p q f 8 q c G
q 11 c G 10 a
a
Tính chất
Complexity
Visit all node have cost < C*
b c1
Let be the min edges, maximum depth C*/ …
O(bC*/) c2
C*/ depth
c3
Memory
O(bC*/)
Completeness
Require > 0
Optimal
Yes
Tính chất
Càng đi nhiều bước thì "đường viền" tìm c1
…
kiếm càng rộng c2
c3
The bad:
Phải tìm kiếm về mọi hướng
Không có thông tin về điểm đến
Ví dụ: bài toán giao thông tìm đường đi ngắn
nhất (đi về hướng nào đó)
Start Goal
Cấu trúc dữ liệu cần thiết
Về cài đặt, các thuật toán
search khác nhau ở chỗ "thứ tự
tìm kiếm"
"Hàng đợi"
BFS/DFS không cần phải tìm trong logn
UCS cần sử dụng priority-queue
Vấn đề về mô hình hóa