











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!












Russell
and Norvig: Chapter 3
environment
actuators
environment
actuators
Example: Route findingExample: Route finding
Holiday Planning^ On holiday in Romania; Currently in Arad.Flight leaves tomorrow from Bucharest.^ Formulate Goal:Be in Bucharest^ Formulate Problem:States: various citiesActions: drive between cities^ Find solution:Sequence of cities: Arad, Sibiu, Fagaras, Bucharest
Problem Formulation
Urziceni Giurgiu
Hirsova Eforie Neamt
OradeaZerind Arad Timisoara
LugojMehadiaDobreta Sibiu^ Fagaras Pitesti Craiova
Iasi Vaslui
Rimnicu Vilcea
Bucharest
71 75 118 11170 75 151 14099 80 97 120
(^211101138) 146
(^8590) 87 92 142 98 86^ Goal
Start
States Actions
Solution
Vacuum World
R L S^
S S^
S R L
R L R L S
S S
S
L L
L
L^
R R R R
Search ProblemSearch Problem^ State space^ Initial state^ Successor function^ Goal test^ Path cost:^ ^ [path
Example: 8-^ Example: 8
-puzzlepuzzle 28 3 47 15 6
Initial state
Goal state
Example: 8Example: 8-
-puzzlepuzzle 28 3 47 15 6
Example: 8Example: 8-
-puzzlepuzzle Size of the state space = 9!/2 = 181,44015-puzzle
Æ^ .65^ x
24-puzzle
Æ^ .5^ x^
10 millions states/sec
0.18 sec 6 days 12 billion years
Your Turn: Search ProblemYour Turn: Search Problem^ State space^ Initial state^ Successor function^ Goal test^ Path cost
Search of State Space^ Search of State Space
Search of State Space^ Search of State Space
Search State SpaceSearch State Space
Example: 8-Example: 8
-queensqueens
Place 8 queens in a chessboard so that no two queensare in the same row, column, or diagonal.A solution
Not a solution
Example: 8-^ Example: 8
-queensqueens^ Formulation #1:•States: any arrangement of0 to 8 queens on the board• Initial state: 0 queens on theboard• Successor function: add aqueen in any square• Goal test: 8 queens on theboard, none attacked^ Æ^64
Example: 8Example: 8-
-queensqueens^ Formulation #2:•States: any arrangement ofk = 0 to 8 queens in the
leftmost columns with noneattacked• Initial state: 0 queens on theboard• Successor function: add aqueen to any square in theleftmost empty column suchthat it is not attackedby any other queen• Goal test: 8 queens on theboard
Example: Robot navigationExample: Robot navigation^ What is the state space
Example: Robot navigationExample: Robot navigation^ Cost of one horizontal/vertical step = 1Cost of one diagonal step =
Example: Robot navigation^ Example: Robot navigation
Example: Assembly PlanningExample: Assembly Planning
Initial state
Goal state
Complex function:it must find if a collision-freemerging motion existsSuccessor function:• Merge two subassemblies
Example: Assembly PlanningExample: Assembly Planning
Basic Search ConceptsBasic Search Concepts^ Search tree^ Search node^ Node expansion^ Search strategy: At each stage itdetermines which node to expand
Search Nodes^ Search Nodes
≠^ States ≠ States
28 3 47 15 6 278 3 4 15 6 28 3 47 15 6
8 3 15 6
48 37 15 6 2 4 7
2
28 3 47 15 6
The search tree may be infinite evenThe search tree may be infinite evenwhen the state space is finitewhen the state space is finite
FringeFringe^ Set of search nodes that have not beenexpanded yet^ Implemented as a queue FRINGE^ ^ INSERT(node,FRINGE)^ ^ REMOVE(FRINGE)^ The ordering of the nodes in FRINGEdefines the search strategy
Search AlgorithmSearch Algorithm^ 1.^ If GOAL?(initial-state) then return initial-state2.^ INSERT(initial-node,FRINGE)3.^ Repeat:
If FRINGE is empty then return failure n^ Å^ REMOVE(FRINGE) s^ Å^ STATE(n) For every state s’ in SUCCESSORS(s) ^ Create a node n’ ^ If GOAL?(s’) then return path or goal state ^ INSERT(n’,FRINGE)
Search Strategies^ A strategy is defined by picking the order of nodeexpansion^ Strategies are evaluated along the followingdimensions:^ ^ Completeness – does it always find a solution if one exists?^ ^ Time complexity – number of nodes generated/expanded^ ^ 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 brancing factor of the search tree^ ^ d – depth of the least-cost solution^ ^ m – maximum depth of the state space (may be
∞)
Important Remark^ Important Remark^ Some problems formulated as searchproblems are NP-hard problems.
We
cannot expect to solve such a problemin less than exponential time in theworst-case^ But we can nevertheless strive to solveas many instances of the problem aspossible
Blind vs. Heuristic StrategiesBlind vs. Heuristic Strategies^ Blind (or uninformed) strategies do notexploit any of the information containedin a state^ Heuristic (or informed) strategiesexploits such information to assess thatone node is “more promising” thananother
Blind Search…^ …[the ant] knew that a certain arrangement had to be made,but it could not figure out how to make it.
It was like a man
with a tea-cup in one hand and a sandwich in the other, whowants to light a cigarette with a match.
But, where the man
would invent the idea of putting down the cup and sandwich—before picking up the cigarette and the match—this ant wouldhave put down the sandwich and picked up the match, then itwould have been down with the match and up with thecigarette, then down with the cigarette and up with thesandwich, then down with the cup and up with the cigarette,until finally it had put down the sandwich and picked up thematch.^ It was inclined to rely on a series of accidents toachieve its object.
It was patient and did not think…
Wart
watched the arrangements with a surprise which turned intovexation and then into dislike.
He felt like asking why it did not
think things out in advance…
T.H. White,
The Once and Future King
Breadth-Breadth
-First StrategyFirst Strategy
Evaluation^ Evaluation^ b: branching factor^ d: depth of shallowest goal node^ Complete^ Optimal if step cost is 1^ Number of nodes generated:1 + b + b
Time and space complexity is O(b
d+1 )
Time and Memory RequirementsTime and Memory Requirements
Time and Memory RequirementsTime and Memory Requirements
Bidirectional StrategyBidirectional Strategy^ 2 fringe queues: FRINGE1 and FRINGE2Time and space complexity = O(b
Depth-^ Depth
-First StrategyFirst Strategy
DepthDepth-
-First StrategyFirst Strategy
DepthDepth-
-First StrategyFirst Strategy
Depth-Depth
-First StrategyFirst Strategy
Depth-^ Depth
-First StrategyFirst Strategy
DepthDepth-
-First StrategyFirst Strategy
DepthDepth-
-First StrategyFirst Strategy
EvaluationEvaluation^ b: branching factor^ d: depth of shallowest goal node^ m: maximal depth of a leaf node^ Complete only for finite search tree^ Not optimal^ Number of nodes generated:1 + b + b
Depth-^ Depth
-Limited StrategyLimited Strategy Depth-first with depth cutoff k(maximal depth below which nodes arenot expanded) Three possible outcomes: Solution Failure (no solution) Cutoff (no solution within cutoff)
Iterative Deepening StrategyIterative Deepening Strategy^ Repeat for k = 0, 1, 2, …:Perform depth-first with depth cutoff k^ Complete^ Optimal if step cost =1^ Time complexity is:(d+1)(1) + db + (d-1)b
2 + … + (1) b
Comparison of StrategiesComparison of Strategies^ Breadth-first is complete and optimal,but has high space complexity^ Depth-first is space efficient, but neithercomplete nor optimal^ Iterative deepening is asymptoticallyoptimal
Uniform-Uniform
-Cost StrategyCost Strategy
≥ ε^ > 0^.
costs of all steps.
S^ A GB C 11055 515
Modified Search Algorithm^ Modified Search Algorithm^ 1.^ INSERT(initial-node,FRINGE)2.^ Repeat:
If FRINGE is empty then return failure n^ Å^ REMOVE(FRINGE) s^ Å^ STATE(n) If GOAL?(s) then return path or goal state For every state s’ in SUCCESSORS(s) ^ Create a node n’ ^ INSERT(n’,FRINGE)
ExercisesExercises^ Adapt uniform-cost search to avoidrepeated states while still finding theoptimal solution^ Uniform-cost looks like breadth-first (itis exactly breadth first if the step cost isconstant). Adapt iterative deepening ina similar way to handle variable stepcosts
Summary^ Search tree
≠^ state space Search strategies: breadth-first, depth-first, and variants Evaluation of strategies: completeness,optimality, time and space complexity Avoiding repeated states Optimal search with variable step costs