31
1 Computer Group Engineering Department University of Science and Culture S. H. Davarpanah [email protected]. ir

Introduction to Artificial Intelligence

  • Upload
    yank

  • View
    40

  • Download
    1

Embed Size (px)

DESCRIPTION

Introduction to Artificial Intelligence. Problem Solving Through Informed Search. S. H. Davarpanah [email protected]. Computer Group Engineering Department University of Science and Culture. Heuristically informed search. - PowerPoint PPT Presentation

Citation preview

Page 1: Introduction to Artificial Intelligence

1

Computer GroupEngineering Department

University of Science and Culture

S. H. Davarpanah

[email protected]

Page 2: Introduction to Artificial Intelligence

2

Heuristically informed search

Uses domain-dependent (heuristic) information in order to search the space more efficiently.

What kind of heuristic information would be useful?

Page 3: Introduction to Artificial Intelligence

3

Information that helps:

• Decide which node to expand next, instead of doing the expansion in a strictly breadth-first or depth-first order;

• In the course of expanding a node, decide which successor(s) to generate, instead of blindly generating all possible successors at one time;

• Decide which nodes to discard (pruned), from the search space.

Heuristically informed search

What kind of heuristic information would be useful?

Page 4: Introduction to Artificial Intelligence

4

• ) نود ) كمتري تعداد بررسي به نياز ، باشد مطلع‌تر باشد بهتر مكاشفه چه هر . كه همانطور رو، اين از دارد وجود حل راه يافتن جهت جستجو درخت در

ميزان تعيين در نقشمؤثري مي‌تواند نمايشدرست روش يك انتخابو توانايي مهم نيز خوب مكاشفه انتخاب باشد، داشته مسئله يك حل در ما

. مي‌باشد تأيين‌كننده

