# هوش مصنوعی - فصل سوم

Post on 15-Apr-2017

224 views

Category:

## Engineering

Embed Size (px)

TRANSCRIPT

: : 1

1

2

2

3

3

: (goal formulation): (problem formulation): (search): ) ) . (execute): .4

4

: 5

5

: : ( ) Arad : ( ) Bucharest : : : : Arad, Sibiu, Fagaras, Bucharest

6

6

function SIMPLE-PROBLEM-SOLVING-AGENT(percept) return an actionstatic: seq , an action sequencestate, some description of the current world stategoal, a goalproblem, a problem formulation

state UPDATE-STATE(state, percept)if seq is empty thengoal FORMULATE-GOAL(state)problem FORMULATE-PROBLEM(state , goal)seq SEARCH(problem)action FIRST(seq)seq REST(seq)return action

7

7

8

9

9

10

10

: (Single State) : (Sensorless/Conformant) : (Contingency) : (Exploration/Online)11

11

: 5 ] [12

12

: {21.... 8} : ] [13

13

14

15

: {31} ( ) : 16

16

17

17

18

18

. (initial state): Arad (successor function): (goal test): (explicit) (implicit) (path cost): C(x, a, y) . (solution): . (optimal solution) : .19

19

: : 8 : :{ } : {7 8} : 20

20

: : : : { } : : 21

21

: 8 1) : : : : 8 : - 22

22

: 8 1) ( ): : : : 8 : - 100 .23

23

: 8 2) : : 8 : : : - 24

24

: : : : : : 25

25

26

26

27

27

= . . ( )28

28

function SIMPLE-PROBLEM-SOLVING-AGENT(percept) return an actionstatic: seq , an action sequencestate, some description of the current world stategoal, a goalproblem, a problem formulation

state UPDATE-STATE(state, percept)if seq is empty thengoal FORMULATE-GOAL(state)problem FORMULATE-PROBLEM(state , goal)seq SEARCH(problem)action FIRST(seq)seq REST(seq)return action

29

29

function SIMPLE-PROBLEM-SOLVING-AGENT(percept) return an actionstatic: seq , an action sequencestate, some description of the current world stategoal, a goalproblem, a problem formulation

state UPDATE-STATE(state, percept)if seq is empty thengoal FORMULATE-GOAL(state)problem FORMULATE-PROBLEM(state , goal)seq SEARCH(problem)action FIRST(seq)seq REST(seq)return action

30

30

function TREE-SEARCH(problem, strategy) return a solution or failureInitialize search tree to the initial state of the problemdo if no candidates for expansion then return failure else choose leaf node for expansion according to strategyif node contains goal state then return solutionelse expand the node and add resulting nodes to the search treeend do

31

31

: 32

32

function TREE-SEARCH(problem, strategy) return a solution or failureInitialize search tree to the initial state of the problemdo if no candidates for expansion then return failure else choose leaf node for expansion according to strategyif node contains goal state then return solutionelse expand the node and add resulting nodes to the search treeend do

33

33

34

function TREE-SEARCH(problem, strategy) return a solution or failureInitialize search tree to the initial state of the problemdo if no candidates for expansion then return failureelse choose leaf node for expansion according to strategyif node contains goal state then return solutionelse expand the node and add resulting nodes to the search treeenddo .

34

35

function TREE-SEARCH(problem, strategy) return a solution or failureInitialize search tree to the initial state of the problemdo if no candidates for expansion then return failureelse choose leaf node for expansion according to strategyif node contains goal state then return solutionelse expand the node and add resulting nodes to the search treeenddo

35

function SIMPLE-PROBLEM-SOLVING-AGENT(percept) return an actionstatic: seq , an action sequencestate, some description of the current world stategoal, a goalproblem, a problem formulation

state UPDATE-STATE(state, percept)if seq is empty thengoal FORMULATE-GOAL(state)problem FORMULATE-PROBLEM(state , goal)seq SEARCH(problem)action FIRST( seq )seq REST(seq)return action

36

36

