ΠΛΗ31 ΜΑΘΗΜΑ 1.3

download ΠΛΗ31 ΜΑΘΗΜΑ 1.3

of 74

  • date post

    18-Aug-2015
  • Category

    Education

  • view

    117
  • download

    17

Embed Size (px)

Transcript of ΠΛΗ31 ΜΑΘΗΜΑ 1.3

  1. 1. 31 1: 1.3:
  2. 2. 2 , 31, 1.3: . . 1. 1. h*(v) 2. H h(v) 3. g(v) 2. UCS 1. 2. 3. 4. 5. 6. 7. 3. A*g(v) 2. 1. Greedy 1. 2. 3. 4. 5. 6. 7. 3. A* 1. 2. 3. 4. 5. 6. 7. .
  3. 3. . UCS A* 3 , 31, 1.3: (-)
  4. 4. . 1. : - - 4 , 31, 1.3: .
  5. 5. . 1. : 5 , 31, 1.3: 3 4 4 A B C S G. 3 4 5 2 5 4 3 S D E F G
  6. 6. 6 , 31, 1.3: S A DB D A E 3 4 5 54 425 54 4 2 E F C G D E B F C G B C E F G B F A C G 4 2 5 5 4 4 44 4 43 3 3 3 : S,A,B,E,F,G : S,A,D,E,F,G : S,D,A,B,E,F,G : S,D,E,F,G
  7. 7. . 1. 1. h*(v) v -, h*(v) 7 , 31, 1.3: h*(v) v ( ) v -. -, h*(v) . : : h*()=0 v : h*(v)=+ .
  8. 8. 8 , 31, 1.3: S A DB D A E 3 4 5 54 425 54 4 2 12 9 14 16 7 9 13 h* E F C G D E B F C G B C E F G B F A C G 4 2 5 5 4 4 44 4 43 3 3 3 : S,A,B,E,F,G : S,A,D,E,F,G : S,D,A,B,E,F,G : S,D,E,F,G 0 3+ + 7 0+ + 3 7 0 3 + 7 12 + + + 0 3
  9. 9. . 1. 1. h*(v) , . : 9 , 31, 1.3: .
  10. 10. . 1. 2. h(v) . . 10 , 31, 1.3: h(v) v h(v) , v - . . h(v) v -. , : h(v)h*(v) v .
  11. 11. . 1. 2. h(v) ** . 11 , 31, 1.3: s , . . v t h(v) h(v)h*(v)
  12. 12. . 1. 2. h(v): , . 12 , 31, 1.3: , .
  13. 13. . 1. 2. h(v): Manhattan - : 13 , 31, 1.3: 1 2 3 4 manhattan ((x1,y1),(x2,y2)) = |x1-x2|+|y1-y2| 1 2 3 4 Manhattan , . 1 2 3 4 1 4 3 2 3 2 3 2 3 2 1 4 3 2 1 2 1 2 3 4 1 2 3 4 (3,3)
  14. 14. . 1. 3. g(v) H v. * UCS 14 , 31, 1.3: H g(v) v v. * UCS . v t s h(v) h(v)h*(v) g(v) v
  15. 15. 15 , 31, 1.3: S A DB D A E 3 4 5 54 425 54 4 2 12 9 14 16 7 9 13 h* h 12/0 11/3 7/4 7/7 7/8 4/9 5/6 g E F C G D E B F C G B C E F G B F A C G 4 2 5 5 4 4 44 4 43 3 3 3 : S,A,B,E,F,G : S,A,D,E,F,G : S,D,A,B,E,F,G : S,D,E,F,G 0 3+ + 7 0+ + 3 7 0 3 + 7 12 + + + 0 3 +/11 4/12 +/14 +/15 2/16 5/10 2/14 4/13 +/17 6/18 +/11 +/15 +/15 0/17 3/22 0/19 0/25 0/13 3/10 +/19
  16. 16. . 3. 1. . 1 16 , 31, 1.3: , ** .
  17. 17. . 3. 1. (1.) 17 , 31, 1.3: GREEDY(S,T) =[(S,f(S))] =[] : 1. v f(v)f(u) u 2. v 3. v. v3. v. v . 4. v u v: 4.1 f(u) 4.2 ( u , ) (u,f(u)) ( u ) f(u) ) (>=) u v (u,) (u,) . f(x) h(x)
  18. 18. . 2. 1. (1.) : 18 , 31, 1.3: : f(x)=h(x). :: . ( ) f(v)=h(v). : . , . , . : -
  19. 19. 12 19 , 31, 1.3: S . 2. 1. (2. ) 0 {(S,12)} {}
  20. 20. 20 , 31, 1.3: A D 12S (1) 11 7 0 {(S,12)} {} 1 {(,11),(D,7)} {(S,12)}
  21. 21. 21 , 31, 1.3: A E A D 12S (1) 11 7 (2) 4 5 0 {(S,12)} {} 1 {(,11),(D,7)} {(S,12)} 2 {(,4),(E,5)} {(S,12),(D,7)}
  22. 22. 22 , 31, 1.3: A E A D 12S (1) 11 7 (2) 4 5 (3) B 4 0 {(S,12)} {} 1 {(,11),(D,7)} {(S,12)} 2 {(,4),(E,5)} {(S,12),(D,7)} 3 {(B,4),(E,5)} {(S,12),(D,7),(A,4)}
  23. 23. 23 , 31, 1.3: A E A D 12S (1) 11 7 (2) 4 5 (3) (4) C E B 4 + 6 (4) 0 {(S,12)} {} 1 {(,11),(D,7)} {(S,12)} 2 {(,4),(E,5)} {(S,12),(D,7)} 3 {(B,4),(E,5)} {(S,12),(D,7),(A,4)} 4 {(C,+),(E,5)} {(S,12),(D,7),(A,4),(B,4)}
  24. 24. 24 , 31, 1.3: A E A D 12S (1) 11 7 (2) 4 5 (3) (4) (5) B F C E B 4 + 6 (4) + 3 0 {(S,12)} {} 1 {(,11),(D,7)} {(S,12)} 2 {(,4),(E,5)} {(S,12),(D,7)} 3 {(B,4),(E,5)} {(S,12),(D,7),(A,4)} 4 {(C,+),(E,5)} {(S,12),(D,7),(A,4),(B,4)} 5 {(C,+),(F,3)} {(S,12),(D,7),(A,4),(B,4), (E,5)}
  25. 25. 25 , 31, 1.3: A E A D 12S (1) 11 7 (2) 4 5 (3) (4) (5) (6) G0 0 B F C E B 4 + 6 (4) + 3 (6) 0 {(S,12)} {} 1 {(,11),(D,7)} {(S,12)} 2 {(,4),(E,5)} {(S,12),(D,7)} 3 {(B,4),(E,5)} {(S,12),(D,7),(A,4)} 4 {(C,+),(E,5)} {(S,12),(D,7),(A,4),(B,4)} 5 {(C,+),(F,3)} {(S,12),(D,7),(A,4),(B,4), (E,5)} 6 {(C,+),(G,0)} {(S,12),(D,7),(A,4),(B,4), (E,5),(F,3)}
  26. 26. 26 , 31, 1.3: A E A D 12S (1) 11 7 (2) 4 5 (3) (4) (5) (6) 0 {(S,12)} {} 1 {(,11),(D,7)} {(S,12)} 2 {(,4),(E,5)} {(S,12),(D,7)} G B F C E B 4 + 6 (4) + 3 (6) 0 (7) 3 {(B,4),(E,5)} {(S,12),(D,7),(A,4)} 4 {(C,+),(E,5)} {(S,12),(D,7),(A,4),(B,4)} 5 {(C,+),(F,3)} {(S,12),(D,7),(A,4),(B,4), (E,5)} 6 {(C,+),(G,0)} {(S,12),(D,7),(A,4),(B,4), (E,5),(F,3)} 7 {(C,+)} {(S,12),(D,7),(A,4),(B,4), (E,5),(F,3),(G,0)} : S-D-E-F-G : 13 : S-D-A-E-B-F-G : 7
  27. 27. . 2. 1. (3.) 1: : () , . 27 , 31, 1.3: . 2: : - 3: : , .
  28. 28. . 2. 1. (4.) : , . . 28 , 31, 1.3: . : (bd) : (bd)
  29. 29. . 2. 2. UCS 2 UCS (Uniform Cost Search) , . UCS 29 , 31, 1.3: UCS ( Dijkstra)
  30. 30. . 2. 2. UCS (1.) 30 , 31, 1.3: UCS(S,T) =[(S,f(S))] =[] : 1. v f(v)f(u) u 2. v 3. v. v3. v. v . 4. v u v: 4.1 f(u) 4.2 ( u , ) (u,f(u)) ( u ) f(u) ) (>=) u v (u,) (u,) . f(x) g(x)
  31. 31. . 2. 2. UCS (1.) : 31 , 31, 1.3: UCS : f(x)=g(x). :: . ( ) f(v)=g(v). : . , . , . : -
  32. 32. 32 S 0 , 31, 1.3: . 2. 2. UCS (2. ) 0 {(S,0)} {}
  33. 33. 33 , 31, 1.3: A D 3 4 S 0 (1) 3 4 0 {(S,0)} {} 1 {(A,3),(D,4)} {(S,0)}
  34. 34. 34 , 31, 1.3: DB 54 A D 3 4 S 0 (1) 3 4 (2) 7 8 0 {(S,0)} {} 1 {(A,3),(D,4)} {(S,0)} 2 {(D,4),(B,7)} {(S,0),(A,3)}
  35. 35. 35 , 31, 1.3: A E 5 2 DB 54 A D 3 4 S 0 (1) 3 4 (2) 7 8 (3) 9 6 0 {(S,0)} {} 1 {(A,3),(D,4)} {(S,0)} 2 {(D,4),(B,7)} {(S,0),(A,3)} 3 {(B,7),(E,6)} {(S,0),(A,3),(D,4)}
  36. 36. 36 , 31, 1.3: 5 4 A E 5 2 DB 54 A D 3 4 S 0 (1) 3 4 (2) 7 8 (3) 9 6 (4) B F11 10 0 {(S,0)} {} 1 {(A,3),(D,4)} {(S,0)} 2 {(D,4),(B,7)} {(S,0),(A,3)} 3 {(B,7),(E,6)} {(S,0),(A,3),(D,4)} 4 {(B,7),(F,10)} {(S,0),(A,3),(D,4),(E,4)}
  37. 37. 37 , 31, 1.3: 54 5 4 A E 5 2 DB 54 A D 3 4 S 0 (1) 3 4 (2) 7 8 (3) 9 6 (4) (5) EC B F11 10 11 12 0 {(S,0)} {} 1 {(A,3),(D,4)} {(S,0)} 2 {(D,4),(B,7)} {(S,0),(A,3)} 3 {(B,7),(E,6)} {(S,0),(A,3),(D,4)} 4 {(B,7),(F,10)} {(S,0),(A,3),(D,4),(E,4)} 5 {(F,10),(C,11)} {(S,0),(A,3),(D,4),(E,4),(B,7)}
  38. 38. 38 , 31, 1.3: 54 5 4 A E 5 2 DB 54 A D 3 4 S 0 (1) 3 4 (2) 7 8 (3) 9 6 (4) (5) (6) G 3 EC B F1111 12 10 13 (6) 0 {(S,0)} {} 1 {(A,3),(D,4)} {(S,0)} 2 {(D,4),(B,7)} {(S,0),(A,3)} 3 {(B,7),(E,6)} {(S,0),(A,3),(D,4)} 4 {(B,7),(F,10)} {(S,0),(A,3),(D,4),(E,4)} 5 {(F,10),(C,11)} {(S,0),(A,3),(D,4),(E,4),(B,7)} 6 {(G,13),(C,11)} {(S,0),(A,3),(D,4),(E,4),(B,7), (F,10)} F
  39. 39. 39 , 31, 1.3: 54 5 4 A E 5 2 DB 54 A D 3 4 S 0 (1) 3 4 (2) 7 8 (3) 9 6 (4) (5) (6) (7) G 3 EC B F1111 12 10 13 (6) 0 {(S,0)} {} 1 {(A,3),(D,4)} {(S,0)} 2 {(D,4),(B,7)} {(S,0),(A,3)} 3 {(B,7),(E,6)} {(S,0),(A,3),(D,4)} 4 {(B,7),(F,10)} {(S,0),(A,3),(D,4),(E,4)} 5 {(F,10),(C,11)} {(S,0),(A,3),(D,4),(E,4),(B,7)} 6 {(G,13),(C,11)} {(S,0),(A,3),(D,4),(E,4),(B,7),(F,10)} 7 {(G,13)} {(S,0),(A,3),(D,4),(E,4),(B,7),(F,10),(C,11)}
  40. 40. 40 , 31, 1.3: 54 5 4 A E 5 2 DB 54 A D 3 4 S 0 (1) 3 4 (2) 7 8 (3) 9 6 (4) (5) (6) (7) G 3 EC B F1111 12 10 13 (6) (8) 0 {(S,0)} {} 1 {(A,3),(D,4)} {(S,0)} 2 {(D,4),(B,7)} {(S,0),(A,3)} 3 {(B,7),(E,6)} {(S,0),(A,3),(D,4)} 4 {(B,7),(F,10)} {(S,0),(A,3),(D,4),(E,4)} 5 {(F,10),(C,11)} {(S,0),(A,3),(D,4),(E,4),(B,7)} 6 {(G,13),(C,11)} {(S,0),(A,3),(D,4),(E,4),(B,7),(F,10)} 7 {(G,13)} {(S,0),(A,3),(D,4),(E,4),(B,7),(F,10),(C,11)} 8 {} {(S,0),(A,3),(D,4),(E,4),(B,7),(F,10),(C,11),(G,13)} : S-D-E-F-G : 13 : S-A-D-E-B-F-C-G : 8
  41. 41. . 2. 2. UCS (3.) 1: : () , . 41 , 31, 1.3: . 2: - 3: : , .
  42. 42. . 2. 2. UCS (4.) : , . . 42 , 31, 1.3: . : (bd) : (bd)
  43. 43. . 2. 3. A* 3 A*, h g, . O A* , 43 , 31, 1.3: O A* , .
  44. 44. . 2. 3. * (1.) 44 , 31, 1.3: *(S,T) =[(S,f(S))] =[] : 1. v f(v)f(u) u 2. v 3. v. v3. v. v . 4. v u v: 4.1 f(u) 4.2 ( u , ) (u,f(u)) ( u ) f(u) ) (>=) u v (u,) (u,) . f(x) g(x)+h(x)
  45. 45. . 2. 2. A* (1.) : 45 , 31, 1.3: A* : f(x)=g(x)+h(x). :: . ( ) f(v)=g(v)+h(v). : . , . , . : -
  46. 46. 46 12+ 0 12 , 31, 1.3: S . 2. 3. A* (2. ) 0 {(S,12)} {}
  47. 47. 47 , 31, 1.3: A D 3 4 12+ 0 12S (1) 11+ 3= 14 7+ 4= 11 0 {(S,12)} {} 1 {(A,14),(D,11)} {(S,12)}
  48. 48. 48 , 31, 1.3: A E 5 2 A D 3 4 12+ 0 12S (1) 11+ 3= 14 7+ 4= 11 (2) 4+ 9= 13 5+ 6= 11 0 {(S,12)} {} 1 {(A,14),(D,11)} {(S,12)} 2 {(A,13),(E,11)} {(S,12),(D,11)}
  49. 49. 49 , 31, 1.3: 5 4 A E 5 2 A D 3 4 12+ 0 12S (1) 11+ 3= 14 7+ 4= 11 (2) 4+ 9= 13