کمتر • آن واقعی مقدار از همواره باید مکاشفه از حاصل تخمینی هزینهپذيرفتني باشد. اصطالحاً .Admissible )مكاشفه باشد (

ديگر، hمكاشفه • مكاشفه به در jنسبت نودها همه براي اگر است تر آگاه ،مقدار جستجو مقدار hفضاي مساوی . jبیشتر باشد

خوب مكاشفه يك انتخاب

Page 5: Introduction to Artificial Intelligence

5

هدف ۲۰حدوداً وضعيت به تصادفي حالتشروع از تا مي‌كشد حركتطولارتفاع جستجو درخت بنابراين . ۲۰برسيم، دارد

. دارد قرار كجا خالي خانه كه دارد اين به بستگي شدن شاخه شاخه فاكتوریا 3, 2) برابر (4و جستجو درخت شدن شاخه شاخه فاكتور متوسط رو اين از۳ . مي‌باشد

حدود تست به نياز جستجو درخت يك كوركورانه جستجوي به 3بنابراين،ً 20توان حدودا كه دارد ً !5/3وضعيت كال كه آنجا از و مي‌شود جستجو بيليون

با 362880يا ۹ و حد اين به بايد جستجو درخت دارد، وجود مختلففقط حالت. برسد تكراري حالت‌هاي حذف

8معماي

7 6

4 3 1

2 5 8

1 2 3

8 4

7 6 5

Page 6: Introduction to Artificial Intelligence

6

8معماي

معماي مسئله جهت نظر مورد مكاشفه خانه‌هايي ۸اولين تعداد شمارش) ( . نود را، مكاشفه اين ندارند قرار خود جاي سر در كه .1h است مي‌ناميم

ديگر، يافته بهبود بايد 2hمكاشفه اعداد از يك هر كه خانه‌هايي تعداد كه است . مقدار مي‌شمارد را برسند خود جاي سر به تا كنند جمع 2hحركت از

( . " فاصله‌ " مي‌آيد بدست آن درست موقعيت از خانه هر هاتان من فاصله‌هاياز دستيابي جهت كه است افقي و عمودي حركت‌هاي تعداد مجموع من‌هاتان

براي مشبك سيستم اينكه از بعد و است نياز ديگر موقعيت به موقعيت يك ). شد ناميده نام، اين به شد استفاده من‌هاتان جزيره‌ در جاده‌ها

مقدار نود هر مقدار h2 براي از نود . h1آن معني بدين اين است بيشتر آنكه . ( Dominate )چيره h1 بر h2 است است شده

هي_چ ك_ه باشن_د دس_ت در مكاشفه‌ تاب_ع تعدادي اس_ت ممك_ن حاالت، بعض_ي درمكاشفه‌اي تاب_ع ي_ك مي‌توان حال اي_ن در ندارن_د، خاص_ي برتري ديگري بر كدام

براساسمكاشفه‌هاي . h1 … hnجديد آورد بدست زير براساسرابطه

)نود(h,...,)نود(h,)نود(hmax)نود(h n21

Page 7: Introduction to Artificial Intelligence

7

Straight-line distance from the current node to the goal.

Can easily be obtained from a map.

S

A

D

B

E

C

FG

34 4

5 5

42

43

[8]

[8.5] [6]

[6] [3]

[3]

[10]

Sample heuristic knowledge

Straight-line distance from S to G: 10Straight-line distance from A to G: 8.5Straight-line distance from D to G: 8...

Page 8: Introduction to Artificial Intelligence

8

Heuristic: expand the most promising successor of the node last expanded (e.g. the node that has the shortest straight-line distance to the goal).

S

A

D

B

E

C

FG

34 4

5 5

42

43

[8]

[8.5] [6]

[6] [3]

[3]

[10]

S

A

A

G

E

FB

88.5

8.5 6

6 3

D

Heuristic search: Hill climbing

Page 9: Introduction to Artificial Intelligence

9

ك_ه تفاوت اي_ن ب_ا باش_د، م_ي نوردي تپ_ه ش_بيه س_ربااليي، تندتري_ن تپه‌نورديارتفاع ك_ه بروي_م موقعيت_ي اولي_ن ب_ه مرحل_ه ه_ر در اينك_ه بجاي آ_ن، اس_اس بر

در را خود بر و دور دارد، فعل_ي موقعي_ت ب_ه نس_بت م_ي 4باالتري چ_ك جه_ت. نماييم مي انتخاب را موقعيت باالترين و كنيم

سربااليي تندترين تپه‌نوردي

Page 10: Introduction to Artificial Intelligence

10

(Foothill)تپه‌ها

Page 11: Introduction to Artificial Intelligence

11

(Plateaus)فالت‌ها

Page 12: Introduction to Artificial Intelligence

12

(Ridge)تيغه‌ها

Page 13: Introduction to Artificial Intelligence

13

تكراري محلي جستجوي

ماكزيمم مشكل بر تا دارند سعي تكراري محلي جستجوي تكنيك‌هاياوليه وضعيت‌هاي از بهينه‌سازي روال مكرر اجراي طريق از محلي

. اين شود، تكرار فوق الگوريتم كافي تعداد به اگر آيند فائق متفاوت . يافت خواهد دست سراسري ماكزيمم به روند

از استفاده و مسائل گونه اين در هدف كه شد يادآور بايد البتهبرسيم، خوب خيلي حل راه يك به كه است اين چنيني اين روندهاي

. در شود بررسي مسئله فضاي كل كه باشد نيازي اينكه بدونشهرها تعداد افزايش با كه دوره‌گرد فروشنده مسئله چون مسائلي

توليد مي‌توانند جواب‌هايي مي‌شود، زياد شدت به جستجو فضاياندازه به باشند زيادي مراحل تكرار به نياز اينكه بدون كه بشوند

) كه ) است حالي در اين و محلي ماكزيمم هستند خوب كافي ( . اينكه حداقل يا مي‌نمايد غيرممكن جواب بهترين به دستيابي

.) ندارد وجود جواب يك بودن بهترين جهت تضميني

Iterated Local Search

Page 14: Introduction to Artificial Intelligence

