1 / 52

Problem Solving and Search

Problem Solving and Search. Introduction to Artificial Intelligence CS440/ECE448 Lecture 2. This Lecture. Problem representation Problem solving through search Reading Chapter 2 Announcements My office hours: Weds. From 2 to 3pm. 2. 8. 3. 1. 2. 3. 1. 6. 4. 8. 4. 7. 5. 7.

Download Presentation

Problem Solving and Search

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. Problem Solving and Search Introduction to Artificial Intelligence CS440/ECE448 Lecture 2

  2. This Lecture • Problem representation • Problem solving through search Reading • Chapter 2 Announcements • My office hours: Weds. From 2 to 3pm.

  3. 2 8 3 1 2 3 1 6 4 8 4 7 5 7 6 5 Goal How do we goal from start configuration to the goal configuration? The 8-puzzle Start

  4. 2 8 3 1 6 4 7 5 2 8 3 2 8 3 2 8 3 1 4 1 6 4 1 6 4 7 5 7 5 6 7 5 2 8 3 2 8 3 2 3 2 8 3 6 4 1 4 1 4 1 4 8 6 1 7 5 7 5 7 5 7 5 6 6 The corresponding search tree

  5. 8-puzzle Vacuum World Cryptarithmetic 8-queens The water jug problem Missionaries and Cannibals Towers of Hanoi Traveling salesman Robot navigation Process or assembly planning VLSI Layout Toy Problems and Real Problems

  6. Problem Solving: • World State – values of all attributes of interest in the world. • State Space – the set of all possible world states. • Operators – change one state into another; cost of applying operator. • Goal – An (often partial) world state or states; in an agent, often implemented as a function of state and current percept. • Initial State – The values of attributes that are in effect at the beginning of a problem before any operators have been applied. • Note: The states and the operators define a directed (possibly weighted) graph. Solution (path) – a sequence of operators leading from the initial state to a goal state. Path cost – e.g. sum of distances, number of operators executed…

  7. In the real world • The real world is absurdly complex. • Real state space must be abstracted for problem solving. • An abstract state is equivalent to a set of real states. • Abstract operator is equivalent to a complex combination of real actions. • Robot operator: Move down hall – In practice, this might involve a complex set of sensor and motor activities. • An abstract solution is equivalent to a set of real paths that are solutions in the real world.

  8. 2 8 3 1 2 3 1 6 4 8 4 7 5 7 6 5 Start Goal Example: The 8-puzzle • States: • Operators: • Goal Test: • Path Cost: • Constraints: 3£ 3 array of integer values Move tile number i left, right, up, down = goal state (given) 1 per move Can only move in a direction if that space is empty

  9. 2 8 3 1 2 3 1 6 4 8 4 7 5 7 6 5 Start Goal Example: The 8-puzzle • States: • Operators: • Goal Test: • Path Cost: • Constraints: Integer location of tiles (ignore intermediate positions) Move blank left, right, up, down = goal state (given) 1 per move Can only move blank in a direction if it stays in puzzle

  10. 2 8 3 1 2 3 1 6 4 8 4 7 5 7 6 5 Start Goal Example: The 8-puzzle 1 2 3 4 5 6 7 8 9 Initial State = [4, 1, 3, 6, 9, 5, 7, 2] Goal State = [1, 2, 3, 6, 9, 8, 7, 4]

  11. Missionaries and cannibals • Three missionaries and three cannibals are on the left bank of a river. • There is one canoe which can hold one or two people. • Find a way to get everyone to the right bank, without ever leaving a group of missionaries in one place outnumbered by cannibals in that place.

  12. Missionaries and cannibals • States: three numbers (i,j,k) representing the number of missionaries, cannibals, and canoes on the left bank of the river. • Initial state: (3, 3, 1) • Operators: take one missionary, one cannibal, two missionaries, two cannibals, one missionary and one cannibal across the river in a given direction (I.e. ten operators). • Goal Test: reached state (0, 0, 0) • Path Cost: Number of crossings.

  13. Missionaries and Cannibals (3,3,1)

  14. Missionaries and Cannibals A missionary and cannibal cross

  15. Missionaries and Cannibals (2,2,0)

  16. Missionaries and Cannibals One missionary returns

  17. Missionaries and Cannibals (3,2,1)

  18. Missionaries and Cannibals Two cannibals cross

  19. Missionaries and Cannibals (3,0,0)

  20. Missionaries and Cannibals A cannibal returns

  21. Missionaries and Cannibals (3,1,1)

  22. Missionaries and Cannibals Two missionaries cross

  23. Missionaries and Cannibals (1,1,0)

  24. Missionaries and Cannibals A missionary and cannibal return

  25. Missionaries and Cannibals (2,2,1)

  26. Missionaries and Cannibals Two Missionaries cross

  27. Missionaries and Cannibals (0,2,0)

  28. Missionaries and Cannibals A cannibal returns

  29. Missionaries and Cannibals (0,3,1)

  30. Missionaries and Cannibals Two cannibals cross

  31. Missionaries and Cannibals (0,1,0)

  32. Missionaries and Cannibals A cannibal returns

  33. Missionaries and Cannibals (0,2,1)

  34. Missionaries and Cannibals The last two cannibals cross

  35. Missionaries and Cannibals (0,0,0)

  36. Water Jugs • You are given: • a spigot, • a 3 Gallon jug, • a 4 Gallon jug. • The goal: Get 2 gallons of water in the 4 gallon jug. • Actions: Filling jugs from spigot, dumping water in jugs onto ground, dumping 4 gallon into 3 gallon jug until 3 gallon jug is full. Dumping 3 gallon jug into 4 gallon jug until empty or until 4 gallon is full, etc, etc.

  37. States: How full are the two jugs? State Representation: 4G = ? 3G = ? Constraints: 0  4G  4 0  3G  3 Initial State: 4G = 0 3G=0 Goal State: 4G=2 Water Jugs

  38. Operators • F3: Fill the 3 Gallon jug from the tap. • F4: Fill the 4 Gallon jug from the tap. • E4: Empty the 4-Gallon jug on the ground. • P43: Pour water from 4G jug into the 3G jug until 3G jug is full. • P34: Pour water from 3G jug into the 4G jug until 4G jug is full or 3G is empty.

  39. Partial State GraphAnd Solution Path F3: Fill the 3 Gallon jug from the tap. F4: Fill the 4 Gallon jug from the tap. E4: Empty the 4-Gallon jug on the ground. P43: Pour water from 4G jug into the 3G jug until 3G jug is full. P34: Pour water from 3G jug into the 4G jug until 4G jug is full or 3G is empty.

  40. Search Methods

  41. A Toy Example: A Romanian Holiday • State space: Cities in Romania • Initial state: Town of Arad • Goal: Airport in Bucharest • Operators: Drive between cities • Solution: Sequence of cities • Path cost: number of cities, distance, time, fuel

  42. The state space

  43. Search Algorithms • Basic Idea: Off-line exploration of state space by generating successors of already-explored states (also known as expanding states). Function GENERAL-SEARCH (problem, strategy) returns a solution or failure Initialize the search tree using the initial state of problem loop do if there are no candidates for expansion, then return failure Choose a leaf node for expansion according to strategy if node contains goal state then return solution else expand node and add resulting nodes to search tree. end

  44. Zerind Sibiu Timisoara Rimnicu Vilcea Arad Oradea Fagaras Sibiu Bucharest General Search Example Arad

  45. The solution

  46. Tree search example

  47. Tree search example Expanded node Fringe

  48. Tree search example

  49. Implementation of Search Algorithms Nodes: state, parent-node,operator, depth, path cost Function GENERAL-SEARCH (problem, queing-fn) returns a solution or failure queue MAKE-QUEUE (MAKE-NODE(INITIAL-STATE[problem])) loop do ifqueueis empty, then return failure node Remove-Front(queue) if GOAL-TEST [problem] applied to STATE(node) succeeds then return node else queueQUEING-FN(queue,EXPAND(node,operators[problem])) end

  50. 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 parent, children, depth, path costg(n). • States do not have parents, children, depth, or path cost!

More Related