Professional Documents
Culture Documents
3
Depth-First Search (DFS)
Algorithm outline:
Always select from the OPEN the node with the greatest
depth for expansion, and put all newly generated nodes
into OPEN
OPEN is organized as LIFO (last-in, first-out) list.
Terminate if a node selected for expansion is a goal.
S
1 5 8
A B C
Depth-First Search (DFS) 3 9 4 5
7
D E G G’ G”
Exp. node OPEN list CLOSED list
{S} {}
S {ABC} {S}
A { D E G B C} {S A}
D {EGBC} {S A D}
E {GBC} {S A D E}
G {BC} {S A D E}
S
1 8
5
Level-1
A B C
3 9 4 5
7
Level-2
D E G G’ G”
Depth-First Iterative Deepening (DFID)
Uniform cost search expands the node with least path cost
Let g(n) = cost of the path from the start node to an open node n
Algorithm outline:
Always select from the OPEN the node with the least g(.)
value for expansion, and put all newly generated nodes into
OPEN
Nodes in OPEN are sorted by their g(.) values (in ascending
order)
Terminate if a node selected for expansion is a goal
S
1 5 8
A B C
Uniform-Cost Search(UCS) 3 9 4
7 5
D E G G’ G”
Breadth-First Search:
• Some solutions are known to be shallow
Uniform-Cost Search:
• Actions have varying costs
• Least cost solution is required
This is the only uninformed search that worries about costs.
Find a Path from Node S to Node G using
BFS, DFS and UCS.
S
1 1
2
A B C
3 3
2 1
2
D E F X
Y
1 4
3
2
Z
G
Heuristics
It is a kind of guess and a kind of technique used to solve a
problem quickly.
In mathematics we are assume value of x , to solve the
problem quickly that’s why heuristics is:
Heuristics are "rules of thumb", educated guesses,
intuitive judgments or simply common sense.
17
Use of heuristics in our everyday lives:
The reason that sales pages are often very long and contain a lot of
material–such as information in bullet form, pictures and lots of
recommendations of satisfied customers–is in the hopes that you, as a
consumer, will think:
“Ah, if this much is written about the product, and if this many
people (experts) recommend the product, then it must be good.”
19
Heuristic Search
For many real world problems, it is possible to find specific
information to guide the search process and thus reduce the
amount of computation.
20
Heuristic Function
It is a function that maps from problem state description to
measure of desirability, usually represented as number.
The purpose of heuristic function is to guide the search process
in the most profitable path among all the paths that are
available.
21
Major Benefits of Heuristics
1. Heuristic approaches have an inherent flexibility, which
allows them to be used on ill-structured and complex
problems.
2. These methods by design may be simpler for the decision
maker to understand, especially when it is composed of
qualitative analysis. Thus chances are much higher for
implementing proposed solution.
3. These methods may be used as part of an iterative
procedure that guarantees the finding of an optimal solution.
22
Generate and Test
A simple generate and test search involves a search in which
each branch of the tree is explored in turn to see if it leads to a
state which matches the goal state.
This algorithm is a depth first search procedure since complete
solutions must be generated before they can be tested.
In order to find a solution it may be necessary to conduct an
exhaustive examination of the entire search space.
Algorithm:
Generate a possible solution. For some problems, this
means generating a particular point in the problem
space. For others, it means generating a path from a
start state.
Test to see if this is actually a solution by comparing the
chosen point or the endpoint of the chosen path to the
set of acceptable goal states.
Ifa solution has been found, Quit, otherwise return to
step1.
The A* Search Heuristic
f=g+h
g - the cost of getting from the initial state to the
current state
h - the cost of getting from the current state to a
goal state
Search Problems:
Single Agent Path-finding Problems
Given a road map of n cities, find the shortest tour which visits
every city on the map exactly once and then return to the original
city.
Geometric version:
• a complete graph of n vertices.
• Find one legal tour that is shortest
State Space of TSP