Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "1/19 Informed search algorithms Chapter 4 Modified by Vali Derhami."— Presentation transcript:

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

2 2/19 Relaxed problems مسائل تعديل شده A problem with fewer restrictions on the actions is called a relaxed problem The cost of an optimal solution to a relaxed problem is an admissible heuristic for the original problem If the rules of the 8-puzzle are relaxed so that a tile can move anywhere, then h 1 (n) gives the shortest solution If the rules are relaxed so that a tile can move to any adjacent square, then h 2 (n) gives the shortest solution تركيب هيوريستيك ها: h(n)=max(h 1 (n), h 2 (n),.. h m (n))

3 3/19 Local search algorithms In many optimization problems, the path to the goal is irrelevant; the goal state itself is the solution, such as 8 queens problem State space = set of "complete" configurations Find configuration satisfying constraints, e.g., n- queens In such cases, we can use local search algorithms keep a single "current" state, try to improve it

4 4/19 Example: n-queens Put n queens on an n × n board with no two queens on the same row, column, or diagonal

5 5/19 مزاياي جستجوي محلي استفاده از حافظه بسيار كم تقريبا ثابت امكان استفاده در فضاهاي حالت بزرگ و نا متناهي (پيوسته)

6 6/19 Hill-climbing search "Like climbing Everest in thick fog with amnesia” همسايه هاي مجاور(توليد شده توسط تابع پسين) را بررسي مي كند و اگر حالتي بهتر است آن را جايگزين حالت فعلي ميكند

7 7/19 Hill-climbing search Problem: depending on initial state, can get stuck in local maxima

8 8/19 Hill-climbing search: 8-queens problem h = number of pairs of queens that are attacking each other, either directly or indirectly h = 17 for the above state تابع پسين تمامي حالتهاي ممكن را كه با جابجا كردن تنها يك وزير به مربعي ديگري در همان ستون توليد مي شود را بر مي گرداند (لذا هر حالت 8*7=56 پسين دارد)

9 9/19 Hill-climbing search: 8-queens problem A local minimum with h = 1

10 10/19 تپه نوردي اتفاقي بصورت تصادفي از حركتهاي رو به بالا يكي را انتخاب ميكند. –ميزان احتمال مي تواند بر اساس مقدار شيب روي به بالاي حركت باشد. هر دو روش تپه نوردي معمولي و اتفاقي ناكامل هستند. تپه نوردي با شروع مجدد تصادفي –يك مجموعه از جستجوي تپه نوردي را از حالتهاي شروع تصادفي اجرا مي كند.

11 11/19 Simulated annealing search جستجوي سخت سازي شبيه سازي شده Idea: escape local maxima by allowing some "bad" moves but gradually decrease their frequency هدف رفع مشكل تپه نوردي چرا كه در روش تپه نوردي هرگز حركت رو به پايين وجود ندارد. داخلي ترين حلقه روش مانند روش تپه نوردي است ليكن در اينجا به جاي انتخاب بهترين حركت يك حركت تصادفي انتخاب مي شود. –اگر حركت انجام شده شرايط را بهبود دهد آنگاه حالت جديد جايگزين حالت فعلي مي شود. –وگرنه با احتمال زير جايگزيني صورت مي گيرد. exp(  E/T) –  E ميزان بدي حالت جديد. –T ضريب دما كه در طول آزمايش كاهش مي يابد.

12 12/19 Simulated annealing search جستجوي سخت سازي شبيه سازي شده

13 13/19 Properties of simulated annealing search One can prove: If T decreases slowly enough, then simulated annealing search will find a global optimum with probability approaching 1 Widely used in VLSI layout, airline scheduling, etc

14 14/19 Local beam search جستجوي پرتوي محلي Keep track of k states rather than just one Start with k randomly generated states At each iteration, all the successors of all k states are generated If any one is a goal state, stop; else select the k best successors (or randomly) from the complete list and repeat.

15 15/19 Genetic algorithms Start with k randomly generated states (population) A state is represented as a string over a finite alphabet (often a string of 0s and 1s) Evaluation function (fitness function). Higher (sometimes lower) values for better states. Produce the next generation of states by selection, crossover, and mutation A successor state is generated by combining two parent states A suitable GUI for GA in MATLAB: gatool

16 16/19 Genetic algorithms Fitness function: number of non-attacking pairs of queens (min = 0, max = 8 × 7/2 = 28) 24/(24+23+20+11) = 31% 23/(24+23+20+11) = 29% etc

17 17/19 قدمهاي الگوريتم ژنتيک 1-انتخاب جمعيت (کروموزم هاي )اوليه 2 اعمال جمعيت به محيط و محاسبه تابع برازش 3- شرط توقف برقرار است يانه؟ اگر بلي توقف 4- انتخاب جميعت براي پيوند 5- انجام پيوند 6-جهش 7- برگشت به قدم دوم

18 18/19 Genetic algorithms

19 19/19 Genetic algorithms

20 20/19 تكليف کامپيوتري يک پاسخ مناسب براي مساله 8 وزير با استفاده از روشهاي زير بيابيد. الف- روش تپه نوردي ب- الگوريتم ژنتيک زمان اجراي هر دو روش و نيز پاسخ را مقايسه کنيد. زمان تحويل:تا تاريخ مشخص شده در سرکلاس باید به ایمیل مسئول حل تمرین درس ايميل کنيد.

21 تمرين اختياري هدف آن است که مقدار x1 و x2 را به گونه اي بيابيم که تابع زير مينيمم شود و ضمنا محدوديتهاي زير نيز برقرار باشد جواب اين مساله را با استفاده از روشهاي جستجوي زير بدست بياوريد: C(x)=2x 1 +5x 2 0<x 1 <5 0<x 2 <10 x 1 2 +x 1 +x 2 3 +log(x 1 )>100 21/19


Download ppt "1/19 Informed search algorithms Chapter 4 Modified by Vali Derhami."

Similar presentations


Ads by Google