Route/Path Planning Using A Star and UCS
Route/Path Planning Referensi
Materi kuliah IF3170 Inteligensi Buatan Teknik Course Website:
Informatika ITB, STEI Teknik Informatika IF3170
Stuart J Russell & Peter Norvig, Artifcial Intelligence: A Modern Approach, 3rd Edition, Prentice-Hall International, Inc, 2010, Textbook Site:(2nd edition)
Free online course materials | MIT OpenCourseWare Website: Site:
Lecture Notes in Informed Heuristic Search,
ICS 271 Fall 2008, Route Planning
Source: Russell’s book Search
O
71 F 151
99 S Z 211
75
140 R B
97 P 120
101 118
D
75 146 138 M T
70 111
L C
S: set of cities i.s: A (Arad) g.s: B (Bucharest) Goal test: s = B ? Path cost: time ~ distance Uninformed Search
Breadth-First Search (BFS)
Treat agenda as a queue (FIFO) O
71 F S 151
Z
99 211
75 A
80
140 R B
97 P 101
120
Simpul-E Simpul Hidup
118 D
A Z ,S ,T A A A
75 138 146
M
Z S ,T , O
70 A A A AZ T 111
L
S T ,O , O ,F ,R
C A A AZ AS AS AS
T O ,O ,F ,R , L A AZ AS AS AS AT O O ,F ,R ,L Path: A S F B, AZ AS AS AS AT Path-cost = 450
O F ,R ,L AS AS AS AT F R ,L , B AS AS AT ASF R L ,B , D ,C ,P AS AT ASF ASR ASR AS R Depth-First Search (DFS)
Treat agenda as a stack (LIFO) O
71 F S 151
Z
99 211
75 A
80
140 R B
97 P 120
101 118
D
75 146 138 M
70 T 111
L
Simpul-E Simpul Hidup
C
A Z ,S ,T A A A Z O , S ,T A AZ A A Path: A Z O S F B
O S ,S ,T AZ AZO A A Path-cost = 607
S F , R ,S ,T AZO AZOS AZOS A A F B , AZOS AZOSF R ,S ,T AZOS A A IDS
71 O F S 151
Z
99 211
75 A
80
140 R B
97 P 120
101 118
D
75 146 138 M
70 T 111
L C
Depth=0: A: cutoff Depth=1: A Z ,S ,T Z : cutoff, S : cutoff, T : cutoff A A A A A A Depth=2: A Z ,S ,T O , S ,T O : cutoff F , R ,T A A A AZ A A AZ AS AS A F : cutoff R : cutoff L L : cutoff AS AS AT AT
Depth=3: A Z ,S ,T O , S ,T S ,S ,T S : cutoff
A A A AZ A A AZO A A AZOF , R ,T B , R ,T B AS AS A ASF AS A ASF
Simpul- Simpul Hidup E
A Z , T S A-75 A-118, A-140 Uniform Cost Search (UCS)
Z T , S , O A-75 A-118 A-140 AZ-146 T S ,O , L A-118 A-140 AZ-146 AT-229
BFS & IDS fnd path with fewest steps S O , R , L ,F A-140 AZ-146 AS-220 AT-229 AS-
If steps ≠ cost, this is not relevant (to 239 AS-291 ,O optimal solution)
O R , L , F ,O AZ-146 AS-220 AT-229 AS-239 AS-
How can we fnd the shortest path 291 (measured by sum of distances along R L , F ,O , P AS-220 AT-229 AS-239 AS-291 ASR-
,D ,C path)? 71 O 317 ASR-340 ASR-366
F 151 S Z 99 211 L F ,O , M , P AT-229 AS-239 AS-291 ATL-299 ASR- 75 317 ASR-340 ASR-366 ,D ,C A 140 80 F O ,M , P AS-239 AS-291 ATL-299 ASR- R 97 B P 118 120 101 O M , P ,D AS-291 ATL-299 ASR-317 ASR- 317 ASR-340 ASR-366, ASF-450 ,D ,C B D 75 146 138 340 ASR-366, ASF-450 ,C B 70 M T 111 L
M P ,D ,D ATL-299 ASR-317 ASR-340 ATLM- C 364 ASR-366, ASF-450 ,C B P D ,D ,C ASR-317 ASR-340 ATLM-364 ASR-366,
Path: A S R P B B , C B ASRP-418 ASRP-455, ASF-450
Path-cost = 418
Informed Search Greedy Best-First Search
Idea: use an evaluation function f(n) for each node
f(n) = h(n) estimates of cost from n to goal
e.g., h (n) = straight-line distance from n to Bucharest
SLD Greedy best-frst search expands the node that appears to be closest to goal
Romania with step costs in km
Greedy best-frst search example
Greedy best-frst search example
Greedy best-frst search example
Greedy best-frst search example
Problems with Greedy Best First Search
Not complete
Get Stuck with Local Minima/ Plateu
Irrevocable (not able to be reversed/ changed)
Can we incorporate heuristics in systematic search? Heuristic Search
Heuristic estimates value of a node promise of a node
difculty of solving the subproblem
quality of solution represented by node
the amount of information gained
f(n)- heuristic evaluation function.
depends on n, goal, search so far, domain A* Search
Idea: avoid expanding paths that are already expensive
Evaluation function f(n) = g(n) + h(n) g(n) = cost so far to reach n
h(n) = estimated cost from n to goal
f(n) = estimated total cost of path through
A
- search example
- search example
- search example
- search example
- search example
- search example
Goal: fnd a minimum sum-cost path
Notation: c(n,n’) - cost of arc (n,n’)
g(n) = cost of current path from start to node n in the
search tree. h(n) = estimate of the cheapest cost of a path from n to a goal.
Special evaluation function: f = g+h
f(n) estimates the cheapest cost solution path that goes through n.
h*(n) is the true cheapest cost from n to a goal. g*(n) is the true shortest path from the start s, to n.
If the heuristic function, h always underestimate
Properties of A*
Complete? Yes, unless there are infnitely many nodes with f ≤ f(G)
Time? Exponential: O(b m
)
Space? Keep all the nodes in memory: O(b
m)
Optimal? Yes Branch-and-Bound vs A*
As in A*, look for a bound which is guaranteed lower than the true cost
Search the branching tree in any way you like
e.g. depth frst (no guarantee), best frst Cut of search if cost + bound > best solution found
If heuristic is cost + bound, search = best frst then BnB = A*
Bounds often much more sophisticated e.g. using mathematical programming optimisations
Admissible heuristics A heuristic h(n) is admissible if for every
- * *
node n, h(n) ≤ h (n), where h (n) is the true cost to reach the goal state from n.
An admissible heuristic never
overestimates the cost to reach the goal,
i.e., it is optimistic Example: h (n) (never overestimates the
SLD actual road distance)
Theorem : If h(n) is admissible, A using
- TREE-SEARCH is optimal
2
73 x y
What must be true about h for h=100 h=1
1
1 A* to fnd optimal path? h=0 h=0
A* fnds optimal path if h is admissable; h is admissible when it never overestimates. g(X)+h(X)=2+100=102
In this example, h is not G(Y)+h(Y)=73+1=74 admissible.
Optimal path is not
In route fnding problems, found! straight-line distance to goal is
admissible heuristic. Because we choose Y,
rather than X which is in the optimal path.Contoh Soal UAS Sem 2 2014/2015
Dalam permainan video game, adakalanya entitas bergerak dalam video game perlu berpindah dari satu posisi ke posisi lain. Seringkali proses perpindahan perlu mengutamakan jalur terdekat atau biaya minimal karena berhubungan dengan poin yang diperoleh. Gambar di bawah ini menunjukkan contoh jalur yang mungkin dilewati oleh entitas bergerak dalam suatu video game. Suatu entitas akan berpindah
dari posisi titik A menuju ke posisi titik F. Jika
diperlukan informasi heuristik, nilai heuristik
Contoh Soal UAS Sem 2 2014/2015 (2)
Pencarian solusi dengan: a.
UCS b. Greedy Best First c. A Star Untuk masing-masing pendekatan tuliskan:
Formula
Iterasi
Simpul ekspan
Simpul hidup & nilai f(n) Urut abjad, simpul ekspan tidak mengulang, tidak membentuk
Selamat Belajar