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

Post on 17-Jan-2016

219 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Chapter 3Chapter 3

Solving Problems by Solving Problems by SearchingSearching

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

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

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

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

Problem FormulationProblem Formulation• State SpaceState Space

Map of RomaniaMap of Romania

Road Map of RomaniaRoad Map of Romania

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

8-Puzzle Problem8-Puzzle Problem

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

8-Queens8-Queens

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

Real-World ProblemsReal-World Problems

Robot NavigationRobot Navigation

VLSI LayoutVLSI Layout

Internet SearchingInternet Searching

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

States vs. NodesStates vs. Nodes

StateState• Physical Physical

ConfigurationConfiguration NodeNode

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

Road Map of RomaniaRoad Map of Romania

RepresentationRepresentation

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

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

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

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

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

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

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

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

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))

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

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

top related