1 / 32

Artificial Intelligence هوش مصنوعی Graph & Search امیر حسامی

Artificial Intelligence هوش مصنوعی Graph & Search امیر حسامی جستجوی محیط حالت یک محیط حالت به صورت زیر نشان داده می شود: [N, A, S, GD] N مجموعه گره ها یا حالات در گراف است. A مجموعه کمانها یا ارتباط بین گرها است. S یک زیر مجموعه غیر تهی از N است که شامل حالت و یا حالات شروع می باشد.

Gabriel
Télécharger la présentation

Artificial Intelligence هوش مصنوعی Graph & Search امیر حسامی

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Artificial Intelligenceهوش مصنوعیGraph & Searchامیر حسامی

  2. جستجوی محیط حالت • یک محیط حالت به صورت زیر نشان داده می شود: • [N, A, S, GD] • N مجموعه گره ها یا حالات در گراف است. • A مجموعه کمانها یا ارتباط بین گرها است. • S یک زیر مجموعه غیر تهی از N است که شامل حالت و یا حالات شروع می باشد. • GD یک زیر مجموعه غیر تهی از N است که شامل حالت و یا حالات هدف می باشد. حالت هدف (Goal) به صورت زیر تعریف می شود. • یک خاصیت قابل اندازه گیری از حالات در جستجو. • یک خاصیت از مسیر حرکت در جستجو به عنوان مثال وزن کمانها. • یک مسیرراه حل یک مسیر از گره های موجود در S به گره های موجود در GD می باشد.

  3. پازل 8 تائی

  4. مسئله مرد فروشنده دوره گرد (TSP) • مسیر با وزن 450 یکی از راه حلهای ممکن است. • یکی از استراتژیهای حل این مسئله ایجاد مسیر با توجه به قانون ” برو به نزدیکترین شهری که هنوز نرفته ای“ می باشد. • این روش یکی از سریعترین روشهاست که برای این مثال مسیر [A, E, D, B, C, A] را ایجاد می کند. گاهی اوقات مسیر ایجاد شده مسیر بهینه نیست.

  5. Back Tracking بازگشت به عقب • بازگشت به عقب یک تکنیک برای امتحان کردن تمام مسیرهای ممکن در یک محیط جستجو است. • بازگشت به عقب از حالت شروع آغاز کرده و هنگامی که به یک پایان مرده (Dead End) و یا هدف برسد, متوقف می شود. اگر به یک پایان مرده برسد, به آخرین گره ای که گرهای هم سطح تست نشده دارد, بازگشته و جستجو را از آنجا در سایر شاخه ها ادامه می دهد: • اگر حالت فعلی S هدف نباشد این روش اولین بچه آن را مورد بررسی قرار می دهد. اگر هدف در زیر گراف با ریشه پیدا نشود این عملیات با گره هم سطح آن, , تکرار می شود. • اگر هدف در هیچ یک از مسیرها پیدا نشود این روش مقدار ” ” را بازمی گرداند.

  6. Back Tracking بازگشت به عقب • الگوریتم Back Track: • SL لیست حالات می باشد و حالات را در مسیری که در حال بررسی است در خود نگاه می دارد. اگر هدف پیدا شود آنگاه SL شامل مسیر راه حل می باشد. • NSLلیست حالات جدیدی که بچه های آنها هنوز جستجو نشده ه اند , می باشد. • DE لیست پایان مرده می باشد یعنی حالاتی که در بچه های آنها هدف پیدا نشده است. • CS حالتی می باشد که در حال حاضر تحت بررسی است.

  7. Back Tracking بازگشت به عقب Function back - track; Begin SL = [Start]; NSL = [Start]; DE = []; CS=Start; While NSL [] do begin if CS == goal then return SL; if CS has no children then begin while SL is not empty and CS == the first element of SL do begin add CS to DE; remove first element from SL; remove first element from NSL; CS = first element of NSL; end add CS to SL; end else begin place children of CS( Except nodes already on DE, SL or NSL) on NSL; CS = first element of NSL; add CS to SL end end return FAIL; end

  8. Back Tracking بازگشت به عقب After Iteration CS SL NSL DE 0 A [A] [A] [] • B [B A] [B C D A] [] • E [E B A] [E F B C D A] [] • H [H E B A] [H I E F B C D A] [] • I [I E B A] [I E F B C D A] [H] • F [F B A] [F B C D A] [E I H] • J [J F B A] [J F B C D A] [E I H] • C [C A] [C D A] [B F J E I H] • G [G C A] [G C D A] [B F J E I H]

  9. Breadth – First Search: • در این گراف جستجوی Breadth – first بصورت زیر است: • A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U. • از دو لیست Open و Closed برای نگهداری حالات در نوشتن الگوریتم این جستجو استفاده می کنیم: • Open همانند NSL در الگوریتم بازگشت به عقب حالاتی که بچه هایشان مورد بررسی قرار نگرفته اند را در خود نگه می دارد. ترتیبی حذف حالات از Open نشاندهنده ترتیب جستجو است. • Closed حالاتی که بررسی شده اند را در خود نگه می دارد. در واقع Closed اجتماع SL و DE در الگوریتم بازگشت به عقب است.

  10. Breadth – First Search: Function Breadth – first – search; Begin open=[Start]; closed= []; while open [] do begin remove leftmost state from open, call it X if X is a goal then return SUCCESS else begin generate children of X; put X on closed; discard children of X if already on open or closed; put remaining children on right end of open end end Return FAIL end

  11. Breadth – First Search: • Open=[A] ; Closed=[]; • Open=[B, C, D]; Closed=[A]; • Open=[C, D, E, F]; Closed=[B, A]; • Open=[D, E, F, G, H]; Closed=[C, B, A]; • Open=[E, F, G, H, I, J]; Closed=[D, C, B, A]; • Open=[F, G, H, I, J, K, L]; Closed=[E, D, C, B, A]; • Open=[G, H, I, J, K, L, M]; Closed=[F, E, D, C, B, A]; • Open=[H, I, J, K, L, M, N]; Closed=[G, F, E, D, C, B, A]; • And so on until either U is found or Open=[] الگوریتم جستجوی Breadth - First قطعا کوتاهترین مسیر را پیدا می کند.

  12. Breadth – First Search: • جستجوی Breadth - First برای پازل 8 تائی:

  13. Depth – First Search: Function Depth – first search; Begin Open=[Start]; Closed=[]; while open [] do begin remove leftmost state from open, call it X; if X is a goal then return SUCCESS else begin generate children of X; put X on Closed; discard children of X if already on Open or Closed; put remaining children on left end of open; end end Return FAIL; end

  14. Depth – First Search: • Open=[A] ; Closed=[]; • Open=[B, C, D]; Closed=[A]; • Open=[E, F, C, D]; Closed=[B, A]; • Open=[K, L, F, C, D]; Closed=[E, B, A]; • Open=[S, L, F, C, D]; Closed=[K, E, B, A]; • Open=[L, F, C, D]; Closed=[S, K, E, B, A]; • Open=[T, F, C, D]; Closed=[L, S, K, E, B, A]; • Open=[F, C, D]; Closed=[T, L, S, K, E, B, A]; • Open=[M, C, D]; (L is already on Closed) Closed=[F, T, L, S, K, E, B, A]; • Open=[C, D]; Closed=[M, F, T, L, S, K, E, B, A]; • Open=[G, H, D]; Closed=[C, M, F, T, L, S, K, E, B, A]; • And so on until either U is found or Open=[] الگوریتم جستجوی Depth - First ممکن است کوتاهترین مسیر را پیدا نکند.

  15. Depth – First Search: • جستجوی Depth - First برای پازل 8 تائی:

  16. Depth – First Search with iterative Deepening: • استفاده از یک Depth - Bound در جستجوی Depth - first. از جستجوی بیهوده و وقت گیر از یک سطح به پائین جلوگیری می کند. • الگوریتم یک جستجوی Depth - First را با Depth - Bound برابر با 1 انجام می دهد. اگر نتواند هدف را پیدا کند با Depth - Bound برابر 2 جستجوی دیگری را آغاز می کند. این مقدار کم کم افزایش می یابد تا یا هدف پیدا شود و یا تمام فضای حالات جستجو گردد. • با این روش قطعا کوتاهترین راه حل در زمان کوتاهی پیدا خواهد شد.

  17. Heuristic • The study of the methods and rules of discovery and invention. (Polya 1945) • بررسی متدها و قوانین اکتشاف و اختراع. • ریشه کلمه یونانی Eurisco به معنی من پی بردم (کشف کردم). • در فضای جستجوی حالات Heuristic فرموله بندی قوانین برای انتخاب شاخه هایی در فضای حالت که با بیشترین احتمال منجر به یافتن یک راه حل مورد قبول شود, می باشد.

  18. Heuristic • محققان هوش مصنوعی از Heuristic در دو موقعیت زیر استفاده می کنند: • یک مسئله ممکن است یک راه حل دقیق به خاطر ابهام ذاتی موجود در مسئله و یا در داده ها, نداشته باشد. به عنوان مثال در تشخیص پزشکی یک مجموعه از علائم ممکن است به دلائل زیادی ایجاد شده باشند. پزشکان از برای انتخاب ممکنترین تشخیص و مشخص کردن درمان استفاده می کنند. • یک مسئله یک راه حل دقیق دارد اما هزینه زیاد یافتن آن موجب جلوگیری از یافتن آن می گردد. مانند شطرنج.

  19. Best – First Search: • Hill – Climbing Strategy: • Expand the current state, the best child is selected for further expansion; neither its siblings nor its parents are retained. i.e. eager blind mountain climber. • Because it keeps no history, the algorithm cannot recover from failures of its strategy. • Problem: Stuck in a local maximum.

  20. Best – First Search: Function best – first – search; Begin open=[Start]; closed=[]; While open [] do begin remove the leftmost state from open, call it X; if X=goal then return the path from Start to X; else begin generate children of X; for each child or X do case the child is not on open or closed: begin assign the child a heuristic value; add the child to open end; the child is already on open: if the child was reached by a shorter path then give the state on open the shorter path the child is already on closed: if the child was reached by a shorter path then begin remove the state from closed; add the child to open end; end; put X on closed; reorder states on open by heuristic merit (best leftmost) end; Return FAIL End;

  21. Best – First Search:

  22. Best – First Search: • Open=[A5]; Closed=[]; • Evaluate A5, Open=[B4, C4, D6]; Closed=[A5]; • Evaluate B4, Open=[C4, E5,F5, D6]; Closed=[B4,A5]; • Evaluate C4, Open=[H3, G4,E5,F5, D6]; Closed=[C4,B4,A5]; • Evaluate H3, Open=[O2,P3 , G4,E5,F5, D6]; Closed=[H3,C4,B4,A5]; • Evaluate O2, Open=[P3, G4,E5,F5, D6]; Closed=[O2,H3,C4,B4,A5]; • Evaluate P3, the solution is found !

  23. Heuristic Evaluation Functions: • استفاده از تعداد مربعهایی که در مکان خود قرار ندارند بعنوان تابع ارزشیابی. • استفاده از فاصله هر مربع با مکان آن در هدف. • یک عدد کوچک (مثلا 2) ضربدر تعداد مربعهایی که مستقیما با یکدیگر در ارتباط بوده و باید معکوس شوند.

  24. Heuristic Evaluation Functions: • اگر دو حالت مقدار ارزشیابی یکسانی داشته باشند معمولا حالتی که نزدیکتر به ریشه گراف (نقطه شروع) است احتمال بوجود آوردن مسیر کوتاهتری تا هدف را دارد.

  25. Heuristic Evaluation Functions:

  26. Heuristic Evaluation Functions:

  27. Admissibility, Monotonicity and Informedness • Heuristics that find the shortest path to a goal whenever it exists are said to be admissible. • We may want to ask whether any better heuristics are available. In what sense is one heuristic “better” than another? This is informedness of a heuristic. • When a state is discovered by using a heuristic search, is there any guarantee that the same state won’t be found later in the search at a cheaper cost. This is the property of monotonicity.

  28. Admissible • Breadth – first is admissible. • In determining the properties of admissible heuristics, we define an evaluation function f*: • f*(n) = g*(n) + h*(n) • Where g*(n) is the cost of the shortest path from the start node to node n, and h* returns the actual cost of the shortest path from n to the goal. f*(n) is the actual cost of the optimal path from a start node to a goal node that passes through node n. • g(n) >= g*(n) • h(n) <= h*(n) • If algorithm A uses an evaluation function f in which we have the above characteristics , it is called algorithm A*.

  29. Admissible • Consider the evaluation function f(n) = g(n) +h(n), where • n is any state encountered in the state. • g(n) is the cost of n from the start state. • h(n) is the heuristic estimate of the cost of going from n to a goal. • If this evaluation function is used with the best – first search algorithm, the result is called algorithm A. • A search algorithm is admissible, if for any graph, it always terminates in the optimal solution path whenever a path from the start to a goal state exists. • If algorithm A is used with an evaluation function in which h(n) is less than or equal to the cost of the minimal path from n to the goal, the resulting algorithm is called algorithm A*.

  30. Monotonic • A heuristic function h is monotone if • For all states and , where is a descendant of • Where is the actual cost of going from state to . • The heuristic evaluation of the goal state is zero h( Goal) =0.

  31. Monotonic • Any monotonic heuristic is admissible: • S1 to S2 • S2 to S3 • S3 to S4 • . • . • . • Sg-1 to Sg • Summing each column and using the monotone property of h(Sg)=0 • Path S1 to Sg • This means that monotone heuristic h is A*.

  32. Informedness • For two A* heuristics h1 and h2, if h1(n) <= h2(n) , for all states n in the search space, heuristic h2 is said to be more informed than h1.

More Related