Download presentation

Presentation is loading. Please wait.

Published byErica Lindsey Modified over 2 years ago

1
Comp 307 Problem Solving and Search Formalize a problem as State Space Search Blind search strategies Heuristic search

2
Comp 307 Motivation Intelligence as problem solving Examples of problems: – The Monkey and Bananas Problem – The Missionaries and Cannibals Problem – The 8-puzzle – The Tower of Hanoi – Route finding – Water jug – Wolf, Goat and Cabbage – Chess – Bridge – Go

3
Comp 307 Problem definition Problem solving as State Space Search State: a state of the world. State space: Collection of all possible states Initial state: where the search starts Goal state: where the search stops Operators: Links between pairs of states, that is, what actions can be taken in any state to get to a new state. A path in the state space is a sequence of operators leading from one state to another Solve problem by searching for path from initial state to goal state through legal states. Each operator has an associated cost. Path cost: the sum of the costs of operators along the path.

4
Comp 307 8 puzzle States: location of the 8 tiles Operators: blank moves left, right, up, or down Path cost: length of path 5 83 17 4 6 2 13 5 87 2 6 4 Initial StateGoal State

5
Comp 307 Route finding State: current location on map – Initial state: city A – Goal state: city B Operators: move along a road to another location Path cost: sum on lengths of road A simplified road map of Romania

6
Comp 307 Search Strategies Uninformed (blind) search – Breadth first – Uniform cost – Depth first – Depth limited – Iterative deepening – Bidirectional Heuristic search – A * – Greedy Best first – Hill climbing – Beam search – …

7
Comp 307 Search Tree 5 83 17 4 6 2 5 8 3 17 4 6 2 5 8 4 3 176 2 53 8 17 4 6 2 5 83 17 4 6 2 5 8 3 1 7 4 6 2 left down up leftdown

8
Comp 307 General search algorithm We collect the nodes in a queue loop If the queue is empty then return failure Take the first node from the front of the queue If the node represents the goal state then return success Else expand the node and put the children notes on the queue (reorder the queue) end loop

9
Comp 307 Criteria for search strategies Completeness : is the strategy guaranteed to find a solution when one exists? Optimality : does the strategy find the highest-quality solution (lowest cost) when there are several solutions? Time complexity : how long does it take to find a solution? Space complexity : how much memory does it need to perform the search?

10
Comp 307 Breadth first search Start at the initial state; Find all states reachable from the initial state; Find all states reachable from the states available at the previous step; Repeat the previous step until the final state is reached; Implement with General-Search and Enqueue-at-End One must be careful not to repeatedly visit states that have been seen before.

11
Comp 307 Issues for Breadth-first Search Breadth-first search is guaranteed to find the shortest path – Complete – Optimal if all operators have same cost (so shallowest solution is cheapest solution) In practice, breadth-first search is very expensive – Time complexity O(b d ) – Space complexity O(b d ) b: the branching factor of nodes (ie, average number of children a node has) d: the depth of the desired solution

12
Comp 307 Uniform cost search Expand lowest cost nodes first Implement with General-Search and Enqueue-By-Cost SG A B C 1 10 5 5 15 5

13
Comp 307 Issues for Uniform Cost Search Same as breadth-first search if all operators have the same cost Complete Optimal if all operators have positive cost Time Complexity O(b d ) Space Complexity O(b d )

14
Comp 307 Depth-first search Ô Make the initial state the current state; Ô If current state is a final state then succeed – else make the current state a state reachable from the current state; Ô Repeat previous step until success, backtracking if necessary; Implement with General-Search and Enqueue-at-Start

15
Comp 307 Depth-first search in Prolog :- use_module(library(lists)). solve(InitialState, GoalState) :- search(InitialState, GoalState, [], Plan), displayPlan(Plan). search(State, State, _, []). search(Init, Goal, StatesSoFar, [Step|Rest]) :- transform(Init,Step,NewState), \+member(NewState, StatesSoFar), search(NewState, Goal, [NewState|StatesSoFar], Rest). displayPlan([]) :- format("~nDone", []), nl. displayPlan([Step|Rest]) :- format("~n do ~w", [Step]), displayPlan(Rest).

16
Comp 307 Issues for Depth-first Search Depth-first search is prone to being lost – Complete only if search tree is finite – Not optimal In practice, depth-first search is efficient – Time Complexity O(b m ) – Space Complexity O(bm) (m=max depth of search tree) Good when many solutions in deep (but finite) trees

17
Comp 307 Depth limited search: Like depth-first, but with depth cut off Complete only if solution is at – depth <= c where c is the depth limit Not optimal Time complexity O(b c) Space complexity O(bc)

18
Comp 307 Iterative deepening search Iterative depth limited search Limit= 0, Limit=1, Limit=2, Limit=3, … a b c d efg hi j kl n mo

19
Comp 307 Iterative deepening search Optimal and Complete (if operators all have same cost) Time complexity O(b d ) Space complexity O(bd) Expands some nodes multiple times – But “wasted” effort is actually quite small and goes down as the branching factor goes up In general, iterative deepening is the preferred search method when there is a large search space and the depth of the solution is not known.

20
Comp 307 Bidirectional Search Two breadth-first search Complete and optimal Time complexity O(b d/2 ) Space complexity O(b d/2 ) Not applicable for some problems

Similar presentations

OK

Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.

Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Mp ppt online viewer Ppt on computer languages basic Ppt on different types of dance forms of indian Ppt on preservation methods of food Ppt on power line communication modem Ppt on unity in diversity of india Ppt on andhra pradesh Ppt on international chamber of commerce What does appt only means of Ppt on wildlife and natural vegetation of india