1 / 96

DCP 1172 Introduction to Artificial Intelligence

DCP 1172 Introduction to Artificial Intelligence. Lecture notes for Chap. 4 [AIMA] Chang-Sheng Chen. Last time: Problem-Solving. Problem solving: Goal formulation Problem formulation (states, operators) Search for solution Problem formulation : Initial state Operators Goal test

kishi
Télécharger la présentation

DCP 1172 Introduction to 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. DCP 1172Introduction to Artificial Intelligence Lecture notes for Chap. 4 [AIMA] Chang-Sheng Chen

  2. Last time: Problem-Solving • Problem solving: • Goal formulation • Problem formulation (states, operators) • Search for solution • Problem formulation: • Initial state • Operators • Goal test • Path cost • Problem types: • single state: fully observable and deterministic environment • multiple state: partially observable and deterministic environment • contingency: partially observable and nondeterministic environment • exploration: unknown state-space DCP 1172, Ch.4

  3. Last time: Finding a solution Function General-Search(problem, strategy) returns a solution, or failure initialize the search tree using the initial state problem loop do if there are no candidates for expansion then return failure choose a leaf node for expansion according to strategy if the node contains a goal statethen return the corresponding solution else expand the node and add resulting nodes to the search tree end • Solution: is a sequence of operators that bring you from current state to the goal state • Basic idea:offline, systematic exploration of simulated state-space by generating successors of explored states (expanding) • Strategy: The search strategy is determined by the order in which the • nodes are expanded. DCP 1172, Ch.4

  4. A Clean Robust Algorithm Function UniformCost-Search(problem, Queuing-Fn) returns a solution, or failure open make-queue(make-node(initial-state[problem])) closed [empty] loop do if open is empty then return failure currnode  Remove-Front(open) if Goal-Test[problem] applied to State(currnode) then return currnode children  Expand(currnode, Operators[problem]) whilechildren not empty [… see next slide …] end closed  Insert(closed, currnode) open  Sort-By-PathCost(open) end DCP 1172, Ch.4

  5. A Clean Robust Algorithm [… see previous slide …] children  Expand(currnode, Operators[problem]) whilechildren not empty child  Remove-Front(children) if no node in open or closed has child’s state open  Queuing-Fn(open, child) else if there exists node in open that has child’s state if PathCost(child) < PathCost(node) open  Delete-Node(open, node) open  Queuing-Fn(open, child) else if there exists node in closed that has child’s state if PathCost(child) < PathCost(node) closed  Delete-Node(closed, node) open  Queuing-Fn(open, child) end [… see previous slide …] DCP 1172, Ch.4

  6. Last time: search strategies Uninformed: Use only information available in the problem formulation • Breadth-first • Uniform-cost • Depth-first • Depth-limited • Iterative deepening Informed: Use heuristics to guide the search • Best first • A* DCP 1172, Ch.4

  7. Evaluation of search strategies • Search algorithms are commonly evaluated according to the following four criteria: • Completeness: does it always find a solution if one exists? • Time complexity: how long does it take as a function of number of nodes? • Space complexity: how much memory does it require? • Optimality: does it guarantee the least-cost solution? • Time and space complexity are measured in terms of: • b – max branching factor of the search tree • d – depth of the least-cost solution • m – max depth of the search tree (may be infinity) DCP 1172, Ch.4

  8. Last time: uninformed search strategies Uninformed search: Use only information available in the problem formulation • Breadth-first • Uniform-cost • Depth-first • Depth-limited • Iterative deepening DCP 1172, Ch.4

  9. This time: informed search Informed search: Use heuristics to guide the search • Best first • A* • Heuristics • Hill-climbing • Simulated annealing DCP 1172, Ch.4

  10. Best-first search • Idea: use an evaluation function for each node; estimate of “desirability” • expand most desirable unexpanded node. • Implementation: QueueingFn = insert successors in decreasing order of desirability • Special cases: greedy search A* search DCP 1172, Ch.4

  11. Romania with step costs in km 374 253 329 DCP 1172, Ch.4

  12. Greedy search • Estimation function: h(n) = estimate of cost from node n to goal (heuristic) • For example: hSLD(n) = straight-line distance from n to Bucharest • Greedy search expands first the node that appears to be closest to the goal, according to h(n). DCP 1172, Ch.4

  13. DCP 1172, Ch.4

  14. DCP 1172, Ch.4

  15. DCP 1172, Ch.4

  16. DCP 1172, Ch.4

  17. Properties of Greedy Search • Complete? No – can get stuck in loops e.g., Iasi > Neamt > Iasi > Neamt > … • Complete in finite space with repeated-state checking. • Time? O(b^m) but a good heuristic can give dramatic improvement • Space? O(b^m) – keeps all nodes in memory • Optimal? No. DCP 1172, Ch.4

  18. A* search • Idea: avoid expanding paths that are already expensive • evaluation function: f(n) = g(n) + h(n) with: g(n) – cost so far to reach n h(n) – estimated cost to goal from n f(n) – estimated total cost of path through n to goal • A* search uses an admissible heuristic, that is, h(n)  h*(n) where h*(n) is thetrue cost from n. • For example: hSLD(n)never overestimates actual road distance. • Theorem: A* search is optimal DCP 1172, Ch.4

  19. DCP 1172, Ch.4

  20. DCP 1172, Ch.4

  21. DCP 1172, Ch.4

  22. DCP 1172, Ch.4

  23. DCP 1172, Ch.4

  24. DCP 1172, Ch.4

  25. 1 Optimality of A* (standard proof) Suppose some suboptimal goal G2 has been generated and is in the queue. Let n be an unexpanded node on a shortest path to an optimal goal G1. DCP 1172, Ch.4

  26. Optimality of A* (more useful proof) DCP 1172, Ch.4

  27. f-contours How do the contours look like when h(n) =0? DCP 1172, Ch.4

  28. Properties of A* • Complete? Yes, unless infinitely many nodes with f  f(G) • Time? Exponential in [(relative error in h) x (length of solution)] • Space? Keeps all nodes in memory • Optimal? Yes – cannot expand fi+1 until fi is finished DCP 1172, Ch.4

  29. Proof of lemma: pathmax DCP 1172, Ch.4

  30. Admissible heuristics DCP 1172, Ch.4

  31. Relaxed Problem • Admissible heuristics can be derived from the exact solution cost of a relaxed version of the problem. • If the rules of the 8-puzzle are relaxed so that a tile can move anywhere, then h1(n) gives the shortest solution. • If the rules are relaxed so that a tile can move to any adjacent square, then h2(n) gives the shortest solution. DCP 1172, Ch.4

  32. Recall: breadth-first search, step by step DCP 1172, Ch.4

  33. 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 is empty then return failure node  Remove-Front(nodes) if Goal-Test[problem] applied to State(node) succeeds then return node nodes  Queuing-Fn(nodes, Expand(node, Operators[problem])) end Queuing-Fn(queue, elements) is a queuing function that inserts a set of elements into the queue and determines the order of node expansion. Varieties of the queuing function produce varieties of the search algorithm. DCP 1172, Ch.4

  34. Recall: breath-first search, step by step DCP 1172, Ch.4

  35. Breadth-first search Node queue: initialization # state depth path cost parent # 1 Arad 0 0 -- DCP 1172, Ch.4

  36. Breadth-first search Node queue: add successors to queue end; empty queue from top (i.e., FIFO) # state depth path cost parent # 1 Arad 0 0 -- 2 Zerind 1 1 1 3 Sibiu 1 1 1 4 Timisoara 1 1 1 DCP 1172, Ch.4

  37. Breadth-first search Node queue: add successors to queue end; empty queue from top # state depth path cost parent # 1 Arad 0 0 -- 2 Zerind 1 1 1 3 Sibiu 1 1 1 4 Timisoara 1 1 1 5 Arad 2 2 2 6 Oradea 2 2 2 (get smart: e.g., avoid repeated states like node #5) DCP 1172, Ch.4

  38. Depth-first search DCP 1172, Ch.4

  39. Depth-first search Node queue: initialization # state depth path cost parent # 1 Arad 0 0 -- DCP 1172, Ch.4

  40. Depth-first search Node queue: add successors to queue front; empty queue from top (i.e., FILO, or stack ) # state depth path cost parent 2 Zerind 1 1 1 3 Sibiu 1 1 1 4 Timisoara 1 1 1 1 Arad 0 0 -- DCP 1172, Ch.4

  41. Depth-first search Node queue: add successors to queue front; empty queue from top # state depth path cost parent # 5 Arad 2 2 2 6 Oradea 2 2 2 2 Zerind 1 1 1 3 Sibiu 1 1 1 4 Timisoara 1 1 1 1 Arad 0 0 -- DCP 1172, Ch.4

  42. Last time: search strategies Uninformed: Use only information available in the problem formulation • Breadth-first • Uniform-cost • Depth-first • Depth-limited • Iterative deepening Informed: Use heuristics to guide the search • Best first: • Greedy search -- queue first nodes that maximize heuristic “desirability” based on estimated path costfrom current node to goal; • A* search – queue first nodes that minimizesum of path cost so far and estimated path cost to goal. DCP 1172, Ch.4

  43. This time – Local Search • Iterative improvement • Hill climbing • Simulated annealing DCP 1172, Ch.4

  44. Iterative improvement • In many optimization problems, path is irrelevant; the goal state itself is the solution. • Then, state space = space of “complete” configurations. Algorithm goal: - find optimal configuration (e.g., TSP), or, - find configuration satisfying constraints (e.g., n-queens) • In such cases, can use iterative improvement algorithms: keep a single “current” state, and try to improve it. DCP 1172, Ch.4

  45. Iterative improvement example: vacuum world Simplified world: 2 locations, each may or not contain dirt, each may or not contain vacuuming agent. Goal of agent: clean up the dirt. If path does not matter, do not need to keep track of it. DCP 1172, Ch.4

  46. Iterative improvement example: n-queens • Goal: Put n chess-game queens on an n x n board, with no two queens on the same row, column, or diagonal. • Here, goal state is initially unknown but is specified by constraints that it must satisfy. DCP 1172, Ch.4

  47. Hill climbing (or gradient ascent/descent) • Iteratively maximize “value” of current state, by replacing it by successor state that has highest value, as long as possible. (健忘症) DCP 1172, Ch.4

  48. Question: What is the difference between this problem and our problem (finding global minima)? DCP 1172, Ch.4

  49. Hill climbing • Note: • minimizing a “value” function v(n) is equivalent to maximizing –v(n), thus both notions are used interchangeably. • Notion of “extremization”: find extrema (minima or maxima) of a value function. DCP 1172, Ch.4

  50. Hill climbing • Problem: depending on initial state, may get stuck in local extremum. DCP 1172, Ch.4

More Related