14

تابو جستجو

م_ي فرامكاشف_ه ي_ك تاب_و از جس_تجوي جلوگيري منظور ب_ه ك_ه باش_دلحظ_ه، ه_ر ت_ا شده ديده هاي وضعي_ت ليس_ت در تكراري حالتهاي تكرار

. شود مي استفادهمورد ديگ__ر مكاشف__ه ي__ك ب__ا تركي__ب در تاب__و جس__تجوي فرامكاشف__هاس__توار اص__ل اي__ن بر آ__ن اس__اسعملكرد و گيرد م__ي قرار اس__تفادهبهت_ر مي‌باش_د ناكارآم_د آي_د م_ي نظ_ر ب_ه ك_ه راه_ي دادن ادام_ه ك_ه اس_ت . ب_ه اس_ت شده ديده قبال ك_ه اس_ت راه_ي كردن دنبال از ارزشمندت_ر و . ب_ه ميكند جلوگيري محل_ي هاي ماكزيم_م از تاب_و جس_تجوي طري_ق، اي_ن

س_ايت از توان_د www.tabusearch.netنق_ل م_ي ب_د تام_ل ب_ا انتخاب ي_كدر خوب تص_ادفي انتخاب ي_ك ب_ه نس_بت را بيشتري اطالعات ه_م هنوز

. باشد برداشته

Tabu search

Page 15: Introduction to Artificial Intelligence

15

فلزات ذوب شبيه‌سازي

انرژي با وضعيت سمت به حركت عدم يا و حركت تعيين منظور بهاحتمال باالتر بين ميزان تصادفي عدد يك و مي‌شود محاسبه

. مقدار از كمتر تصادفي عدد اين اگر شد خواهد انتخاب يك و صفر . كه حاالتي در مي‌شود پذيرفته جديد وضعيت باشد، احتمال تابع

پايين خيلي دما مقدار يا و است زياد خيلي انرژي افزايشميزانرا انرژي كه حالي در كمي بسيار وضعيت‌هاي تعداد مي‌باشد،

مقدار و شد خواهند پذيرفته ميل افزايشمي‌دهند سمتصفر بهنمود .خواهد

را سيستم انرژي تا دارند اجازه مراحل بعضي كه واقعيت اينتوانمند محلي اكستريم‌هاي از رهايي جهت را پردازه افزايشدهند،

بسيار روشي اغلب فلزات ذوب شبيه‌سازي رو اين از و مي‌سازدمحلي اكستريمم‌هاي زيادي تعداد با پيچيده مسائل حل در توانمند

.مي‌باشد

)TdE

