PROBLEM SOLVING 030523111 Introduction to Artificial Intelligence Asst
PROBLEM SOLVING 030523111 – Introduction to Artificial Intelligence Asst. Prof. Dr. Choopan Rattanapoka
: 8 -Puzzle ปรภมสถานะ 1 8 Initial state 4 7 6 3 5 U D 1 U D 7 5 2 R 7 8 4 2 5 8 4 1 8 4 6 3 7 6 3 R 5 2 1 7 8 4 8 6 3 7 1 5 2 7 8 4 6 1 5 1 R Goal State 2 3 5 2 4 6 3 2 6 3
: 8 -Puzzle เสนทางไปสเปาหมาย 1 8 Initial state 4 7 6 3 5 U D 1 U D 7 5 2 R 7 8 4 2 5 8 4 1 8 4 6 3 7 6 3 R 5 2 1 7 8 4 8 6 3 7 1 5 2 7 8 4 6 1 5 1 R Goal State 2 3 5 2 4 6 3 2 6 3
BLIND SEARCH TECHNIQUES Choopan Rattanapoka 357353 – Introduction to AI
Breadth-First Search (BFS) เปนวธการคนหาในแนวกวาง (Breadth) จะคนหาทละโหนดจากซายไปขวาทละระดบของตนไม (level) วนซำไปเรอยๆจนกระทงพบโหนดเปาหมาย (อาศยหลกการของ queue) begin open : = [start]; close : = [ ] ; 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 close; discard children of X if already on open or closed put remaining children on right end of open end return FAIL end
Breadth-First Search (BFS) คนหา E A B D H C E I J F K L G M N O Open : [ A ] , Close : [ ] Open : [B C], Close : [ A ] Open : [C D E], Close : [B A] Open : [D E F G], Close : [C B A] : [E F G H I], Close : [D C B Open A] Found node E begin open : = [start]; close : = [ ] ; while open ≠ [ ] do begin remove leftmost state from open, call it X; if X is a goal then return SUCCESS else begin if X is not already on open or closed; put X on close; generate children of X; put children on right end of open end return FAIL end
Depth-First Search (DFS) เปนวธการคนหาในแนวลก (Depth) จะคนหาทละโหนดจากบนลงลาง หากไมพบเปาหมาย จะลงไปพจารณาโหลดลกทอยดานซายกอน (อาศยหลกการของ stack) begin open : = [start]; close : = [ ] ; while open ≠ [ ] do begin remove leftmost state from open, call it X; if X is a goal then return SUCCESS else begin if X is not already on open or closed; put X on close; generate children of X; put children on left end of open end return FAIL end
Depth-First Search (DFS) คนหา E A B C D H E I J F K L G M N O Open : [ A ] , Close : [ ] Open : [B C], Close : [ A ] Open : [D E C ], Close : [B A] Open : [H I E C ], Close : [D B A] Open : [I E C ], Close : [H D B A] Open : [E C], Close: [I H D B A] Found node E begin open : = [start]; close : = [ ] ; while open ≠ [ ] do begin remove leftmost state from open, call it X; if X is a goal then return SUCCESS else begin if X is not already on open or closed; put X on close; generate children of X; put children on left end of open end return FAIL end
สรป BFS VS DFS Completene ������ ss Optimalit y Time Complexity Space Complexity Breath-First Search YES O(bd) Depth-First Search NO NO O(bm) ���������������� 3 �������������� 5 ����� • BFS 35 = 243 • DFS 3 * 5 = 15
ตวอยางการคนหา : 8 -puzzle Initial state Goal state
: 8 -puzzle (BFS) ตวอยางการคนหา Initial state 1 Goal state 2 5 3 6 4
: 8 -puzzle (DFS) ตวอยางการคนหา 1 Initial state Goal state 2 3 4 5
: 8 -puzzle (DLS) ตวอยางการคนหา limit = 3 1 Initial state Goal state 2 3 4 6 7 5
: 8 -puzzle (IDS) ตวอยางการคนหา 10 Limit =2 Initial state 1 Goal state 2 3 3 4 5 4
(Blind สรปวธการคนหาแบบตางๆ search) Completene Optimalit ������ ss y Time Complexity Space Complexity Breath-First Search YES O(bd) Depth-First Search NO NO O(bm) Depth-Limited Search NO NO O(bl) Iterative Deepening Search YES O(bd) b จำนวนกงเฉลยของแตละโห นด d ระดบความลกทคนหาระดบ นน l
- Slides: 40