1 / 94

인공지능 (Artificial Intelligence)

Week2 . Search 최 윤 정. 인공지능 (Artificial Intelligence).  가지 않은 길 R. 프로스트  노란 숲 속에 두 갈래 길이 있었습니다 나는 두 가지 길을 다 가지 못하는 것을 안타깝게 생각하면서 오랫동안 서서 한 길이 굽어 꺾여 내려간 데까지 바라볼 수 있는 데까지 멀리 바라다 보았습니다 그리고 똑같이 아름다운 다른 길을 선택 했습니다 그 길에는 풀이 더 많고 사람이 걸은 자취가 적어 아마 더 걸어야 될 길이라고 나는 생각했었던 거지요

kenda
Download Presentation

인공지능 (Artificial Intelligence)

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. Week2 . Search 최윤 정 인공지능(Artificial Intelligence)

  2. 가지 않은 길 R. 프로스트 노란 숲 속에 두 갈래 길이 있었습니다 나는 두 가지 길을 다 가지 못하는 것을 안타깝게 생각하면서 오랫동안 서서 한 길이 굽어 꺾여 내려간 데까지 바라볼 수 있는 데까지 멀리 바라다 보았습니다 그리고 똑같이 아름다운 다른 길을 선택 했습니다 그 길에는 풀이 더 많고 사람이 걸은 자취가 적어 아마 더 걸어야 될 길이라고 나는 생각했었던 거지요 그 길을 걸으므로,그 길도 거의 같아질 것이겠지만 그날 아침 두 길에는 낙엽을 밟은 자취는 없었습니다 아....나는 다음날을 위하여 한길은 남겨 주었습니다 길은 길에 이어져 끝이 없으므로 내가 다시 돌아 올 수 있는지를 의심 하면서 오랜 세월이 흐른 훗날에 나는 한숨을 쉬면서 이야기 할 것입니다 숲 속에 두 갈래 길이 있었다고 나는 사람이 적게 가는 길을 택하였다고 그리고 그것 때문에 모든 것이 달라졌다고 Prologue 희망이란.. 본래 있다고도 할 수 없고 없다고도 할 수 없다. 그것은 마치 땅 위의 길과 같은 것이다. 본래 땅 위에는 길이 없었다. 한 사람이 먼저 가고 걸어가는 사람이 많아지면 그것이 곧 길이 되는 것이다. - 루쉰의'고향'중에서..

  3. !! • 탐색 : 문제해결을 위해 적용하는 아주 흔한 기법.! • 만약 우리가 문제 해결을 위해서 취해야 할 행동들이 무엇인지 알고 있지만 어떤 순서로 행동을 취해야 문제가 해결되는지 알지 못한다면 가능한 모든 순서의 조합을 다 시도해 보아야 한다. • 상태공간에서의 문제 풀이과정 • 목표: 과제를 수행하는 프로그램 • 제약조건: • 사용 가능한 컴퓨터언어, 처리시간 및 메모리 용량. • 인간의 문제풀이 과정을 상태공간의 개념으로 형식화

  4. Problem State Space • What is Problem State Space? • What is valid move within the space? • Rule of the Game • Characteristic of the State Space • How to find the Solution Path in the State Space? • Search Methods

  5. What is Problem State Space? • 상태공간 (State Space): • 표현방식을 설정하는 풀이 과정에서 발생하는 모든 가능한 매 순간의 문제상태들의 집합 • 변수를 사용하여 수식으로 표현하거나,논리식으로서 표현 • 초기상태(Initial State) : 문제 풀이과정이 시작되는 최초의 상태 • 목표상태(Goal State) : 문제 풀이과정에서 최종적으로 도달하여야 할 목표상태 • 동작자(operator)의 정의 • 동작자를 적용하여 문제의 상태를 다른 상태로 변환 • 동작자는 주어진 제약 조건을 만족해야 한다.

  6. 8-Puzzel 3 1 2 3 2 1 8 8 4 4 6 5 7 6 5 7 List Representation (2 0 3 1 8 4 7 6 5) : Initial State (1 2 3 8 0 4 7 6 5) : Goal State (0 2 3 1 8 4 7 6 5) : Intermediate States (2 8 3 1 0 4 7 6 5) (2 3 0 1 8 4 7 6 5) 2 3 8 3 2 2 3 1 1 4 8 4 8 1 4 7 7 6 5 5 7 6 5 6 a c b

  7. State Space of 8-Puzzle(2) • Position Function Pos(1, 1) = 2 Pos(1, 2) = 8 …. Or Predicate? Pos(1, 1, 2) = True Empty(3, 2) = True Valid Moves of 8-Puzzle List (2 0 3 1 8 4 7 6 5)  (0 2 3 1 8 4 7 6 5) (2 0 3 1 8 4 7 6 5)  (2 8 3 1 0 4 7 6 5) (2 0 3 1 8 4 7 6 5)  (2 3 0 1 8 4 7 6 5) Predicate (empty 1 2)  (pos 1 1 x)  (empty 1 1) (pos 1 2 x)

  8. Water Jug Problem • 2 water jugs : 4 liter, 3 liter Need to get exactly 2 liters of water • State space? (0, 0) : initial (2, 0) : Goal • Valid move? • (4,0) (1, 3)  (0, 1)(4, 1) (2,3) (2,0 ) • (0,3)  (3, 0)  (3, 3)  (4, 2)  (0, 2) • ..?

  9. Examples • Tower of Hanoi : C or Java • Missionaries & Cannibals Problem : LISP • Maze & Blocks world : C or Java

  10. C A B Tower of Hamoi • 문제는 막대 A에 쌓여있는 원판 3개를 막대 C로 옮기는 것이다. 단 다음의 조건을 지켜야 한다. • 한 번에 하나의 원판만 이동할 수 있다 • 맨 위에 있는 원판만 이동할 수 있다 • 크기가 작은 원판위에 큰 원판이 쌓일 수 없다. • 중간의 막대를 임시적으로 이용할 수 있으나 앞의 조건들을 지켜야 한다.

  11. C C B B A A C C A B B A C C A B B A C C B B A A 3개의 원판인 경우의 해답 • 3개중 위 2개의 원판을 A->B • A의제일 큰 원판을 A->C • B 에있는 2개의 원판을 B->C

  12. 문제의 일반화 n-1개의 원판을 A에서 B로 옮기고 n번째 원판을 A에서 C로 옮긴 다음, n-1개의 원판을 B에서 C로 옮긴다. 필요한 변수 원판의 개수 : n 어디에서 어디로? : from  to 임시막대 1개 : tmp 따라서, 함수의 prototype n-1개의 원판 1개의 원판 C B A C B A C B A C B A n개의 원판인 경우 • void hanoi_tower(int n, char from, chartmp, char to)

  13. void hanoi_tower(int n, char from, chartmp, char to) ? • if(n==1) 1. 1번 원판을 fromto즉, AC로옮긴다. • else n>=1 이면{ 2. from의맨아래 원판을 제외한 (n-1)개의 원판을 fromtmp, 즉AB로 옮긴다. 3. 2번에서 옮기지 않은 from의 1번원판을fromto, AC로 옮긴다. 4. 임시막대인 tmp의 원판들을 to로 옮긴다. } 2. hanoi_tower(n-1, from, to, tmp); 4. hanoi_tower(n-1, tmp, from, to);

  14. 하노이탑 실습 (전공및 4학년 제외) • #include <stdio.h> • voidhanoi_tower(int n, char from, chartmp, char to) • { • if( n==1 ) printf("원판 1을 %c 에서 %c으로 옮긴다.\n",from,to); • else { • hanoi_tower(n-1, from, to, tmp); • printf("원판 %d을 %c에서 %c으로 옮긴다.\n",n, from, to); • hanoi_tower(n-1, tmp, from, to); • } • } • intmain(void) • { • hanoi_tower(4, 'A', 'B', 'C'); • }

  15. Missionaries & Cannibals Problem • 3명의 선교사와 3명의 식인괴물(cannibal)이 강 한 쪽편에 있어요. • 보트를 이용해 강을 건너야 하는데, 보트는 1개이고 1번 건너갈 때 최대 2명을 태울 수 있어요 • 그러니까 1명은 노를 저어야 합니다. • 만약 식인괴물 수가 선교사보다 많으면(같으면 괜찮아요) 선교사가 괴물한테 잡아 먹힙니다. 선교사를 무사히 살려서 6명 모두 강을 건너는 퀴즈. • 이런 문제는 C나Java로도 물론 할 수 있겠으나 • 일련의 규칙과 조건을 표현하는 데 용이한 언어를 이용하면 쉽게(?) 해결됩니다.

  16. Lisp 코드(실습시간에 돌려봅니다) ;;;; The Missionaries and Cannibals Domain (defun goal-test (state) "The goal is to have no missionaries or cannibals left on the first side." (= 0 (m1 state) (c1 state))) (defun successors (state) "Return a list of (action . state) pairs. An action is a triple of the form (delta-m delta-c delta-b), where a positive delta means to move from side 1 to side 2; negative is the opposite. For example, the action (1 0 1) means move one missionary and 1 boat from side 1 to side 2." (let ((pairs nil)) (loop for action in '((+1 0 +1) (0 +1 +1) (+2 0 +1) (0 +2 +1) (+1 +1 +1) (-1 0 -1) (0 -1 -1) (-2 0 -1) (0 -2 -1) (-1 -1 -1)) do (let ((new-state (take-the-boat state action))) (when (and new-state (not (cannibals-can-eat? new-state))) (push (cons action new-state) pairs)))) pairs)) (defun main () (print-actions (solve)) 'done) (defun solve () (labels ((iter (state path) (if (goal-test state) (reverse path) (let ((ss (remove-cyclic (successors state) path))) (and ss (some #'(lambda (s) (iter (cdr s) (cons s path))) (suffless))))))) (iter (make-cannibal-state) (list (cons 'Begin (make-cannibal-state)))))) (defun remove-cyclic (succs path) (remove-if #'(lambda (s) (member s path :test #'(lambda (a b) (equal (cdr a) (cdr b))))) succs)) (defun print-actions (path) (format t "~&~10A ~{~4S~}" "Action" '(m1 c1 b1 m2 c2 b2)) (mapc #'(lambda (p) (format t "~&~10A~{~4d~}" (car p) (cdr p))) path)) (defunsuffle (lst) (sort (copy-list lst) #'> :key #'(lambda (x) (declare (ignore x)) (random 1.0))))

  17. Lisp 코드 (defstruct (cannibal-state (:conc-name nil) (:type list)) "The state says how many missionaries, cannibals, and boats on each side. The components m1,c1,b1 stand for the number of missionaries, cannibals and boats, respectively, on the first side of the river. The components m2,c2,b2 are for the other side of the river." ;; We need to represent both sides (rather than just one as on [p 68]) ;; because we have generalized from 3+3 people to M+C. Incidently, we ;; also generalized from 1 boat to B boats. (m1 3) (c1 3) (b1 1) (m2 0) (c2 0) (b2 0)) (defun take-the-boat (state action) "Move a certain number of missionaries, cannibals, and boats (if possible)." (destructuring-bind (delta-m delta-c delta-b) action (if (or (and (= delta-b +1) (> (b1 state) 0)) (and (= delta-b -1) (> (b2 state) 0))) (let ((new (copy-cannibal-state state))) (decf (m1 new) delta-m) (incf (m2 new) delta-m) (decf (c1 new) delta-c) (incf (c2 new) delta-c) (decf (b1 new) delta-b) (incf (b2 new) delta-b) (if (and (>= (m1 new) 0) (>= (m2 new) 0) (>= (c1 new) 0) (>= (c2 new) 0)) new nil)) nil))) (defun cannibals-can-eat? (state) "The cannibals feast if they outnumber the missionaries on either side." (or (> (c1 state) (m1 state) 0) (> (c2 state) (m2 state) 0))) CL-USER 1 > (main) Action M1 C1 B1 M2 C2 B2 BEGIN 3 3 1 0 0 0 (0 2 1) 3 1 0 0 2 1 (0 -1 -1) 3 2 1 0 1 0 (0 2 1) 3 0 0 0 3 1 (0 -1 -1) 3 1 1 0 2 0 (2 0 1) 1 1 0 2 2 1 (-1 -1 -1) 2 2 1 1 1 0 (2 0 1) 0 2 0 3 1 1 (0 -1 -1) 0 3 1 3 0 0 (0 2 1) 0 1 0 3 2 1 (-1 0 -1) 1 1 1 2 2 0 (1 1 1) 0 0 0 3 3 1 DONE CL-USER 2 >

  18. MazeProblem • n×m행렬 M • 미로의 입구를 M[0,0], 미로의 출구를 M[n-1,m-1] 동작자 정의의 예 상태 공간의 정의 현재 위치 : - {(x, y)| x = 0,1,...,n-1,y = 0,1,...,m-1}으로 표현 가능 - 초기 상태 : 시작상태로서 (x, y) = (0,0) - 목표 상태 : 미로의 출구에 있는 상태, 즉 (x, y) = (n-1,m-1)

  19. 탐색트리와 탐색그래프(1) • 탐색트리 • 노드: 상태 • 근(root) 노드: 초기상태 • 자식(child) 노드들: 하나의 노드에동작자를 적용하였을 때 생기는 결과 상태들 • 문제를 풀어나가는 과정 • Root노드들로부터 적용 가능한 동작자들을 선정하여 적용 • 노드가목표상태가 될 때까지 노드의선택- 확장과정을 반복 • 탐색 트리의 예 • 초기의 문제 상태: 거북이가 미로의 M(0,0) 에 위치 • 밑줄을 그은 노드들은 탐색 트리의 다른 부분에 중복 • 초기상태에서 목표상태에 도달하는 경로를 추적하기 위하여, 자식노드에는부모노드를 가리키는 역방향 arc표시

  20. 탐색트리와 탐색그래프(2) • 탐색 그래프 • 단순히 존재하는 노드간의연결 • 순환하는 경로, 즉 사이클(cycle)허용 -> 그래프 • 자식노드에서부모노드로의역방향 아크의설정시여러 개의 부모 노드가 가능 • MainStrategy : • 탐색 트리/그래프 상에서, 초기 상태로 부터 목표상태로 도달하는 경로(path)를 발견하는 방식 • 점진적인 트리의 확장: 탐색 트리 혹은 그래프상에 존재 하는 노드들 중 하나의 노드를 선택 • 자식노드들을 정해진 전략에 따라 순서대로 기존의 탐색 트리에 추가 • 문제 : 기존노드의선택 및 자식노드의 확장 순서를 결정하는방법 • 노드의 확장 방향? : 너비우선, 깊이우선…. • 초기상태 -> 목표상태, 목표상태 -> 초기상태 경험적 지식(heuristic knowledge)을 사용할 수 있는가?

  21. Characteristic of State SpaceStrategy of State Space Search Algorithms ..Hill climbing, game tree ..

  22. Characteristics of State Space • Decomposable? • goal -- subgoals • BlindvsInformed (heuristic) Search • RevocablevsIrrevocable • backtracking • PredictablevsStochastic • OptimalvsPlausible Solution • Slide 맨 뒷장 보충자료 참고합니다.

  23. Search Algorithm • Guarantee to find a solution ? • Always terminate ? • Guarantee the solution to be optimal -- admissible? • Complexity - time and space • How can the complexity be reduced ? • Characteristics of the space? State Space Search !

  24. Strategies of SS Search • Data-Driven vs. Goal Driven • Forward chaining / Backward chaining • Symptom  diagnosis : Forward eg. Fever, cough  flu • Goal/Sub-goal : Backward eg. Good Husband? Girl? Rich? Or Handsome & Pretty ,,,

  25. Forward vs Backward • Factors deciding Forward/Backward • Size of the known states: initial, goal • small to big • Branching Factor : converging • computational simplicity eg. Water jug problem • When is forward (backward) better? • Bi-Directional ▶어느 방식을 적용할 것인가는 문제의 특성에 의존적 : 예)선택해야 할 경우의 수가 적은가? Bi-Directional(양방향) 추론 : 순방향 추론과 역방향 추론을 혼용한 방식 ▶초기상태와 목표상태 양쪽에서 동시에 상대편 상태 쪽으로 경로를 찾아 나가는 방식 ▶평균적으로 계산시간이 감소되며, 경로가 어긋나는 경우, 추론 과정을 반복

  26. Implementing Search(1) • Blind Search • Search does not depend on the nature of the positional value • Systematic Search Method • Breadth-First Search • Depth-First Search • Iterative Deepening Search • Lowest Cost First Search (blind 와 heuristic의 경계) • Heuristic Search

  27. Implementing Search(2) • Blind Search • Heuristic Search • Hill Climbing • Best First Search • A* Algorithm

  28. 1 1 3 3 2 2 4 4 5 5 9 9 6 6 8 8 7 7 Blind Search • Abstract Data Type – Tree (참고만 해보세요.) (defun make-TREE(label value children) (list ‘tree label value children)) (defun TREE-label (tree) (second tree)) (defun TREE-value(tree) (third tree)) (defun TREE-children(tree)(fourth tree)) (defun TREE-print(tree) (princ(TREE-label tree))) Depth-First Search Example Breadth-First Search Example

  29. Depth First Search 1. 빈 큐(Queue)에 초기상태 노드를 넣는다. 2. 큐가 비어 있지 않고 답 =찾지못함 이면 다음을 반복한다. 3. 큐에서 하나의 노드N 을 빼낸다. 4. N과 N의 부모노드를 쌍(Pair)으로 만들어 LIST에 넣는다. 5. 만약 N 이 목적상태노드 이면 답 = 찾음으로한다. 6. N의 자식노드가 있으면 자식노드중LIST에 없는 자노드만 큐에 넣는다. (e.g., QUEUE ={도서관}) LIST = { }; 초기의 리스트는 비어 있음 답 = 찾지못함. (e.g., 리스트={(도서관, NIL)} (e.g., QUEUE ={병원 초등학교}) • (defundfs(nodes goalp next) • (cond ((null nodes) nil) • ((funcallgoalp (first nodes)) (first nodes)) • (t (dfs (append (funcall next (first nodes)) • (rest nodes)) • goalp • next ) ) ) ) Lisp 코드의 예

  30. Function DFS • > (setq tree • (make-TREE ‘a 6 • (list (make-TREE ‘b 3 • (list(make-TREE ‘d 5 nil) • (make-TREE ‘e 4 nil)))))) • // 이 부분은 인공지능실습시간에 실습해 봅니다. • > (dfs (list tree) • #’(lambda(x) (TREE-print x) • (eq ‘g (TREE-label x))) • #’TREE-children)

  31. DFS에서의 Stack과 QUEUE상태 • 1) QUEUE = {도서관}, 답 = 찾지못함 • LIST={ } . • 2) QUEUE = {병원 초등학교}, 답 = 찾지못함 • LIST ={(도서관, NIL)} . • 3) QUEUE = {초등학교 공원 중학교}, 답 = 찾지못함 • LIST ={(병원, 도서관)(도서관, NIL)} • 4) QUEUE = {공원 중학교 상가}, 답 = 찾지못함 • LIST ={(초등학교, 도서관)(병원, 도서관)(도서관, NIL)} • 5) QUEUE = {중학교 상가}, 답 = 찾지못함 • LIST ={(공원, 병원) (초등학교, 도서관)(병원, 도서관)(도서관, NIL)} • 6) QUEUE = {상가 대학교 교회}, 답 = 찾지못함 • LIST ={(중학교, 병원)(공원, 병원) (초등학교, 도서관)(병원, 도서관)(도서관, NIL)} • 7) QUEUE = {대학교 교회}, 답 = 찾지못함 • LIST ={(상가, 초등학교)(중학교, 병원)(공원, 병원) (초등학교, 도서관)(병원, 도서관) (도서관, NIL)} • 8) QUEUE = {교회}, 답 = 찾음 • LIST ={(대학교, 중학교)(상가, 초등학교)(중학교, 병원)(공원, 병원)(초등학교, 도서관) (병원, 도서관)(도서관, NIL)}

  32. Breadth First Search • (defunbfs(nodes goalp next) • (cond ((null nodes) nil) • ((funcallgoalp (first nodes)) (first nodes)) • (t (bfs (append (rest nodes) • (funcall next (first nodes))) • goalp • next ) • ) • ) • )

  33. Comparison of BFS and DFS • BFS always terminate if goal exist cf. DFS on infinite tree • BFS Guarantee shortest path to the goal (admissible) • Backtracking ? • Multiple Goals • Space requirement • BFS - Exponential • DFS - Linear Which is better ? BFS or DFS ? DFS의 특징중 하나는 시작노드에서목적노드까지의 가장 짧은 거리를 처음에 찾는 것을 보장 할 수 없다는 것이다. 하나의 길이 찾아진 후에 더 짧은 길이 발견될 수 있는 것이다. (그래프에서 두 노드를 연결하는 길은 하나 이상이 있을 수 있다.) 하지만 BFS 탐색은 DFS 탐색과는 달리 처음 찾은 길이 가장 짧은 길이 된다.

  34. Iterative Deepening Search • Compromise of BFS and DFS • Branch and Bound • Set the Limit then DFS • If Fail, extend the limit (one step) • Save on Storage, guarantee shortest path

  35. Lowest Cost First Search • Borderline between Blind and Heuristic Search • Cost value is assigned to each arc • Moveset (candidate list) is a priority queue ordered by path cost Eg. Dijkstra’s algorithm • When Arc cost is unit value, BFS • (Supplement : Slide - 72)

  36. Search Summary

  37. Heuristic Search • Blind search assumes no information about the domain – Too expensive • Heuristic Information can be helpful • Heuristic Function f(n) = g(n) + h(n) f: total cost g: cost from start to node n (real value) h: cost from node n to goal (usually unknown)

  38. Cost: 거리 = 휴리스틱 (Supplement : Slide - 84)

  39. Heuristic Function • Heuristics : Knowledge obtained from human experience • Heuristic function h : SS  number • a preference measure for each position of the state space • What is the heuristic function for CUBE Puzzle? • Necessary for Informed Search (cf. Blind) • *Heuristic : 예) 예전에 경험을 토대로, 누가 그러던데.... 일단 한번 시도해 볼까? • 탐색공간에 관한 정보를 활용하여 탐색공간을 줄이거나, • 정확한(최선의) 답은 아닐지라도 사용 가능한근사치를 빨리 찾을 수 있도록 하는 유용한 정보 • 모호성이 큰 경우, 모든 경우를 찾아보기에 시간이 부족한 경우 적용할 수 있다. • 항상 ‘true’라는 보장은 없으며 최적의 ‘해’ 임을 증명하지 못하는 경우가 많으나, • ‘좋은 답’을 구하게 되는 경우가 많다. 얼마나 좋은가? 에 관한 ’평가함수’의 구현에 달려있다.

  40. Generate & Test • British Museum Algorithm • Guess a Solution & Test if it is right • DENDRAL : molecular structure analysis • plan-generate-test (constraint) • AM (Automated Mathematician) • Number Theory – generate a conjecture • Generate & Test is especially useful when combined with other strategy

  41. Best First Search • (현재까지 탐색되어온 노드들 중에서 목표 상태로 이끌 가능성이 가장 높은 노드를 선택해서 탐색을 계속하는 방식) • Moveset (candidate list) is a priority queue ordered by heuristic cost h(n) • Does not guarantee the Shortest Path • Does not always terminate even though there is a solution • Performance depends on the h function

  42. Hill Climbing • 목표상태를 언덕의 꼭대기에 비유하고, 각 노드에서 언덕 꼭대기에 가장 빨리 도달할 수 있는 다음 노드를 선택하는 방법.! • Greed Method , Iterative Improvement Algorithm • Select the Best Looking Candidate : Use heuristic function • Stop when no more better looking candidates  Assume it is the Goal! • No Backtracking : Simplicity!! • 휴리스틱: 목표까지 남아있는 거리! • DFS와 유사하지만, 유망한 자녀노드의 선택을 위해평가함수를 사용한다. • 이 값에 근거하여 최선의 노드를 택한 후에는 부모,자녀노드에 대한 참고는 더 이상 하지 않는다.

  43. Hill Climbing Issues Hill Climbing Algorithm • Low Memory Requirement • No backtracking • Moveset (next move) design is critical • Evaluation Function design is critical • If the number of move is too big • Inefficient • Too small? • Easily stuck (plateau) • Hill-climbing: Attempt to maximize Eval(X) by moving to the highest configuration in our moveset. 1. Let X := initial config 2. Let E := Eval(X) 3. Let N = moveset_size(X) 4. For ( i = 0 ; i<N ; i := i+1) Let Ei := Eval(move(X,i)) 5. If all Ei’s are ≤ E, terminate, return X Else let i* = argmaxEi 6. X := move(X, i*) 7. E := Ei* 8. Goto 3

  44. Problems of Hill Climbing • 문제점 : 목표상태로 접근하기 위한 상태를 변화시킬 수 없는 경우가 발생! • Local Maxima (지역최적화) • 인접한 근처의 모든 상태들보다는 나은(우수한, 가까운)상태. 백트래킹이 필요함 • Plateau(고원) • 인접한 상태들이 모두 같은 값을 갖는 탐색공간의 평탄한 지역. 같은 방식으로 최적방향의 결정이 불가능. • 해당 공간을 벗어나기 위한 연산자 적용이 필요.! • Ridge(산등성이) • 주위지역보다는 높지만, 하나의움직임만으로는 일정한 방향으로 탐색을 계속 수행할 수 없는 공간. (이상적인 목표 예) : Global Maxima 찾기

  45. Avoiding Problems in H.C. • Many Starting Points • Random Jump : Mutation • Genetic Algorithm • Simulated Annealing • Stochastic Method

  46. Simulated Annealing If Ei >= E then definitely accept the change. If Ei < E then accept the change with probability exp (-(E - Ei)/Ti) (called the Boltzman distribution) …where Ti is a “temperature” parameter that gradually decreases. • High temp: accept all moves (Random Walk) Low temp: Stochastic Hill-Climbing • When enough iterations have passed without improvement, terminate.

  47. Means Ends Analysis(1) • Bi-Directional Method • GPS(General Problem Solver) – Newell • Operator, Pre-condition, Result Table • Choose the operator that reduce the difference most • Recursively reduce the first and rest parts with other operators

  48. Means Ends Analysis(2) GPS(I, G, O); I:initial, G: goal, O: op table select o from O which reduce the difference GPS(I, pre-condition(o), O) print(o) GPS(result(o), G, O) end • Going to Central Park, N.Y GPS(Konkuk, C.Park, O-Table) • Operation Table op pre result ------------------------------------------------ AirPlane Inchon J.F.K AirBus버스터미널 Inchon Taxi Konkukuniv.버스터미널 Subway J.F.K C.Park

  49. A* Algorithm • Best First Search only considers h • Lowest Cost First only considers g • A* algorithm takes f (note. f(n) = g(n) + h(n)) • A* is optimal if h never overestimates the (optimistic) cost : h is admissible • See the extra slide about A* algorithm ( slide 82) f(n)= g(n) + h(n) : g(n): 초기노드에서 현재 노드n 까지의 cost h(n): 노드n에서 목표노드까지 도달하기 위한 비용의 추정치, heuristic function f(n)은 초기 상태에서 노드n을 거쳐 목표 상태에 도달하는 전체 경비의 추정치

More Related