(e

Page 16: Introduction to Artificial Intelligence

16

فلزات ذوب شبيه‌سازي

. مي‌باشد محك_م و س_خت فلزات و شيشه‌ه_ا تولي_د پروس_ه ذوب‌كاري،و مي‌دهن_د حرارت باالي_ي بس_يار دماي ت_ا را فلزات ابتدا فراين_د اي_ن در . مي‌توانن_د اتمه_ا روش، اي_ن در مي‌كنند خن_ك را آنه_ا مرور ب_ه ادام_ه درتولي_د را محكم_ي بس_يار مواد و بگيرن_د خود ب_ه ماناي_ي بس_يار س_اختار

نمايند.از تركيبي كه مي‌شود اعمال مسائلي به فلزات ذوب شبيه‌سازي . تا است الزم مسائل، گونه اين در هستند دخيل آن در مقدار چند

شوند انتخاب متفاوت متغيرهاي به نسبت‌دهي جهت زيادي مقاديرعمومي توابع برخي مقدار مقادير، اين همه به بسته كه بگونه‌اي

. مطرح سيستم انرژي عنوان تحت مقدار اين مشخصمي‌شودحداقل. نمودن پيدا فلزات ذوب شبيه‌سازي كلي هدف مي‌شود

. است سيستم يك براي انرژي

Page 17: Introduction to Artificial Intelligence

17

Expand the leaf node (of the current search tree) that seems ”the most promising" to lead to a goal node. The node selected for expansion is the one at which an evaluation function f* is minimum (e.g. f* could be the straight line distance to the goal).

Heuristic search: Greedy best-first search

S

A Df*(A)=8.5 f*(A)=8

S

A

D

B

E

C

FG

34 4

5 5

42

43

[8]

[8.5] [6]

[6] [3]

[3]

[10]

A E f*(E)=6f*(A)=8.5

Page 18: Introduction to Artificial Intelligence

18

What is the difference between hill-climbing and greedy best-first search?

Discussion

Greedy best-first search: expand the leaf node of the current search tree that seems the most promising to lead to a goal node.

Hill climbing search: expand the most promising successor of the node last expanded.

Hill climbing is a local search method, while greedy best-first search is a global search method.

What are some of the problems with hill climbing?

Local maxima, plateaus, and ridges

Page 19: Introduction to Artificial Intelligence

19

f*(i) = the cost of the path from the start node to i

Generality of greedy best-first search

What heuristic function leads to breadth-first search?

f*(i) = the depth of node i (the distance from the root to i)

What heuristic function leads to depth-first search?

f*(i) = - the depth of node i

What heuristic function leads to uniform-cost search?

Page 20: Introduction to Artificial Intelligence

A bad example for greedy

A

B

F

D E3 4

4

7 6

start state

goal state

• Say: h(A) = 9, h(B) = 5, h(D) = 6, h(E) = 3, h(F) = 0

• Problem: greedy evaluates the promise of a node only by how far is left to go, does not take cost occurred already into account

Page 21: Introduction to Artificial Intelligence

21

The A* algorithm is the greedy best-first search method with:f*(n) = g*(n) + h*(n)

where: g*(n) estimates the minimum cost of a path from the start node to node n;h*(n) estimates the minimum cost from node n to a goal.

The node chosen for expansion is the one for which f* is minimum.

Heuristic search: The A* algorithm

S

m n

G

p

g*(m) g*(n)g*(p)

h*(m)h*(n)

h*(p)

Page 22: Introduction to Artificial Intelligence

22

S

A

D

B

E

C

FG

34 4

5 5

42

43

[8]

[8.5] [6]

[6] [3]

[3]

[10]

S

C E

4 5

14 18

G

3

13

B D

54

8+8=167+6=13

A D

3 4

11.5 12

g*(A)=3h*(A)=8.5f*(A)=3+8.5

g*(A)=4h*(A)=8f*(A)=4+8

A E

5 2

129+8.5=17.5 6+6

B F

45

10+311+6 17 13

Illustration of A*

step 1

step 2 step 3

step 4step 5

step 6

Page 23: Introduction to Artificial Intelligence

23

Apply the A* algorithm to find a path from S to T, in the following map. The value v associated with a link MN is the length of that link. The value [w] associated with a node N is the straight line distance between N and T.

SA

B

D

T

F C

G

2

21 1

5

2

2

3

3

[5]

[7]

[4]

[3]

[4][3]

E[2]

2

goal

start

Exercise

Page 24: Introduction to Artificial Intelligence

24

SA

B

D

T

F C

G

2

21 1

5

2

2

3

3

[5]

[7]

[4]

[3]

[4][3]

E[2]

2

goal

start

S

A B

D

C

T

C

F

h*(A)=72

5 2

1 1

2

9

step 1

f*(A)=2+7 7step 5 step 2

step 3

step 7

9

2g*(A)=2h*(B)=5f*(B)=2+5

g*(B)=2

4+4=87+4=11

5+3=8 5+4=9

E

3step 4

8+3=11 G

2 step 6

7+2=9

Page 25: Introduction to Artificial Intelligence

A* and repeated states

• Suppose we try to avoid repeated states• Ideally, the second (or third, …) time that we

reach a state the cost is at least as high as the first time– Otherwise, have to update everything that came after

• This is guaranteed if the heuristic is consistent: if one step takes us from n to n’, then h(n) ≤ h(n’) + cost of step from n to n’– Similar to triangle inequality

Page 26: Introduction to Artificial Intelligence

Admissibility

• A heuristic is admissible if it never overestimates the distance to the goal– If n is the optimal solution reachable from n’, then g(n) ≥

g(n’) + h(n’)

• Straight-line distance is admissible: can’t hope for anything better than a straight road to the goal

• Admissible heuristic means that A* is always optimistic

Page 27: Introduction to Artificial Intelligence

Optimality of A*

• If the heuristic is admissible, A* is optimal (in the sense that it will never return a suboptimal solution)

• Proof:– Suppose a suboptimal solution node n with solution value C > C*

is about to be expanded (where C* is optimal)– Let n* be an optimal solution node (perhaps not yet discovered)– There must be some node n’ that is currently in the fringe and on

the path to n*

– We have g(n) = C > C* = g(n*) ≥ g(n’) + h(n’)– But then, n’ should be expanded first (contradiction)

Page 28: Introduction to Artificial Intelligence

28

A* (and greedy best-first) search: Discussion

Complete?:

Optimal?:

Time complexity:

Space complexity:

Yes

Yes

O(bm)

O(bm)

A* به آن در كه درختي كه است كامل هنگامي حقيقتفقط درداشته محدودي شدن شاخه شاخه فاكتور مقدار مي‌پردازد جستجو

آن در نامحدود نودهاي تعداد با و محدود هزينه با مسيري و باشد. نباشد موجود

A *پذیرفتنی شده گرفته نظر در مکاشفه که است بهینه هنگامیباشد.

A good heuristic reduces the complexity substantially.

Page 29: Introduction to Artificial Intelligence

29

A* گام به گام عميق‌سازي

روش دو تركيب ارائه* Aاز الگوريتمي گام، به گام عميق‌سازي وشبيه ) است بهينه و كامل كه حال عين در كه شبيه*( Aمي‌شود

. دارد نيز كمي حافظه به احتياج عمق اول جستجوي

IDA *در كه است عمقي گام به گام جستجوي الگوريتم از نمونه يكگردد، تعيين نود يك براساسعمق اينكه جاي به محدوديت آن

) نود ) .fبراساسمقدار مي‌شود تعيين موفق نمونه‌هاي

