0% found this document useful (0 votes)
7 views39 pages

Unit 2 AI Part 1

The document discusses various search algorithms used in artificial intelligence to solve problems by exploring action sequences in a search tree. It outlines uninformed search strategies like breadth-first, depth-first, and uniform-cost search, as well as informed search strategies such as greedy best-first and A* search, highlighting their mechanisms and performance metrics. Additionally, it covers memory-bounded heuristic searches, including recursive best-first search and memory-bounded A*, which aim to optimize memory usage during the search process.

Uploaded by

venkat Mohan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views39 pages

Unit 2 AI Part 1

The document discusses various search algorithms used in artificial intelligence to solve problems by exploring action sequences in a search tree. It outlines uninformed search strategies like breadth-first, depth-first, and uniform-cost search, as well as informed search strategies such as greedy best-first and A* search, highlighting their mechanisms and performance metrics. Additionally, it covers memory-bounded heuristic searches, including recursive best-first search and memory-bounded A*, which aim to optimize memory usage during the search process.

Uploaded by

venkat Mohan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 39

Artificial

Intelligence
UNIT 2
SEARCHING FOR SOLUTIONS
• Having formulated some problems, a solution is an
action sequence, so search algorithms work by
considering various possible action sequences.
• The possible action sequences starting at the initial
state form a search tree with the initial state at the root;
the branches are actions and the nodes correspond to
states in the state space of the problem.
• In Route-finding problem, we add three branches from
the parent node In(Arad) leading to three new child
nodes: In(Sibiu), In(Timisoara), and In(Zerind).
• Suppose we choose Sibiu first. We check to see whether
it is a goal state (it is not) and then expand it to get
In(Arad), In(Fagaras), In(Oradea), and In(RimnicuVilcea).
We can then choose any of these four or go back and
choose Timisoara or Zerind. Each of these six nodes is a
leaf node, that is, a node with no children in the tree.
• The set of all leaf nodes available for expansion at any
given point is called the frontier.
• The path from Arad to Sibiu and back to Arad again! We
say that In(Arad) is a repeated state in the search
tree, generated in this case by a loopy path.
• Consider the paths Arad–Sibiu (140 km long) and Arad–
Zerind–Oradea–Sibiu (297 km long). Obviously, the
second path is redundant, called as redundant path.
Infrastructure for search
algorithms
• For each node n of the tree, we have a structure that
contains four components:
1. n.STATE: the state in the state space to which the
node corresponds;
2. n.PARENT: the node in the search tree that generated
this node;
3. n.ACTION: the action that was applied to the parent to
generate the node;
4. n.PATH-COST: the cost, traditionally denoted by g(n),
of the path from the initial state to the node, as
indicated by the parent pointers
• The frontier needs to be stored in such a way that the
search algorithm can easily choose the next node to
expand according to its preferred strategy. The
appropriate data structure for this is a queue.
• The operations on a queue are as follows:
1. EMPTY?(queue) returns true only if there are no more
elements in the queue.
2. POP(queue) removes the first element of the queue
and returns it.
3. INSERT(element, queue) inserts an element and
returns the resulting queue.
• Three common variants are the
• first-in, first-out or FIFO queue, which pops the
oldest element of the queue.
• LIFO queue the last-in, first-out or LIFO queue
(also known as a stack), which pops the newest
element of the queue.
• Priority queue, which pops the element of the
queue with the highest priority according to
some ordering function.
Measuring problem-solving
performance
• Completeness: Is the algorithm guaranteed to
find a solution when there is one?
• Optimality: Does the strategy find the optimal
• Time complexity: How long does it take to find
a solution?
• Space complexity: How much memory is
needed to perform the search?
Uninformed Search Strategies
• This means that the strategies have no additional information
about states beyond that provided in the problem definition. All
they can do is generate successors and distinguish a goal state
from a non-goal state.
• Also called as Blind search.
1. Breadth-first search
2. Uniform-cost search
3. Depth-first search
4. Depth-limited search
5. Iterative Deepening Depth First Search
6. Bidirectional Search
Breadth-first search
• Breadth-first search is a simple strategy in which
the root node is expanded first, then all the
successors of the root node are expanded next,
then their successors, and so on.
• In general, all the nodes are expanded at a given
depth in the search tree before any nodes at the
next level are expanded.
• This is achieved very simply by using a FIFO
queue for the frontier.
Uniform-cost search
• When all step costs are equal, breadth-first search is
optimal because it always expands the shallowest
unexpanded node.
• By a simple extension, we can find an algorithm that
is optimal with any step-cost function.
• Instead of expanding the shallowest node, uniform-
cost search expands the node n with the lowest path
cost g(n).
• This is done by storing the frontier as a priority queue
ordered by g.
Depth-first search
• Depth-first search always expands the deepest
node in the current frontier of the search tree.
The search proceeds immediately to the deepest
level of the search tree, where the nodes have
no successors.
• As those nodes are expanded, they are dropped
from the frontier, so then the search “backs up”
to the next deepest node that still has
unexplored successors.
• Depth-first search uses a LIFO queue.
BACKTRACKING SEARCH
• A variant of depth-first search called
backtracking search uses still less memory. In
backtracking, only one successor is generated at
a time rather than all successors; each partially
expanded node remembers which successor to
generate next.
Depth Limited Search
• The embarrassing failure of depth-first search in
infinite state spaces can be alleviated by
supplying depth-first search with a
predetermined depth limit l.
• That is, nodes at depth l are treated as if they
have no successors. This approach is called
depth-limited search.
• The depth limit solves the infinite-path problem.
Unfortunately, it also introduces an additional
source of incompleteness if we choose l<d, that
is, the shallowest goal is beyond the depth limit.
• For example, on the map of Romania there are 20 cities.
Therefore, we know that if there is a solution, it must be
of length 19 at the longest, so = 19 is a possible
choice.
• But in fact if we studied the map carefully, we would
discover that any city can be reached from any other
city in at most 9 steps. This number, known as the
diameter of the state space, gives us a better depth
limit, which leads to a more efficient depth-limited
search.
• For most problems, however, we will not know a good
depth limit until we have solved the problem.
Iterative deepening depth-first
search
• Iterative deepening search is a general strategy, often used
in combination with depth-first tree search, that finds the
best depth limit.
• It does this by gradually increasing the limit—first 0, then 1,
then 2, and so on—until a goal is found. This will occur when
the depth limit reaches d, the depth of the shallowest goal
node.
• Iterative deepening combines the benefits of depth-first and
breadth-first search.
• Like depth-first search, its memory requirements are precise.
• Like breadth-first search, it is complete when the branching
factor is finite and optimal when the path cost is a
nondecreasing function of the depth of the node.
Bidirectional search
• The idea behind bidirectional search is to run two
simultaneous searches—one forward from the initial
state and the other backward from the goal—hoping
that the two searches meet in the middle.
• Bidirectional search is implemented by replacing the
goal test with a check to see whether the frontiers of
the two searches intersect; if they do, a solution has
been found.
Comparing uninformed search
strategies
Informed Search Strategies
• One that uses problem-specific knowledge
beyond the definition of the problem itself—can
find solutions more efficiently than an
uninformed strategy.
• Also called as Heuristic Search.
1. Greedy best-first search
2. A* search
3. Memory-bounded heuristic search
Greedy best-first search
• The evaluation function is construed as a cost
estimate. It is denoted by f(n).
• That estimated cost of the cheapest path from the state
at node n to a goal state is called as heuristic
function. It is denoted by h(n).
• Greedy best-first search tries to expand the node that is
closest to the goal, on the grounds that this is likely to
lead to a solution quickly. Thus, it evaluates nodes by
using just the heuristic function; that is, f(n) = h(n).
• Example: Route-finding problem in Romania
• we use the straightline distance heuristic, which
we will call h(SLD) . If the goal is Bucharest, we
need to know the straight-line distances to
Bucharest. For example, h(SLD) (In(Arad)) = 366.
• Notice that the values of h(SLD) cannot be
computed from the problem description itself.
Moreover, it takes a certain amount of
experience to know that h(SLD) is correlated with
actual road distances and is, therefore, a useful
heuristic.
A* search
• It evaluates nodes by combining g(n), the cost to
reach the node, and h(n), the cost to get from
the node to the goal.
f(n) = g(n) + h(n)
• Since g(n) gives the path cost from the start
node to node n, and h(n) is the estimated cost of
the cheapest path from n to the goal.
f(n) = estimated cost of the cheapest solution
through n
Memory-bounded heuristic
search
• This search is used to reduce the memory
requirements during the search.
• Two memory-bounded algorithms present,
called RBFS and MA∗.
1. Recursive best-first search (RBFS)
2. Memory-bounded A∗ (MA∗)
Recursive best-first search
• Recursive best-first search (RBFS) is a simple recursive
algorithm that attempts to mimic the operation of standard
best-first search, but using only linear space.
• It uses the f-limit variable to keep track of the f-value of the best
alternative path available from any ancestor of the current
node. If the current node exceeds this limit, the recursion
unwinds back to the alternative path.
• As the recursion unwinds, RBFS replaces the f-value of each
node along the path with a backed-up value—the best f-value of
its children. In this way, RBFS remembers the f-value of the best
leaf in the forgotten subtree and can therefore decide whether
it’s worth reexpanding the subtree at some later time.
Memory-bounded A∗ (MA∗)
• Advanced technique is Simplified Memory-bounded A∗
(SMA∗).
• SMA∗ proceeds just like A∗, expanding the best leaf
until memory is full. At this point, it cannot add a new
node to the search tree without dropping an old one.
• SMA∗ always drops the worst leaf node—the one with
the highest f-value. Like RBFS, SMA∗ then backs up the
value of the forgotten node to its parent. In this way, the
ancestor of a forgotten subtree knows the quality of the
best path in that subtree.
• With this information, SMA∗ regenerates the subtree
only when all other paths have been shown to look
worse than the path it has forgotten.

You might also like