1 / 66

Princess Nora University Artificial Intelligence

Princess Nora University Artificial Intelligence. Chapter (3) Solving problems by searching. Out Line :. Problem-solving agents Problem types Problem formulation Example problems Basic search algorithms. Solving problems by searching.

honey
Download Presentation

Princess Nora University 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. Princess Nora UniversityArtificial Intelligence Chapter (3) Solving problems by searching

  2. Out Line : • Problem-solving agents • Problem types • Problem formulation • Example problems • Basic search algorithms

  3. Solving problems by searching • In which we look at how an agent can decide what to do by systematically considering the outcomes of various sequences of actions that it might take. • Basic Search Algorithm • Many AI problems can be posed as search • If goal found=>success; else, failure

  4. Why Search? • Not just city route search • Many AI problems can be posed as search • Planning : • Vertices : World states; Edges: Actions • Game-playing: • Vertices: Board configurations; Edges: Moves • Speech Recognition: • Vertices: Phonemes; Edges: Phone transitions

  5. Problem-solving agents

  6. Example: • On holiday in Riyadh. • Flight leaves tomorrow from Riyadh • Formulate goal : • be after two days in Paris • Formulate problem: • States : various cities • Actions : drive between cities • Find solution : • sequence of cities, e.g., Riyadh, Jeddah, London, Paris

  7. Example: Romania

  8. Problem types • Deterministic, fully observable  single-state problem • Agent knows exactly which state it will be in; solution is a sequence • Non-observable  sensorless problem (conformant problem) • Agent may have no idea where it is; solution is a sequence • Nondeterministic and/or partially observable  contingency problem • percepts provide new information about current state • Solution is tree, branch chosen based on percepts • Must use sensors during execution • Unknown state space  exploration problem

  9. Single-state problem formulation A problem is defined by 4 items: • initial statee.g., "at Arad“ • actions or successor function S(x) = set of action–state pairs e.g., S(Arad) = {<Arad  Zerind, Zerind>, … }

  10. Single-state problem formulation 3. goal test, can be explicit, e.g., x = "at Bucharest" implicit, e.g., Checkmate(x) 4. path cost (additive) sequence of actions leading from one state to another e.g., sum of distances, number of actions executed, etc. C (x, a, y) is the step cost, assumed to be ≥ 0 State space: all states reachable from the initial state by any sequence action A solution is a sequence of actions leading from the initial state to a goal state

  11. Selecting a state space • Real world is absurdly complex  state space must be abstracted for problem solving (Abstract) state = set of real states • (Abstract) action = complex combination of real actions • e.g., "Arad Zerind" represents a complex set of possible routes, detours, rest stops, etc. • For guaranteed reliability, any real state "in Arad“ must get to some real state "in Zerind" • (Abstract) solution = • set of real paths that are solutions in the real world • Each abstract action should be "easier" than the original problem

  12. Vacuum world state space graph • States ? dirt and robot location • actions? Left, Right, Suck • goal test ? no dirt at all locations • path cost? 1 per action

  13. Example: The 8-puzzle • states? locations of tiles • actions? move blank left, right, up, down • goal test? = goal state (given) • path cost? 1 per move [Note: optimal solution of n-Puzzle family is NP-hard]

  14. Tree search algorithms • Basic idea: • offline, simulated exploration of state space by generating successors of already-explored states (expanding states)

  15. Tree search example

  16. Implementation: general tree search

  17. Implementation: states vs. nodes • A state is a (representation of) a physical configuration • A node is a data structure constituting part of a search tree includes state, parent node, action, path cost g(x), depth • The Expand function creates new nodes, filling in the various fields and using the SuccessorFn of the problem to create the corresponding states.

  18. Search strategies • A search strategy is defined by picking the order of node expansion • Strategies are evaluated along the following dimensions: • completeness: does it always find a solution if one exists? • time complexity: number of nodes generated • space complexity: maximum number of nodes in memory • optimality: does it always find a least-cost solution? • Time and space complexity are measured in terms of • b: maximum branching factor of the search tree • d: depth of the least-cost solution • m: maximum depth of the state space (may be ∞)

  19. Uninformed search strategies • Uninformed search strategies use only the information available in the problem definition • Breadth-first search • Uniform-cost search • Depth-first search • Depth-limited search • Iterative deepening search

  20. Breadth-first search • Expand shallowest unexpanded node • Implementation: • fringe is a FIFO queue, i.e., new successors go at end • Application1: Given the following state space (tree search), give the sequence of visited nodes when using BFS (assume that the node O is the goal state)

  21. G F A B C E N D H I J K L M O Breadth First Search • :

  22. G F A B C E N D H I J K L M O Breadth First Search • A, • B,C,D,E, • F,G,H,I,J, • K,L, M,N, • Goal state: O

  23. G F A B C E N D H I J K L M O Breadth First Search • The returned solution is the sequence of operators in the path: A, B, G, L, O

  24. Basic Search Algorithms Uninformed Search Uniform Cost Search (UCS)

  25. Properties of breadth-first search • Complete? Yes ( if bis finite) • Time?b+b2+b3+… +bd + b(bd-1) = O(bd+1) • Space?1+b+b2+b3+… +bd + b(bd-1) = O(bd+1) O(bd+1) (keeps every node in memory) • Optimal? Yes (if cost = 1 per step) • Space is the bigger problem (more than time)

  26. Uniform Cost Search (UCS) • Expand the cheapest node. Where the cost is the path cost g(n). • Implémentations: Enqueue nodes in order of cost g(n). QUEUING-FN:- insert in order of increasing path cost. Enqueue new node at the appropriate position in the queue so that we dequeue the cheapest node.

  27. Uniform Cost Search (UCS) 5 2 [2] [5] 1 4 1 7 [6] [3] [9] [9] 4 5 Goal state [x] = g(n) path cost of node n [7] [8]

  28. 5 2 [2] [5] Uniform Cost Search (UCS)

  29. Uniform Cost Search (UCS) 5 2 [2] [5] 1 7 [3] [9]

  30. Uniform Cost Search (UCS) 5 2 [2] [5] 1 7 [3] [9] 4 5 [7] [8]

  31. 5 2 [2] [5] 1 4 1 7 [6] [3] [9] [9] 4 5 [7] [8] Uniform Cost Search (UCS)

  32. Goal state path cost g(n)=[6] 5 2 [2] [5] 1 4 1 7 [3] [9] [9] 4 5 [7] [8] Uniform Cost Search (UCS)

  33. 5 2 [2] [5] 1 4 1 7 [6] [3] [9] [9] 4 5 [7] [8] Uniform Cost Search (UCS)

  34. Uniform Cost Search (UCS) Complete? Yes Time? O(bd) Space? : O(bd), note that every node in the fringe keep in the queue. Optimal? Yes

  35. Depth-first search • Expand deepest unexpanded node • Implementation: • fringe = LIFO queue, i.e., put successors at front

  36. G F A B C E N D H I J K L M O Depth First Search (DFS) Given the following state space (tree search), give the sequence of visited nodes when using DFS (assume that the nodeO is the goal state):

  37. A B C E D Depth First Search • A,

  38. A B C E D F G Depth First Search • A,B,

  39. A B C E D F G Depth First Search • A,B,F,

  40. A B C E D F G K L Depth First Search • A,B,F, • G,

  41. A B C E D F G K L Depth First Search • A,B,F, • G,K,

  42. A B C E D F G K L O Depth First Search • A,B,F, • G,K, • L,

  43. A B C E D F G K L O Depth First Search • A,B,F, • G,K, • L, O: Goal State

  44. A B C E D F G K L O Depth First Search The returned solution is the sequence of operators in the path: A, B, G, L, O

  45. Properties of depth-first search • Complete? No: fails in infinite-depth spaces, spaces with loops • Modify to avoid repeated states along path  complete in finite spaces • Time?O(bm): terrible if m is much larger than d • but if solutions are dense, may be much faster than breadth-first • Space?O(bm), i.e., linear space! • Optimal? No

  46. Depth-limited search = depth-first search with depth limit l, i.e., nodes at depth l have no successors

  47. H L K J I G F M E C B A N D O Depth-Limited Search (DLS) Given the following state space (tree search), give the sequence of visited nodes when using DLS (Limit = 2): Limit = 0 Limit = 1 Limit = 2

  48. A B C E D Depth-Limited Search (DLS) • A, Limit = 2

  49. A B C E D F G Depth-Limited Search (DLS) • A,B, Limit = 2

  50. A B C E D F G Limit = 2 Depth-Limited Search (DLS) • A,B,F,

More Related