IDA* ( Iterative Deepening A* Search )

Page 30: Introduction to Artificial Intelligence

30

شده داده محدود حافظه *Aبا

شبیه است نیاورده کم حافظه وقتی . Aتا وقتی* کند می عملبیشترین که نودها از تعدادی یا یکی شد پر دارند fحافظه را

فراموششده) روند ( Forgotten Nodesنودهای می بیرون حافظه ازمقدار اگر fفقط تا شود می داشته نگه پدرشان نود در آنها تخمینی

دوباره است بوده مناسبی نود نود آن که برسیم نتیجه این به بعدا . حداکثر تعداد به باسد نود هر در لذا دهیم بسط و کنیم تولید آنرا

. باشیم داشته فرزندانشجا تهدادبه حافظه اگر برساند جواب به را ما که کند می تضمین الگوریتم این

. باشد موجود جواب عمق اندازهسازی پیاده بودن مشکل به توجه با عمل از* SMAدر * IDAبیشتر

. شود می استفاده

SMA* ( Simplified Memory-Bound A* Search )

Page 31: Introduction to Artificial Intelligence

31

Applications of search methods

Route Finding• routing in computer networks;• automated travel advisory systems;• airline travel planning systems.

Touring and Traveling Salesperson Problems• planning trips for traveling salespersons;• planning movements for automatic circuit board drills.

VLSI Layout• cell layout on the chip;• channel routing between the cells.

Robot Navigation• in a two dimensional space (moving on a surface);• in a multidimensional space (when the robot has arms

and legs that must be controlled).

Assembly Sequencing• checking the feasibility of the steps in a sequence

(a geometrical search problem).