Problem Solving as Search Foundations of Artificial Intelligence
Problem Solving as Search Foundations of Artificial Intelligence
Search and Knowledge Representation i Goal-based and utility-based agents require representation of: 4 states within the environment 4 actions and effects (effect of an action is transition from the current state to another state) 4 goals 4 utilities i Problems can often be formulated as a search problem 4 to satisfy a goal, agent must find a sequence of actions (a path in the state-space graph) from the starting state to a goal state. i To do this efficiently, agents must have the ability to reason with their knowledge about the world and the problem domain 4 which path to follow (which action to choose from) next 4 how to determine if a goal state is reached OR how decide if a satisfactory state has been reached. Foundations of Artificial Intelligence 2
Introduction to Search is one of the most powerful approaches to problem solving in AI i Search is a universal problem solving mechanism that 4 Systematically explores the alternatives 4 Finds the sequence of steps towards a solution i Problem Space Hypothesis (Allen Newell, SOAR: An Architecture for General Intelligence. ) 4 All goal-oriented symbolic activities occur in a problem space 4 Search in a problem space is claimed to be a completely general model of intelligence Foundations of Artificial Intelligence 3
Problem-Solving Agents function Simple-Problem-Solving-Agent(percept) returns action inputs: p, a percept static: s, an action sequence, initially empty state, a description of current world state g, a goal, initially null problem, a problem formulation state ¬ Update-State(state, p) if s = empty then g ¬ Formulate-Goal(state) problem ¬ Formulate-Problem(state, g) s ¬ Search(problem) endif action ¬ first(s) s ¬ remainder(s) return action i Assumptions on Environment 4 Static: formulating and solving the problem does not take any changes into account 4 Discrete: enumerating all alternative courses of action 4 Deterministic: actions depend only on previous actions 4 Observable: initial state is completely known i The agent follows a simple “formulate, search, execute” design Foundations of Artificial Intelligence 4
Stating a Problem as a Search Problem S 1 3 Foundations of Artificial Intelligence 2 § State space S § Successor function: x in S SUCCESSORS(x) § Cost of a move § Initial state s 0 § Goal test: for state x in S GOAL? (x) =T or F 5
Example (Romania) i Initial Situation 4 On Holiday in Romania; currently in Arad 4 Flight leaves tomorrow from Bucharest i Formulate Goal 4 be in Bucharest i Formulate Problem 4 states: various cities 4 operators: drive between cities i Find Solution 4 sequence of cities 4 must start at starting state and end in the goal state Foundations of Artificial Intelligence 6
Example (Romania) Foundations of Artificial Intelligence 7
Example: Vacuum World i Vacuum World 4 Let the world be consist two rooms 4 Each room may contain dirt 4 The agent may be in either room i initial: both rooms dirty i goal: both rooms clean i problem: 4 states: each state has two rooms which may contain dirt (8 possible) 4 actions: go from room to room; vacuum the dirt i Solution: 4 sequence of actions leading to clean rooms Foundations of Artificial Intelligence 8
Problem Types i Deterministic, fully-observable ==> single-state problem 4 agent has enough info. to know exactly which state it is in 4 outcome of actions are known i Deterministic, partially-observable ==> multiple-state problem 4 “sensorless problem”: Limited/no access to the world state; agent may have no idea which state it is in 4 require agent to reason about sets of states it can reach i Nondeterministic, partially-observable ==> contingency problem 4 must use sensors during execution; percepts provide new information about current state 4 no fixed action that guarantees a solution (must compute the whole tree) 4 often interleave search, execution i Unknown State Space ==> exploration problem (“online”) 4 only hope is to use learning (reinforcement learning) to determine potential results of actions, and information about states Foundations of Artificial Intelligence 9
Example: Vacuum World i Single-State 4 start in #5. Solutions? i Multiple-State 4 start in {1, 2, 3, 4, 5, 6, 7, 8} 4 e. g. , Right goes to {2, 4, 6, 8}. Solutions? i Contingency 4 Start in #5 4 e. g. , Suck can dirty a clean carpet 4 Local sensing: dirt, location only. Solutions? Foundations of Artificial Intelligence Goal states 10
Single-state problem formulation i A problem is defined by four items: i initial state 4 e. g. , ``at Arad'' i operators (or successor function S(x)) 4 e. g. , Arad ==> Zerind Arad ==> Sibiu i goal test, can be 4 explicit, e. g. , x = ``at Bucharest'' 4 implicit, e. g. , No. Dirt(x) i path cost (additive) 4 e. g. , sum of distances, number of operators executed, etc. i A solution is a sequence of operators leading from the initial state to a goal state Foundations of Artificial Intelligence 11
Selecting a state space i Real world is absurdly complex 4 state space must be abstracted for problem solving i (Abstract) state = set of real states i (Abstract) operator = complex combination of real actions 4 e. g. , “Arad ==> Zerind” represents a complex set of possible routes, detours, rest stops, etc. i For guaranteed realizability, any real state “in Arad” must get to some real state “in Zerind” i (Abstract) solution = set of real paths that are solutions in the real world i Each abstract action should be “easier” than the original problem! Foundations of Artificial Intelligence 12
Example: Vacuum World i States? integer dirt and robot locations (ignore dirt amounts) i Operators? Left, Right, Suck i Goal Test? no dirt i Path Cost? one per move What if the agent had no sensors: the multiple-state problem Goal states Foundations of Artificial Intelligence 13
Example: The 8 -Puzzle i i States? Operators? Goal Test? Path Cost? integer location of tiles move blank left, right, up, down = goal state (given) One per move i Note: optimal solution of n-Puzzle problem is NP-hard Foundations of Artificial Intelligence 14
8 -Puzzle: Successor Function 8 2 3 4 5 1 6 8 2 7 8 6 3 8 2 3 4 7 3 4 5 1 6 5 1 Foundations of Artificial Intelligence 7 5 2 7 4 1 6 15
State-Space Graph i The state-space graph is a representation of all possible legal configurations of the problem resulting from applications of legal operators 4 each node in the graph is a representation a possible legal state 4 each directed edge is a representation of a possible legal move applied to a state (resulting in a new state of the problem) i States: 4 representation of states should provide all information necessary to describe relevant features of a problem state i Operators: 4 Operators may be simple functions representing legal actions; 4 Operators may be rules specifying an action given that a condition (set of constraints) on the current state is satisfied 4 In the latter case, the rules are sometimes referred to as “production rules” and the system is referred to as a production system h This is the case with simple reflex agents. Foundations of Artificial Intelligence 16
Vacuum World State-Space Graph i State-space graph does not include initial or goal states i Search Problem: Given specific initial and goal states, find a path in the graph from an initial to a goal state 4 An instance of a search problem can be represented as a “search tree” whose root note is the initial state Foundations of Artificial Intelligence 17
Foundations of Artificial Intelligence 18
Solution to the Search Problem i A solution is a path connecting the initial to a goal node (any one) i The cost of a path is the sum of the edge costs along this path i An optimal solution is a solution path of minimum cost i There might be no solution ! Foundations of Artificial Intelligence 19
Foundations of Artificial Intelligence 20
State Spaces Can be Very Large i 8 -puzzle 9! = 362, 880 states i 15 -puzzle 16! ~ 1. 3 x 1012 states i 24 -puzzle 25! ~ 1025 states Foundations of Artificial Intelligence 21
Searching the State Space i Often it is not feasible to build a complete representation of the state graph i A problem solver must construct a solution by exploring a small portion of the graph i For a specific search problem (with a given initial and goal state) we can view the relevant portion as a search tree Foundations of Artificial Intelligence 22
Searching the State Space Foundations of Artificial Intelligence 23
Searching the State Space Search tree Foundations of Artificial Intelligence 24
Searching the State Space Search tree Foundations of Artificial Intelligence 25
Searching the State Space Search tree Foundations of Artificial Intelligence 26
Searching the State Space Search tree Foundations of Artificial Intelligence 27
Searching the State Space Search tree Foundations of Artificial Intelligence 28
Portion of Search Space for an Instance of the 8 -Puzzle Problem . . . Foundations of Artificial Intelligence 29
Simple Problem-Solving Agent Algorithm is 0 sense/read initial state i. GOAL? select/read goal test i. Succ select/read successor function isolution search(s 0, GOAL? , Succ) iperform(solution) Foundations of Artificial Intelligence 30
Example: Blocks World Problem i World consists of blocks A, B, C, and the Floor 4 Can move a block that is “clear” on top of another clear block or onto the Floor i State representation: using the predicate “on(x, y)” 4 on(x, y) means the block x is on top of block y 4 on(x, Floor) means block x is on the Floor 4 on(_, x) means block x has nothing on it (it is “clear”) i Can specify operators as a set of production rules: 4 1. on(_, x) on (x, Floor) 4 2. on(_, x) and on(_, y) on(x, y) i Initial state: some initial configuration 4 E. g. , on(A, Floor) and on(C, A) and on(B, Floor) and on(_, B) and on(_, A) i Goal state: some specified configuration 4 E. g. , on(B, C) and on(A, B) Foundations of Artificial Intelligence 31
Blocks World: State-Space Graph 1 A B C on(_, x) on (x, Floor) 2 B A C 2 1 on(_, x) and on(_, y) on(x, y) A C B 1 2 2 A C B 1 C A B 2 Foundations of Artificial Intelligence 1 B C A 2 2 C A B 2 2 1 2 A C B B A C 2 2 C A B 2 1 B A C 2 C B A 2 32
Blocks World: A Search Problem A C B Notes: 1. Repeated states have been eliminated in diagram. 2. The highlighted path represents (in this case) the only solution for this instance of the problem. 3. The solution is a sequence of legal actions: move(A, Floor) move(B, C) move(A, B). Foundations of Artificial Intelligence A B C Search tree for the problem A C B B A C B C A B B A C C A B A C B A B C A C B A 33
Some Other Problems Foundations of Artificial Intelligence 34
8 -Queens Problem Place 8 queens in a chessboard so that no two queens are in the same row, column, or diagonal. A solution Foundations of Artificial Intelligence Not a solution 35
Formulation #1 § States: all arrangements of 0, 1, 2, . . . , or 8 queens on the board § Initial state: 0 queen on the board § Successor function: each of the successors is obtained by adding one queen in an empty square § Arc cost: irrelevant § Goal test: 8 queens are on the board, with no two of them attacking each other 64 x 63 x. . . x 53 ~ 3 x 1014 states Foundations of Artificial Intelligence 36
Formulation #2 2, 057 states Foundations of Artificial Intelligence § States: all arrangements of k = 0, 1, 2, . . . , or 8 queens in the k leftmost columns with no two queens attacking each other § Initial state: 0 queen on the board § Successor function: each successor is obtained by adding one queen in any square that is not attacked by any queen already in the board, in the leftmost empty column § Arc cost: irrelevant § Goal test: 8 queens are on the board 37
Path Planning What is the state space? Foundations of Artificial Intelligence 38
Formulation #1 Cost of one horizontal/vertical step = 1 Cost of one diagonal step = 2 Foundations of Artificial Intelligence 39
Optimal Solution This path is the shortest in the discretized state space, but not in the original continuous space Foundations of Artificial Intelligence 40
Formulation #2 Visibility graph Cost of one step: length of segment Foundations of Artificial Intelligence 41
Formulation #2 Visibility graph Cost of one step: length of segment Foundations of Artificial Intelligence 42
Solution Path The shortest path in this state space is also the shortest in the original continuous space Foundations of Artificial Intelligence 43
Search Strategies i. Uninformed (blind, exhaustive) strategies use only the information available in the problem definition 4 Breadth-first search 4 Depth-first search 4 Uniform-cost search i. Heuristic strategies use “rules of thumb” based on the knowledge of domain to pick between alternatives at each step Graph Searching Applet: http: //www. cs. ubc. ca/labs/lci/CIspace/Version 4/search/index. html Foundations of Artificial Intelligence 44
Implementation of Search Algorithms function General-Search(problem, Queuing-Fn) returns a solution, or failure nodes ¬ Make-Queue(Make-Node(Initial-State[problem])) loop do if nodes = empty then return failure nodes ¬ Remove-Front(nodes) if Goal-Test[problem] applied to State[node] succeeds then return node else nodes ¬ Queuing-Fn(nodes, Expand(node, Operators[problem])) return i A state is a representation of a physical configuration i A node is a data structure constituting part of a search tree 4 includes parent, children, depth, or path cost i States don’t have parents, children, depth, or path cost i The Expand function creates new nodes, filling in various fields and using Operators (or Sucessor. Fn) of the problem to create the corresponding states Foundations of Artificial Intelligence 45
Search Strategies i A strategy is defined by picking the order of node expansion 4 i. e. , how expanded nodes are inserted into the queue i Strategies are evaluated along the following dimensions 4 completeness - does it always find a solution if one exists 4 time complexity - number of nodes generated / expanded 4 space complexity - maximum number of nodes in memory 4 optimality - does it always find a least-cost solution i Time and space complexity are measured in terms of: 4 4 4 b - maximum branching factor of the search tree d - depth of the least-cost solution m - maximum depth of the state space (may be ¥) Foundations of Artificial Intelligence 46
Recall: Searching the State Space Search tree Note that some states are visited multiple times Foundations of Artificial Intelligence 47
Search Nodes States 8 2 3 4 7 5 1 6 8 2 7 3 4 5 1 6 8 2 8 4 2 7 3 4 7 3 5 1 6 5 Foundations of Artificial Intelligence 1 6 8 2 3 4 7 5 1 6 48
Search Nodes States 8 2 3 4 7 5 1 6 8 2 7 3 4 5 1 If states are allowed to be revisited, the search tree may be infinite even when the state space is finite 6 8 2 8 4 2 7 3 4 7 3 5 1 6 5 Foundations of Artificial Intelligence 1 6 8 2 3 4 7 5 1 6 49
Data Structure of a Node 8 2 3 4 7 5 1 6 STATE PARENT-NODE BOOKKEEPING CHILDREN . . . Action Right Depth 5 Path-Cost 5 Expanded yes Depth of a node N = length of path from root to N (Depth of the root = 0) Foundations of Artificial Intelligence 50
Node expansion i. The expansion of a node N of the search tree consists of: 4 Evaluating the successor function on STATE(N) 4 Generating a child of N for each state returned by the function Foundations of Artificial Intelligence 51
Basic Search Procedure i 1. Start with the start node (root of the search tree) and place in on the queue i 2. Remove the front node in the queue and 4 If the node is a goal node, then we are done; stop. 4 Otherwise expand the node generate its children using the successor function (other states that can be reached with one move) i 3. Place the children on the queue according to the search strategy i 4. Go back to step 2. Foundations of Artificial Intelligence 52
Search Strategies i. Search strategies differ based on the order in which new successor nodes are added to the queue i. Breadth-first add nodes to the end of the queue i. Depth-first add nodes to the front i. Uniform cost sort the nodes on the queue based on the cost of reaching the node from start node Foundations of Artificial Intelligence 53
Breadth-First Search 1 2 5 4 3 6 11 7 12 8 13 9 10 14 goal Foundations of Artificial Intelligence 54
Example (Romania) Foundations of Artificial Intelligence 55
Breadth-First Search i Always expand the shallowest unexpanded node 4 Queuing. FN = insert successor at the end of the queue Arad Zerind Foundations of Artificial Intelligence Sibiu Timisoara 56
Breadth-First Search Arad Zerind Arad Foundations of Artificial Intelligence Sibiu Timisoara Oradea 57
Breadth-First Search Arad Zerind Arad Oradea Foundations of Artificial Intelligence Sibiu Arad Timisoara Oradea Fagaras Rimnicu Vilcea 58
Breadth-First Search Arad Sibiu Zerind Arad Oradea Foundations of Artificial Intelligence Oradea Timisoara Fagaras Rimnicu Vilcea Arad Lugoi 59
Depth d = 4 Branching factor b = 2 goal No. of nodes examined through level 3 (d-1) = 1 + 22 + 23 = 1 + 2 + 4 + 8 = 15 Avg. no. of nodes examined at level 4 = (1 + 24) / 2 Foundations of Artificial Intelligence (min = 1, max = 24) 60
Breadth-First Search i Space complexity: 4 Full tree at depth d uses bd memory nodes 4 If you know there is a goal at depth d, you are done; otherwise have to store the nodes at depth d+1 as you generate them; so might need bd+1 memory nodes i Nodes examined: (assume tree has depth d with a single goal node at that depth) Number of internal nodes before reaching goal at depth d Average number of nodes examined at the fringe ( at depth d) 4 for large b, this is O(bd) (the fringe dominates) Foundations of Artificial Intelligence 61
Properties of Breadth-First Search i Complete? 4 Yes, if b is finite i Time Complexity? 4 1 + b 2 + b 3 +. . . + bd = O(bd) i Space Complexity? 4 O(bd) (keeps every node in memory) i Optimal? 4 Yes (if cost = 1 per step); but, not optimal in general Note: biggest problem in BFS is the space complexity Foundations of Artificial Intelligence 62
Breadth-First Search: Time and Space Complexity i Assume 4 branching factor b=10; 4 1000 nodes/second; 4 100 bytes/node Foundations of Artificial Intelligence 63
Depth-First Search 1 2 3 13 8 10 4 12 9 7 11 14 15 goal 5 6 Foundations of Artificial Intelligence 64
Depth-First Search i Always expand the deepestest unexpanded node 4 Queuing. FN = insert successor at the front of the queue Arad Zerind Arad Foundations of Artificial Intelligence Sibiu Timisoara Oradea 65
Depth-First Search Arad Zerind Sibiu Foundations of Artificial Intelligence Sibiu Oradea Timisoara Note that DFS can perform infinite cyclic excursions. Need a finite, non-cyclic search space, or repeated state-checking. Timisoara 66
Depth d = 4 Branching factor b = 2 Best case in Depth-First Search: Goal node is on the far left. goal Highlighted nodes are those that have to be kept in memory. worst case In best case, we examine d + 1 = 5 nodes. In worst case, need all the nodes = 1 + 2 + 4 + 8 + 16 (bd) = 31 Foundations of Artificial Intelligence 67
Depth-First Search i Space complexity: (assume tree has depth d with a single goal node at that depth) 4 The most memory is needed at the first point we reach depth d 4 Need to store b-1 nodes at each depth (siblings of the node already expanded) with one additional node at depth d (since it hasn’t been expanded yet) 4 Total space = d(b-1) + 1 (the 1 additional node is for the goal at depth d) i Nodes examined: (assume tree has depth d with a single goal node at that depth) 4 Best case (goal is at far left) ==> d +1 nodes 4 Worst case ==> 4 Average case ==> 4 for large b, this O(bd) (the fringe dominates) Foundations of Artificial Intelligence 68
Properties of Depth-First Search i Complete? 4 No; fails in infinite-depth spaces, spaces with loops 4 need to modify the algorithm to avoid repeated states along paths i Time Complexity? 4 O(bm): terrible if m is much larger than d 4 but, if solutions are dense, may be much faster that BFS i Space Complexity? 4 O(bm) (i. e. , linear space) i Optimal? 4 No Foundations of Artificial Intelligence 69
Iterative Deepening i Depth-Limited Search 4 = depth-first search with depth limit l 4 Nodes at depth l have no successors function Iterative-Deepening-Search(problem, Queuing-Fn) returns a solution sequence inputs: problem for depth ¬ 0 to ¥ do result ¬ Depth-Limited-Search(problem, depth) if result ¹ cutoff then return result end Foundations of Artificial Intelligence 70
Iterative Deepening Arad Zerind Foundations of Artificial Intelligence Sibiu l=0 l=1 steps 1 and 2 Timisoara 71
Iterative Deepening Arad Zerind Arad Oradea Timisoara Sibiu l=2 steps 1, 2, and 3 Foundations of Artificial Intelligence 72
Iterative Deepening l=2 step 5 Arad Sibiu Zerind Arad Oradea Foundations of Artificial Intelligence Arad Oradea Timisoara Fagaras Rimnicu Vilcea Arad Lugoi 73
Iterative Deepening i Space complexity: 4 if the shallowest solution is at depth g, then the depth-first search to this depth will succeed (so Iterative Deepening will always return the shallowest solution). Since each of the individual searches are performed depth-first, the amount of memory required is same as depth-first search. i Nodes examined: (assume tree has depth d with a single goal node at that depth) No. of nodes examined in the final (successful) iteration (same as DFS): (1) For each of depths j = 1, 2, …, d-1, must examine the entire tree: Total nodes examined in failing searches: Foundations of Artificial Intelligence (2) 74
Properties of Iterative Deepening i Complete? 4 Yes i Time Complexity? 4 Adding (1) and (2) from before gives: = O(bd) i Space Complexity? 4 O(bd) i Optimal? 4 Yes (if cost = 1 per step) 4 Can be modified to explore uniform-cost search Foundations of Artificial Intelligence 75
Uniform-Cost Search i Always expand the least-cost unexpanded node 4 Queue = insert in order of increasing path cost Arad 75 Zerind 140 Sibiu 118 Timisoara <== Zerind, Timisoara, Sibiu <== Foundations of Artificial Intelligence 76
Uniform-Cost Search Arad 75 Zerind 75+75 Arad 140 Sibiu 118 Timisoara 71+75 Oradea <== Timisoara, Sibiu, Oradea, Arad <== Foundations of Artificial Intelligence 77
Uniform-Cost Search Arad 75 Zerind 75+75 Arad 140 118 Sibiu Timisoara 71+75 118+118 111+118 Oradea Arad Lugoi <== Sibiu, Oradea, Arad, Lugoi, Arad <== Foundations of Artificial Intelligence 78
Uniform-Cost Search Arad 75 Zerind 75+75 Arad 140 118 Sibiu Timisoara 71+75 118+118 111+118 Oradea Arad Lugoi <== Sibiu, Oradea, Arad, Lugoi, Arad <== Foundations of Artificial Intelligence 79
Uniform Cost Search i. For the rest of the example, let us assume repeated state checking: 4 If a newly generated state was previously expanded, then discard the new state 4 If multiple (unexpanded) instances of a state end up on the queue, we only keep the instance that has the least path cost from the start node and eliminate the other instances. Foundations of Artificial Intelligence 80
Uniform-Cost Search Arad 75 Zerind 140 Sibiu 71+75 118 Timisoara 111+118 Oradea Lugoi <== Sibiu, Oradea, Lugoi <== Foundations of Artificial Intelligence 81
Uniform-Cost Search Arad 75 140 Zerind 146 Oradea 118 Sibiu 239 Timisoara 220 229 Fagaras Rimnicu Lugoi <== Oradea, Rimnicu, Lugoi, Fagaras <== Foundations of Artificial Intelligence 82
Uniform-Cost Search Note: Oradea only leads to repeated states. Arad 75 140 Zerind 146 Oradea 118 Sibiu 239 Timisoara 220 229 Fagaras Rimnicu Lugoi <== Rimnicu, Lugoi, Fagaras <== Foundations of Artificial Intelligence 83
Uniform-Cost Search Foundations of Artificial Intelligence 84
Uniform-Cost Search Arad 75 140 Zerind 146 Oradea 118 Sibiu Timisoara 239 220 229 Rimnicu Fagaras 367 Craiova Lugoi 317 Pitesti <== Lugoi, Fagaras, Pitesti, Craiova <== Foundations of Artificial Intelligence 85
Uniform-Cost Search Arad 75 140 Zerind 146 Oradea 118 Sibiu Timisoara 239 220 229 Rimnicu Fagaras 367 Craiova Lugoi 317 299 Pitesti Mehadia <== Fagaras, Mehadia, Pitesti, Craiova <== Foundations of Artificial Intelligence 86
Uniform-Cost Search Arad 140 75 118 Sibiu Zerind 239 146 220 367 450 229 Rimnicu Fagaras Oradea Timisoara Lugoi 317 299 Bucharest Craiova Pitesti Mehadia <== Mehadia, Pitesti, Craiova, Bucharest <== Foundations of Artificial Intelligence 87
Uniform-Cost Search Arad 118 140 75 Sibiu Zerind 239 146 Oradea Timisoara 229 220 Rimnicu Fagaras Lugoi 367 450 Bucharest Craiova 317 Pitesti Mehadia Dobreta 299 374 <== Pitesti, Craiova, Dobreta, Bucharest <== Foundations of Artificial Intelligence 88
Uniform-Cost Search Arad 118 140 75 Sibiu Zerind 239 146 Oradea Timisoara 229 220 Rimnicu Fagaras Lugoi 367 450 Bucharest 317 Pitesti Craiova 418 Bucharest Mehadia 299 455 Craiova Dobreta 374 <== Craiova, Dobreta, Bucharest <== Foundations of Artificial Intelligence 89
Uniform-Cost Search Arad 118 140 75 Sibiu Zerind 239 146 Oradea Timisoara 229 220 Rimnicu Fagaras Lugoi 367 450 Bucharest 317 Pitesti Craiova 418 Bucharest Foundations of Artificial Intelligence <== Craiova, Dobreta, Bucharest <== Mehadia 299 455 Craiova Dobreta 374 90
Uniform-Cost Search Arad 118 140 75 Sibiu Zerind Timisoara 239 146 Oradea 229 220 Rimnicu Fagaras Lugoi 367 Craiova 317 Pitesti Mehadia 418 Bucharest Dobreta 299 374 Goes to repeated states with higher path costs than previous visits to those states Foundations of Artificial Intelligence <== Craiova, Dobreta, Bucharest <== 91
Uniform-Cost Search Foundations of Artificial Intelligence 92
Uniform-Cost Search Arad Sibiu Zerind 146 Oradea 118 140 75 Timisoara 239 220 Rimnicu Fagaras Lugoi 367 Craiova 317 Pitesti Mehadia 418 Bucharest Dobreta 299 374 <== Bucharest <== Foundations of Artificial Intelligence 93
Uniform-Cost Search Arad Sibiu Zerind 146 Oradea 118 140 75 239 Timisoara 229 220 Rimnicu Fagaras Lugoi 367 317 Pitesti Craiova Mehadia 418 Bucharest Dobreta 299 374 <== Urziceni, Giurgiu <== 519 Pitesti Foundations of Artificial Intelligence Fagaras 629 508 Giurgiu 503 Urziceni 94
Uniform-Cost Search Arad Sibiu Zerind 146 Oradea 118 140 75 239 Timisoara 229 220 Rimnicu Fagaras Lugoi 367 Craiova 317 Pitesti Mehadia 418 Bucharest Dobreta 299 374 Solution Path: Arad Sibiu Rimnicu Pitesti Bucharest Total cost: 418 Compare this to: Arad Sibiu Fagaras Bucharest with total cost of 450 Foundations of Artificial Intelligence 95
Properties of Uniform-Cost Search i Complete? 4 Yes, if b is finite (similar to Breadth-First search) i Time Complexity? 4 Number of nodes with g(n) £ cost of optimal solution i Space Complexity? 4 Number of nodes with g(n) £ cost of optimal solution i Optimal? 4 Yes, if the path cost never decreases along any path 4 i. e. , if g(Successor(n)) ³ g(n), for all nodes n i What happens if we had operators with negative costs? Foundations of Artificial Intelligence 96
- Slides: 96