chapter 3 solving problems by searching. abstraction representing the real world want to buy a...

27
Chapter 3 Chapter 3 Solving Problems by Solving Problems by Searching Searching

Upload: edmund-walton

Post on 17-Jan-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

Chapter 3Chapter 3

Solving Problems by Solving Problems by SearchingSearching

Page 2: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

AbstractionAbstraction

Representing the Real WorldRepresenting the Real World• Want to buy a full-scale model of the Want to buy a full-scale model of the

Real WorldReal World• Way too complex!Way too complex!

Simplify the ProblemSimplify the Problem Throw-out unnecessary informationThrow-out unnecessary information

• This is where much of the real This is where much of the real intelligence happensintelligence happens

Page 3: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

Problem Solving AgentsProblem Solving Agents

Goal FormulationGoal Formulation• What does the agent need to accomplish What does the agent need to accomplish

right now.right now. Problem FormulationProblem Formulation

• What States and Actions to considerWhat States and Actions to consider• This is where we need abstractionThis is where we need abstraction

Search for SolutionSearch for Solution• Given states and actionsGiven states and actions• What actions should be taken to achieve goalWhat actions should be taken to achieve goal

Page 4: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

Well-defined Well-defined Problems and SolutionsProblems and Solutions

Well-defined ProblemsWell-defined Problems• Initial StateInitial State• ActionsActions

Successor FunctionSuccessor Function

• Goal TestGoal Test• Path CostPath Cost

Step CostStep Cost Well-defined SolutionWell-defined Solution

• Sequence of ActionsSequence of Actions

Page 5: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

How do I get to Bucharest?How do I get to Bucharest?

Problem FormulationProblem Formulation• State SpaceState Space

Map of RomaniaMap of Romania

Page 6: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

Road Map of RomaniaRoad Map of Romania

Page 7: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

How do I get to Bucharest?How do I get to Bucharest? Problem FormulationProblem Formulation

• State SpaceState Space Map of RomaniaMap of Romania

• Initial StateInitial State At(Arad)At(Arad)

• ActionsActions Go(Arad,Zerind), Go(Iasi,Vaslui), …Go(Arad,Zerind), Go(Iasi,Vaslui), …

• Goal TestGoal Test At(Bucharest)At(Bucharest)

• Path CostPath Cost Sum of individual step costsSum of individual step costs

Well-defined SolutionWell-defined Solution• Sequence of ActionsSequence of Actions

Page 8: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

8-Puzzle Problem8-Puzzle Problem

Page 9: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

How do I solve How do I solve an 8-puzzle?an 8-puzzle?

Problem FormulationProblem Formulation• StatesStates

Position of each tilePosition of each tile• Initial StateInitial State

Random PositionRandom Position• ActionsActions

Move tilesMove tiles Move empty tileMove empty tile

• Goal TestGoal Test Are all of the tiles in the correct positionAre all of the tiles in the correct position

• Path CostPath Cost step cost is 1step cost is 1

Well-defined SolutionWell-defined Solution• Sequence of ActionsSequence of Actions

Page 10: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

8-Queens8-Queens

Page 11: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

How do I Solve How do I Solve an n-Queens Problem?an n-Queens Problem?

Problem FormulationProblem Formulation• StatesStates

Position of each queenPosition of each queen• Initial StateInitial State

Random PositionRandom Position Empty BoardEmpty Board

• ActionsActions Move(Queen,Square)Move(Queen,Square) Place(Queen,Square)Place(Queen,Square)

• Goal TestGoal Test No Queen Attacks anotherNo Queen Attacks another

• Path CostPath Cost NoneNone

Well-defined SolutionWell-defined Solution• Placement of each QueenPlacement of each Queen

Page 12: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

Real-World ProblemsReal-World Problems

Robot NavigationRobot Navigation

VLSI LayoutVLSI Layout

Internet SearchingInternet Searching

Page 13: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

Search AlgorithmsSearch Algorithms Simulated Exploration of State SpaceSimulated Exploration of State Space Off-lineOff-line Create Search TreeCreate Search Tree

Simple Search AlgorithmSimple Search Algorithm• 1. Start with initial state1. Start with initial state• 2. Expand state by applying appropriate 2. Expand state by applying appropriate

actionsactions• 3. Check Goal Test3. Check Goal Test

If False: Goto 2If False: Goto 2• 4. Return Path From Initial State To Goal4. Return Path From Initial State To Goal

Page 14: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

States vs. NodesStates vs. Nodes

