1 / 48

問題解決:木とグラフの探索

問題解決:木とグラフの探索. 白井 良明 立命館大学情報理工学部 知能情報学科 shirai@ci.ritsumei.ac.jp. ON (B, C) ON (C, A). ON (B, C) ON (C, A). 問題の記述:初期状態と目標状態. A. B. C. B. A. C. ONTABLE (A) ONTABLE (C). x. y. 問題の記述: オペレータ.

andrecobb
Download Presentation

問題解決:木とグラフの探索

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. 問題解決:木とグラフの探索 白井 良明 立命館大学情報理工学部 知能情報学科 shirai@ci.ritsumei.ac.jp

  2. ON (B, C) ON (C, A) ON (B, C) ON (C, A) 問題の記述:初期状態と目標状態 A B C B A C ONTABLE (A) ONTABLE (C)

  3. x y 問題の記述:オペレータ PICKUP(x);テーブルの上のxをつかむ                 前提条件: ONTABLE(x),CLEAR(x),EMPTY           削除リスト:ONTABLE(x),CLEAR(x),EMPTY           追加リスト:HOLD(x);手はxをつかんでいる      PUTDOWN(x);xをテーブルの上に置く                 前提条件: HOLD(x)                           削除リスト:HOLD(x)                           追加リスト: ONTABLE(x),CLEAR(x),EMPTYTAKEOFF(x,y);yの上にあるxをつかむ                前提条件:ON(x,y),CLEAR(x),EMPTY               削除リスト: ON(x,y),CLEAR(x),EMPTY               追加リスト:CLEAR(y),HOLD(x)                PUTON(x,y);xをyの上へ置く                       前提条件: HOLD(x),CLEAR(y)                    削除リスト:HOLD(x),CLEAR(y)                   追加リスト:  ON(x,y),CLEAR(x),EMPTY x x

  4. 木の探索 S A B C D E F H G

  5. width-first procedure depth-first tree search • add (s, open); • LOOP: if open = null then exit(fail); • n:= first(open); • If goal(n) then exit (success); • Remove(n, open); • Expand(n); • Put all child nodes into the top of open and attach pointers to n; • Go to LOOP. last

  6. グラフの探索 D B E G H A C F S I

  7. procedure depth-first tree search • add (s, open); • LOOP: if open = null then exit(fail); • n:= first(open); • If goal(n) then exit (success); • Remove(n, open); • Expand(n); • Put all child nodes into the top of open and attach pointers to n; • Go to LOOP. add(n, closed)

  8. procedure depth-first tree search • add (s, open); • LOOP: if open = null then exit(fail); • n:= first(open); • If goal(n) then exit (success); • Remove(n, open); add(n, closed) • Expand(n); • Put all child nodes into the top of open and attach pointers to n; • Go to LOOP. which are not in open nor closed

  9. 4 1 6 5 4 3 5 7 6 7 最適経路の探索 S 4 1 B A 2 3 1 2 E C F D 4 3 2 1 H G1 I G2

  10. procedure optimal tree search • add (s, open); g^(s):= 0; • LOOP: if open = null then exit(fail); • n:= first(open); • If goal(n) then exit (success); • Remove(n, open); • Expand(n); • Put all child nodes into open and attach pointers to n; • Sort nodes in open in increasing order of g^; • Go to LOOP.

  11. 4 1 6 5 4 3 5 7 6 7 最適経路の探索 S 4 1 B A 2 3 1 2 E C F D 4 3 2 1 H G1 I G2

  12. グラフ最適経路の探索 D B E G 6 5 4 5 3 6 H A 4 5 C F 6 S I

  13. procedure optimal tree search • add (s, open); g^(s):= 0; • LOOP: if open = null then exit(fail); • n:= first(open); • If goal(n) then exit (success); • Remove(n, open); • Expand(n); • Put all child nodes into open and attach pointers to n; • Sort nodes in open in increasing order of g^; • Go to LOOP.

  14. procedure optimal tree search • add (s, open); g^(s):= 0; • LOOP: if open = null then exit(fail); • n:= first(open); • If goal(n) then exit (success); • Remove(n, open); • Expand(n); • Put all child nodes into open, and attach pointers to n; • Sort nodes in open in increasing order of g^; • Go to LOOP. add(n, closed)

  15. procedure optimal tree search • add (s, open); g^(s):= 0; • LOOP: if open = null then exit(fail); • n:= first(open); • If goal(n) then exit (success); • Remove(n, open); add(n, closed) • Expand(n); • Put all child nodes into open, and attach pointers to n; • Sort nodes in open in increasing order of g^; • Go to LOOP. which are not in open nor closed. If child node j was in open and g^(n, j) < g^(j), then attach pointers to n;

  16. グラフ最適経路の探索 D B E G 6 5 4 5 3 6 H A 4 5 C F 6 S I

  17. グラフ最適経路の探索 4 B G 3 C A 2 H D E 4 S F

  18. グラフ最適経路の探索 4 B G 3 C A 2 7 H D E 4 S F

  19. グラフ最適経路の探索 4 B G 3 C A 2 / 5 7 H D E 4 S F

  20. グラフ最適経路の探索 4 B G 8 3 C A 2 6 5 H D E 4 6 S F

  21. 1 3 0 D B E G 2 3 A H 4 3 C F 4 6 S I グラフの最良優先探索

  22. 2 1 3 0 D B E G 2 3 A H 4 4 3 C F 4 6 S I グラフの最良優先探索 3 6

  23. 1 2 1 3 3 0 D B E G 2 3 A H 4 4 3 C F 4 6 S I グラフの最良優先探索 3 6

  24. 1 2 1 3 0 3 0 D B E G 2 2 3 A H 4 4 3 C F 4 6 S I グラフの最良優先探索 3 6

  25. procedure best-first search • add (s, open); • LOOP: if open = null then exit(fail); • n:= first(open); • If goal(n) then exit (success); • Remove(n, open); add(n, closed) • Expand(n); • Put all child nodes except in open or closed into open, Sort nodes in open in increasing order of h^ ; • Go to LOOP;

  26. 0 B G 4 3 A C 3 4 2 H D E 6 4 S F グラフの最良優先探索

  27. 2 0 B G 4 4 3 3 A C 3 4 2 H D E 6 6 4 S F グラフの最良優先探索 3

  28. 2 0 B G 4 4 3 3 A C 3 4 4 2 2 H D E 6 6 4 S F グラフの最良優先探索 3

  29. 2 0 0 B G 4 4 3 3 A C 3 4 4 2 2 H D E 6 6 4 4 S F グラフの最良優先探索 3

  30. A*アルゴリズム f^(n):= g^(n) + h^(n) 2 1 3 0 D B E G 6 3 2 A H 4 3 C F 4 6 6 S I

  31. 8 A*アルゴリズム 2 1 3 0 D B E G 6 3 2 A H 4 3 C F 4 6 6 S I

  32. 6 8 8 A*アルゴリズム 2 1 3 0 D B E G 6 3 2 A H 4 3 C F 4 6 6 S I

  33. 6 8 6 8 8 A*アルゴリズム 2 1 3 0 D B E G 6 3 2 A H 4 3 C F 4 6 6 S I

  34. procedure optimal tree search • add (s, open); g^(s):= 0; • LOOP: if open = null then exit(fail); • n:= first(open); • If goal(n) then exit (success); • Remove(n, open); add(n, closed) • Expand(n); • Put all child nodes into open, and attach pointers to n; • Sort nodes in open in increasing order of g^; • Go to LOOP. which are not in open nor closed. If child node j was in open,select min{g^(j), g^(n, j)},

  35. procedure optimal tree search • add (s, open); g^(s):= 0; • LOOP: if open = null then exit(fail); • n:= first(open); • If goal(n) then exit (success); • Remove(n, open); add(n, closed) • Expand(n); • Put all child nodes into open, and attach pointers to n; • Sort nodes in open in increasing order of g^; • Go to LOOP. which are not in open nor closed. If child node j was in open,select min{g^(j), g^(n, j)},

  36. procedure optimal search • add (s, open); g^(s):= 0; • LOOP: if open = null then exit(fail); • n:= first(open); • If goal(n) then exit (success); • Remove(n, open); add(n, closed) • Expand(n); • Put all child nodes except in open or closed into open, compute g, and attach pointers to n; and attach pointers to n; • Sort nodes in open in increasing order of g^; • Go to LOOP. If child node j was in open,select min{g^(j), g^(n, j)},

  37. A-algorithm procedure optimal search f^(s):=h^(s); • add (s, open); g^(s):= 0; • LOOP: if open = null then exit(fail); • n:= first(open); • If goal(n) then exit (success); • Remove(n, open); add(n, closed) • Expand(n); • Put all child nodes except in open or closed into open, compute g, and attach pointers to n; • Sort nodes in open in increasing order of g^; • Go to LOOP. f^(n, j):= g^(n, j) + h^(n); If child node j was in open,select min{g^(j), g^(n, j)},

  38. procedure A-algorithm • add (s, open);f^(s):=h^(s); • LOOP: if open = null then exit(fail); • n:= first(open); • If goal(n) then exit (success); • Remove(n, open); add(n, closed) • Expand(n); • Put all child nodes except in open or closed into open, compute g; f^(n, j):= g^(n, j) + h^(n); and attach pointers to n; • Sort nodes in open in increasing order of g^; • Go to LOOP. If child node j was in open,select min{g^(j), g^(n, j)}, min{f^(j), f^(n, j)}; f^;

  39. procedure optimal search procedure A-algorithm search procedure A-algorithm search • add (s, open); f^(s):= h^(s); • LOOP: if open = null then exit(fail); • n:= first(open); • If goal(n) then exit (success); • Remove(n, open); add(n, closed) • Expand(n); • Put all child nodes except in open or closed into open, compute g; f^(n, j):= g^(n, j) + h^(n); if node j is in open or closed, select min{f^(j), f^(n, j)} and put into open; Sort nodes in open in increasing order of f^; • Go to LOOP;

  40. A*アルゴリズム 2 0 6 B G 4 3 6 6 A C 3 4 2 D E H 6 6 4 S F

  41. A*アルゴリズム 2 0 6 B G 4 3 6 6 A C 3 4 2 8 10 D E H 6 6 4 S F

  42. A*アルゴリズム 2 0 6 B G 4 3 6 6 A C 8 3 4 2 8 D E H 6 6 10 4 S F

  43. A*アルゴリズム 2 8 0 6 B G 4 3 6 6 A C 8 3 4 2 8 10 8 D E H 6 6 10 4 S F

  44. CLOSED, OPEN を用いる例 10 S 3 1 9 9 6 10 A B 1 6 4 5 8 7 14 7 15 E D C

  45. CLOSED, OPEN を用いる例 10 S 3 1 8 9 6 10 A B 1 6 4 5 8 7 14 15 7 15 E D C

  46. CLOSED, OPEN を用いる例 10 S 3 1 8 9 6 10 A B 1 6 4 5 8 7 14 15 13 7 14 15 E D C

  47. A*アルゴリズムが有効な例 S (7) 4 5 6 9 9 8 (5) (4) (2) A B C 3 3 3 2 2 2 1 1 1 10 8 9 (2) (3) (3) (3) (3) (3) (1) D E K F H I J 4 4 4 4 4 4 4 2 1 3 3 4 4 4 9 8 G2 G1 G3 G4 G5 G6 G7 G8

  48. A*アルゴリズムとならない例 S 5 2 3 5 3 4 7 A B 4 2 G 6

More Related