solving problems by searching
DESCRIPTION
Solving Problems by Searching. CPS 4801-01. Outline. Problem-solving agents Example problems Basic search algorithms. Problem-Solving Agents. Intelligent agents are supposed to maximize their performance measure. If the agent can adopt a goal and aim at satisfying it. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/1.jpg)
Solving Problems by Searching
CPS 4801-01
![Page 2: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/2.jpg)
Outline• Problem-solving agents• Example problems• Basic search algorithms
![Page 3: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/3.jpg)
Problem-Solving Agents
• Intelligent agents are supposed to maximize their performance measure.o If the agent can adopt a goal and aim at
satisfying it.
![Page 4: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/4.jpg)
Problem-Solving Agents
• “formulate, search , execute” design
![Page 5: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/5.jpg)
Problem-Solving Agents
• Goal formulation, based on the current situation and the agent’s performance measure, is the first step in problem solving.
• Problem formulation is the process of deciding what actions and states to consider, given a goal.
• The process of looking for a sequence of actions that reaches the goal is search.
• Execution phase: once a solution is found, the actions it recommended can be carried out.
![Page 6: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/6.jpg)
Example: Romania• On holiday in Romania; currently in Arad.• Flight leaves tomorrow from Bucharest• Formulate goal: be in Bucharest• Formulate problem:
o states: various citieso action: drive between cities
• Find solution:o sequence of cities: e.g., Arad, Sibiu, Fagaras,
Bucharest
![Page 7: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/7.jpg)
Example: Romania
![Page 8: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/8.jpg)
Problem Formulation• A problem is defined by five components.• Initial state e.g., “at Arad”• Actions (s) {a1, a2, a3, … }
o e.g., {Go(Sibiu), Go(Timisoara), Go(Zerind)}
• Transition model: Result (s,a) s’o e.g., Result(In(Arad), Go(Timisoara)) =
In(Timisoara)
• Goal test (s) T/F e.g., “at Bucharest”• Path cost (sss) n (additive)
o sum of cost of individual steps, e.g., number of miles traveled, number of minutes to get to destination
![Page 9: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/9.jpg)
Example Problems• Toy problems: to illustrate or exercise
various problem-solving methods, given a concise, exact description.
• Real-world problems: tend not to have a single agreed-upon description.
![Page 10: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/10.jpg)
Example: Vacuum World
• states?• initial state?• actions?• transition model?• goal test?• path cost?
![Page 11: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/11.jpg)
• states? location and dirt, 2*22=8, n*2n
• initial state? any state• actions? Left, Right, Suck (Up, Down)• transition model? • goal test? no dirt at all locations• path cost? 1 per action (0 for NoOp)
![Page 12: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/12.jpg)
Example: The 8-Puzzle
• states?• initial state?• actions?• transition model?• goal test?• path cost?
![Page 13: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/13.jpg)
• states? A state description specifies the location of the eight tiles and the blank one.
• initial state? any state• actions? movement of the blank space: Left,
Right, Up, Down• transition model? (s,a)s’• goal test? goal state (given)• path cost? 1 per move
![Page 14: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/14.jpg)
The 8-Queens Problem
• states?• initial state?• actions?• transition model?• goal test?• path cost?
![Page 15: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/15.jpg)
• states? Any arrangement of 0 to 8 queens • initial state? No queens on the board• actions? Add a queen to any empty square• transition model? Return the board with a
queen added• goal test? 8 queens, none attacked• path cost? no interest
Incremental formulation
![Page 16: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/16.jpg)
The 8-Queens Problem• 64*63*…*57 ~= 1.8*1014
• A better formation:• states: All possible arrangement of n
queens, one per column in the leftmost n columns, with no queen attacking another. (0<=n<=8)
• actions: Add a queen to any square in the leftmost empty column such that it is not attacked by any other queen.
![Page 17: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/17.jpg)
• Donald Knuth (1964): starting with the number 4, a sequence of factorial, square root, and floor operation will reach any desired positive integer.
• states? Positive numbers• initial state? 4• actions? Apply factorial, square root, or floor
operation• transition model? definition of the
operations• goal test? desired positive integer• path cost? number of operations
![Page 18: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/18.jpg)
Real-World Problems• Route-finding problem• Touring problems
o e.g., visit every city in the Romania example at least once, starting and ending in Bucharest.
• Traveling salesman problem (TSP)o each city must be visited exactly onceo shortest tour
![Page 19: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/19.jpg)
Tree Search Algorithms
• search tree: initial state as the root, the branches as actions and the nodes as states.
• We expand the current state and generate a new set of states.
• parent node, child nodes• leaf node: a node with no children (frontier)• search strategy: how to choose which state
to expand next• repeated state, redundant paths
![Page 20: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/20.jpg)
Tree Search Example• The initial state
![Page 21: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/21.jpg)
Tree Search Example• After expanding Arad
![Page 22: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/22.jpg)
Tree Search Example• After expanding Sibiu
![Page 23: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/23.jpg)
Graph Search Algorithm
• explored set: remembers every expanded node
• Newly generated nodes that are in the explored set are discarded.
• The frontier separates the explored region and the unexplored region.
![Page 24: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/24.jpg)
Data Structure
• For each node n, • n.State• n.Parent• n.Action: parent generated the node• n.Path-Cost
![Page 25: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/25.jpg)
Data Structure• Frontier: queue
o Empty? (queue) : T/Fo Pop (queue)o Insert (queue)o FIFO, LIFO, priority
• Explored set: hash table
![Page 26: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/26.jpg)
Search Strategies• A search strategy is defined by picking the order
of node expansion• Strategies are evaluated along the following
dimensions:o completeness: does it always find a solution if one
exists?o time complexity: number of nodes generatedo space complexity: maximum number of nodes in
memoryo optimality: does it always find a least-cost solution?
• Time and space complexity are measured in terms of o b: branching factor or maximum number of successors
of any nodeo d: depth of the least-cost solutiono m: maximum length of any path in the state space (may
be ∞)
![Page 27: Solving Problems by Searching](https://reader035.vdocuments.us/reader035/viewer/2022070411/56814887550346895db59945/html5/thumbnails/27.jpg)
Uninformed Search Strategies
• Uninformed search strategies use only the information available in the problem definition.
Breadth-first searchUniform-cost searchDepth-first search• Depth-limited search