1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

27
1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami

description

3/27 Outline Best-first search Greedy best-first search A * search Heuristics Local search algorithms Hill-climbing search Simulated annealing search Local beam search Genetic algorithms

Transcript of 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

Page 1: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

1/27

Informed search algorithms

Chapter 4Modified by Vali Derhami

Page 2: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

2/27

Material

• Chapter 4

Page 3: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

3/27

Outline• Best-first search• Greedy best-first search• A* search• Heuristics• Local search algorithms• Hill-climbing search• Simulated annealing search• Local beam search• Genetic algorithms

Page 4: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

4/27

Review: Tree search

• A search strategy is defined by picking the order of node expansion

Page 5: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

5/27

Best-first searchبهترين اول جستجوي

• Idea: use an evaluation function f(n) for each node– estimate of "desirability"Expand most desirable unexpanded node

• Implementation:Order the nodes in fringe in decreasing order of desirability

• Special cases:– greedy best-first search– A* search

–•

––

Page 6: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

6/27

Romania with step costs in km

Page 7: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

7/27

Greedy best-first search• Evaluation function f(n) = h(n) (heuristic) = estimate of cost from n to goal• e.g., hSLD(n) = straight-line distance from n

to BucharestGreedy best-first search expands the node

that appears to be closest to goal•

Page 8: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

8/27

Greedy best-first search example

Page 9: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

9/27

Greedy best-first search example

Page 10: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

10/27

Greedy best-first search example

Page 11: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

11/27

Greedy best-first search example

Page 12: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

12/27

Properties of greedy best-first search

• Complete? No – can get stuck in loops, e.g., Iasi Neamt Iasi Neamt

• Time? O(bm), but a good heuristic can give dramatic improvement

• Space? O(bm) -- keeps all nodes in memory

• Optimal? No

Page 13: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

13/27

A* search• Idea: avoid expanding paths that are

already expensive– h(n) = estimated cost from n to goal– f(n) = estimated total cost of path through n to

goal–

• Evaluation function f(n) = g(n) + h(n)• g(n) = cost so far to reach n

Page 14: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

14/27

A* search example

Page 15: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

15/27

A* search example

Page 16: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

16/27

A* search example

Page 17: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

17/27

A* search example

Page 18: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

18/27

A* search example

Page 19: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

19/27

A* search example

Page 20: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

20/27

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.

• Theorem: If h(n) is admissible, A* using TREE-SEARCH is optimal

• An admissible heuristic never overestimates the cost to reach the goal, i.e., it is optimistic

• Example: hSLD(n) (never overestimates the actual road distance)

Page 21: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

21/27

گراف جستجوي در بهينگي عدمروش • كه شود بهينه *Aتوجه گراف جستجوي در

مسير يك است ممكن روش اين در كه چرا نيست. شود گذاشته كنار تكراري حالت يك به بهينه

شناسايي: • تكراري حالت مذكور روش در ياداوري . گردد مي حذف شده كشف جديد مسير شود

• : حل راه•. شود/ گذاشته كنار دارد تر هزينه پر مسير كه گرهيبه • بهينه مسير كند تض/مين كه باشد گونه بدان عملكرد نحوه

شده دنبال كه است مسيري اولين هميشه تكراري حالتيكنواخت. هزينه جستجوي همانند است

Page 22: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

22/27

Consistent heuristicsسازگار هيوريستيكهاي

• A heuristic is consistent if for every node n, every successor n' of n generated by any action a, h(n) ≤ c(n,a,n') + h(n')

هزينه و پسين گره هيوريستيك تابع حاصلجمع هميشه يعنيبه .رفتن است مساوي يا بيشتر والد هيوريستيك تابع از ان

». هست هم قبول قابل سازگار هيوريستيك هر• If h is consistent, we havef(n') = g(n') + h(n') = g(n) + c(n,a,n') + h(n') ≥ g(n) + h(n) = f(n)

مقدار • .f(n)يعني است نزولي غير مسيري هر طول در• Theorem: If h(n) is consistent, A* using GRAPH-SEARCH is optimal

•i.e., f(n) is non-decreasing along any path.

••

Page 23: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

23/27

Properties of A*• Complete? Yes (unless there are infinitely many nodes

with f ≤ f(G) )• Optimal? Yes

•• ريشه از را جستجو مسيرهاي كه الگوريتمهايي ميان در

تواند نمي ديگري بهينه الگوريتم هيچ دهند مي توسعهاز ميدهد توسع كه هايي گره تعداد كه كند *A تضمين

باشد كمتر• Time? Exponential• Space? Keeps all nodes in memory• مياورد كم حافظه بياورد كم وقت آنكه از بيشتر .الگوريتم

Page 24: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

24/27

Admissible heuristicsE.g., for the 8-puzzle:• h1(n) = number of misplaced tiles• h2(n) = total Manhattan distance موقعيتهاي از كاشيها فاصله مجموع هدفشان

(i.e., no. of squares from desired location of each tile)

• h1(S) = ? • h2(S) = ? •••

Page 25: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

25/27

Admissible heuristicsE.g., for the 8-puzzle:• h2(n) = total Manhattan distance(i.e., no. of squares from desired location of each tile)

• h1(S) = ? 8• h2(S) = ? 3+1+2+2+2+3+3+2 = 18

•• h1(n) = number of misplaced tiles

Page 26: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

26/27

Dominance• effective branching factor b*.

N + 1 = 1 + b* + b*2 + • • • + (b*)d . N=total number of nodes generated by A*, d= solution depth

, b* is the branching factor that a uniform tree of depth d would have to have in order to contain N+ 1 nodes.

• If h2(n) ≥ h1(n) for all n (both admissible)• then h2 dominates h1 , and h2 is better for search

• Typical search costs (average number of nodes expanded):• d=12 IDS = 3,644,035 nodes

A*(h1) = 227 nodes A*(h2) = 73 nodes b*=1.24

• d=24 IDS = too many nodesA*(h1) = 39,135 nodes A*(h2) = 1,641 nodes b*=1.26

••

Page 27: 1/27 Informed search algorithms Chapter 4 Modified by Vali Derhami.

27/27

Relaxed problemsشده تعديل مسائل

• A problem with fewer restrictions on the actions is called a relaxed problem

• If the rules of the 8-puzzle are relaxed so that a tile can move anywhere, then h1(n) gives the shortest solution

• If the rules are relaxed so that a tile can move to any adjacent square, then h2(n) gives the shortest solution

• : ها هيوريستيك تركيب• h(n)=max(h1(n), h2(n), .. hm(n))

••• The cost of an optimal solution to a relaxed problem

is an admissible heuristic for the original problem•