(2)37function TREE-SEARCH(problem, fringe) return a solution or failurefringe INSERT(MAKE-NODE(INITIAL-STATE[problem]), fringe)loop doif EMPTY?(fringe) then return failurenode REMOVE-FIRST(fringe)if GOAL-TEST[node] then return SOLUTION(node)else fringe INSERT-ALL(EXPAND(node, problem), fringe)

)Remove-First ) Goal Test) Expand ) Insert_All

37

38

function TREE-SEARCH(problem, strategy) return a solution or failureInitialize search tree to the initial state of the problemdo if no candidates for expansion then return failureelse choose leaf node for expansion according to strategyif node contains goal state then return solutionelse expand the node and add resulting nodes to the search treeenddo

38

) 39

39

(state) .

(node) . . (FRINGE) . ( ) 40

40

41function EXPAND(node,problem) return a set of nodessuccessors the empty setfor each in SUCCESSOR-FN[problem](STATE[node]) dos a new NODESTATE[s] resultPARENT-NODE[s] nodeACTION[s] actionPATH-COST[s] PATH-COST[node] + STEP-COST(node, action,s)DEPTH[s] DEPTH[node]+1add s to successorsreturn successors

41

. () . : : : / : 42

42

:(b): (d): (m): ( )43

43

( ).

( ).

44

44

(Breadth-first search) (Uniform-cost search) (Depth-first search) (Depth-limited search) (Iterative deepening search) (Bidirectional search)45

45

1) (fringe) FIFO

46

46

1) FIFO

47

47

1) FIFO

48

48

1) FIFO

49

49

1) FIFO

50

50

(BF Search) : (d) . (b) .51

51

(BF Search) : .52

52

(BF Search) b . b . d . .

.

53

53

1) ) 2 4

54

(b=10) . . .55

55

: . ( ) .

56

56

2) . . : fringe BF .57

2) : . . : .

58

2) C* . . . .

59

3) . : fringe LIFO ()60

3) . : fringe LIFO ()61

3) . : fringe LIFO ()62

3) . : fringe LIFO ()63

3) . : fringe LIFO ()64

3) . : fringe LIFO ()65

3) . : fringe LIFO ()66

3) . : fringe LIFO ()67

3) . : fringe LIFO ()68

3) . : fringe LIFO ()69

3) . : fringe LIFO ()70

3) . : fringe LIFO ()71

3) . .72

3) m d . BF . .

73

4) DF (L) . . Ld . L=d .

74

4)

75

4) function DEPTH-LIMITED-SEARCH(problem,limit) return a solution or failure/cutoffreturn RECURSIVE-DLS(MAKE-NODE(INITIAL-STATE[problem]),problem,limit)

function RECURSIVE-DLS(node, problem, limit) return a solution or failure/cutoffcutoff_occurred? falseif GOAL-TEST[problem](STATE[node]) then return SOLUTION(node)else if DEPTH[node] == limit then return cutoffelse for each successor in EXPAND(node, problem) doresult RECURSIVE-DLS(successor, problem, limit)if result == cutoff then cutoff_occurred? trueelse if result failure then return resultif cutoff_occurred? then return cutoff else return failure

76

5) L BF DFfunction ITERATIVE_DEEPENING_SEARCH(problem) return a solution or failureinputs: problemfor depth 0 to doresult DEPTH-LIMITED_SEARCH(problem, depth)if result cuttoff then return result

77

5)

78Limit=0

5)

79

Limit=1

5)

80Limit=2

5)

81Limit=3

5) .

.

82

5)

level d: oncelevel d-1: 2level d-2: 3level 2: d-1level 1: dLevel 0: 1

83

5) : 10 5 .

84

6)

85

6) .

.

86

CriterionBreadth-FirstUniform-costDepth-FirstDepth-limitedIterative deepeningBidirectional searchComplete?YES*YES*NOYES, if l dYESYES*Timebd+1bC*/ebmblbdbd/2Spacebd+1bC*/ebmblbdbd/2Optimal?YES*YES*NONOYESYES

87

Recommended