StateState• Physical Physical

ConfigurationConfiguration NodeNode

• IncludesIncludes• DepthDepth• Parent NodeParent Node• Etc.Etc.

Page 15: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

Road Map of RomaniaRoad Map of Romania

Page 16: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale
Page 17: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

RepresentationRepresentation

One possible node representationOne possible node representation• StateState• Parent pointerParent pointer• ActionAction• Path-CostPath-Cost• DepthDepth• Child ListChild List

Page 18: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

Measuring PerformanceMeasuring Performance

CompletenessCompleteness• GuaranteedGuaranteed to find a solution? to find a solution?

OptimalityOptimality• Find an Find an optimaloptimal solution? solution?

Space complexitySpace complexity• How much How much memorymemory to find a solution to find a solution

Time complexityTime complexity• How How longlong to find a solution to find a solution

Page 19: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

Uninformed Search StrategiesUninformed Search Strategies

Breadth-first SearchBreadth-first Search Uniform-cost SearchUniform-cost Search Depth-first SearchDepth-first Search Depth-limited SearchDepth-limited Search Iterative-deepening SearchIterative-deepening Search Bidirectional SearchBidirectional Search

Page 20: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

Breadth-first SearchBreadth-first Search

Expand according to tree-depthExpand according to tree-depth CompleteComplete Non-optimalNon-optimal

• (optimal if cost related to depth)(optimal if cost related to depth) Space!! Space!!

• All nodes remain in memoryAll nodes remain in memory• bbdd nodes per level nodes per level

Page 21: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

Breadth-first SearchBreadth-first SearchTime & Memory RequirementsTime & Memory Requirements

DepthDepth NodesNodes TimeTime MemoryMemory

22 11001100 .11 sec.11 sec 1 meg1 meg

44 111,100111,100 11 sec11 sec 106 meg106 meg

66 101077 19 min19 min 10 gig10 gig

88 101099 31 hrs31 hrs 1 T1 T

1010 10101111 129 days129 days 101 T101 T

Page 22: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

Uniform-cost SearchUniform-cost Search Expand node with lowest path costExpand node with lowest path cost CompleteComplete OptimalOptimal

Space ComplexitySpace Complexity• Similar to BFSSimilar to BFS• O(bO(bC*/eC*/e))

C* is memory cost of optimal solutionC* is memory cost of optimal solution e is the minimal cost of each actione is the minimal cost of each action

• If all costs are the same If all costs are the same O(bO(bC*/eC*/e) = b) = bdd

Page 23: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

Depth-first SearchDepth-first Search

Expand deepest node firstExpand deepest node first Implemented with stackImplemented with stack

Space ComplexitySpace Complexity• Only need a single pathOnly need a single path• O(bd)O(bd)

Time ComplexityTime Complexity• O(bO(bdd))

Not CompleteNot Complete Not OptimalNot Optimal

Page 24: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

Depth-limited SearchDepth-limited Search

DFS with a predetermined depth limit DFS with a predetermined depth limit – ‘L’– ‘L’

Better space and time complexitiesBetter space and time complexities• Space O(bL)Space O(bL)• Time O(bTime O(bLL))

Not CompleteNot Complete Not OptimalNot Optimal

Page 25: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

Iterative DeepeningIterative Deepening

DLS with modificationDLS with modification Gradually increase depth limitGradually increase depth limit

CompleteComplete OptimalOptimal SpaceSpace

• O(bd)O(bd) TimeTime

• O(bO(bdd))

Page 26: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

Bi-directionalBi-directional Search Both directionsSearch Both directions

• From Start and GoalFrom Start and Goal Both Searches use BFSBoth Searches use BFS

• why?why?

CompleteComplete OptimalOptimal SpaceSpace

• O(bO(bd/2d/2)) TimeTime

• O(bO(bd/2d/2))

Requires Predecessor InformationRequires Predecessor Information

Page 27: Chapter 3 Solving Problems by Searching. Abstraction  Representing the Real World Want to buy a full-scale model of the Real WorldWant to buy a full-scale

Avoiding Repeated StatesAvoiding Repeated States

Issue in all problems with reversible Issue in all problems with reversible actionsactions

Must somehow mark nodes as visitedMust somehow mark nodes as visited• Check expanded nodes in queueCheck expanded nodes in queue• Create memory of visited statesCreate memory of visited states

Must also check to see if new path to Must also check to see if new path to repeated state has lower cost of repeated state has lower cost of previous pathprevious path