0% found this document useful (0 votes)
11 views15 pages

Informed Search

The document explains the Greedy Best-First Search algorithm, which uses a heuristic function to expand nodes closest to the goal but may not find the optimal path due to disregarding edge weights. It also discusses the A* Search algorithm, which combines uniform-cost and greedy search strategies to ensure the lowest-cost path is found by evaluating both actual and estimated costs. Additionally, the AO* algorithm is introduced as an adaptable search method that provides incremental solutions and can be interrupted, making it suitable for real-time applications.

Uploaded by

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

Informed Search

The document explains the Greedy Best-First Search algorithm, which uses a heuristic function to expand nodes closest to the goal but may not find the optimal path due to disregarding edge weights. It also discusses the A* Search algorithm, which combines uniform-cost and greedy search strategies to ensure the lowest-cost path is found by evaluating both actual and estimated costs. Additionally, the AO* algorithm is introduced as an adaptable search method that provides incremental solutions and can be interrupted, making it suitable for real-time applications.

Uploaded by

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

1.

Best-first search (Greedy Approach) is an informed search algorithm where the evaluation
function is strictly equal to the heuristic function, disregarding the edge weights in a weighted graph
because only the heuristic value is considered. In order to search for a goal node it expands the node
that is closest to the goal as determined by the heuristic function. This approach assumes that it is
likely to lead to a solution quickly. However, the solution from a greedy best-first search may not be
optimal since a shorter path may exist.
In this algorithm, search cost is at a minimum since the solution is found without expanding a node
that is not on the solution path. This algorithm is minimal, but not complete, since it can lead to a
dead end. It’s called “Greedy” because at each step it tries to get as close to the goal as it can.
Evaluation Function
The evaluation function, f(x), for the greedy best-first search algorithm is the following:
f(x) = h(x)
Here, the evaluation function is equal to the heuristic function. Since this search disregards edge
weights, finding the lowest-cost path is not guaranteed.
Heuristic Function
A heuristic function, h(x), evaluates the successive node based on how close it is to the target node.
In other words, it chooses the immediate low-cost option. As this is the case, however, it does not
necessarily find the shortest path to the goal.
Suppose a bot is trying to move from point A to point B. In greedy best-first search, the bot will
choose to move to the position that brings it closest to the goal, disregarding if another position
ultimately yields a shorter distance. In the case that there is an obstruction, it will evaluate the
previous nodes with the shortest distance to the goal, and continuously choose the node that is
closest to the goal.
The Algorithm
1. Initialize a tree with the root node being the start node in the open list.
2. If the open list is empty, return a failure, otherwise, add the current node to the closed list.
3. Remove the node with the lowest h(x) value from the open list for exploration.
4. If a child node is the target, return a success. Otherwise, if the node has not been in either
the open or closed list, add it to the open list for exploration.
Example
Consider finding the path from P to S in the following graph:
In this example, the cost is measured strictly using the heuristic value. In other words, how close it is
to the target.

C has the lowest cost of 6. Therefore, the search will continue like so:
U has the lowest cost compared to M and R, so the search will continue by exploring U. Finally, S has
a heuristic value of 0 since that is the target node:

The total cost for the path (P -> C -> U -> S) evaluates to 11. The potential problem with a greedy
best-first search is revealed by the path (P -> R -> E -> S) having a cost of 10, which is lower than (P -
> C -> U -> S). Greedy best-first search ignored this path because it does not consider the edge
weights.
1. A* Search
A* Tree Search, known as A* Search, combines the strengths of uniform-cost search and greedy
search. To find the best path from the starting state to the desired state, the A* search algorithm
investigates all potential paths in a graph or grid. The algorithm calculates the cost of each potential
move at each stage using the following two criteria:
 How much it costs to reach the present node?
 The approximate cost from the present node to the goal.
A heuristic function is used to determine the estimated cost and estimate the distance between the
current node and the desired state. The acceptable nature of this heuristic function ensures that it
never overestimates the actual cost of achieving the goal.
The path with the lowest overall cost is chosen after an A* search examines each potential route
based on the sum of the actual cost and the estimated cost (i.e., the cost so far and the estimated
cost-to-go). By doing this, the algorithm is guaranteed to always investigate the most promising path
first, which is most likely to lead to the desired state.
In this algorithm, we denote the total cost (heuristic) by f(x), summing the cost in uniform cost
search represented by g(x) and the cost of the greedy search represented by h(x).
f (x) = g (x) + h (x)
In this, we define g(x) as the backward cost, which is the cumulative cost from the root node to the
current node, and we define h(x) as the forward cost, which is the approximate distance between
the goal node and the current node.
The A* algorithm is implemented in a similar way to Dijkstra’s algorithm. Given a weighted graph
with non-negative edge weights, to find the lowest-cost path from a start node S to a goal node G,
two lists are used:
 An open list, implemented as a priority queue, which stores the next nodes to be explored.
Because this is a priority queue, the most promising candidate node (the one with the
lowest value from the evaluation function) is always at the top. Initially, the only node in this
list is the start node S.
 A closed list which stores the nodes that have already been evaluated. When a node is in the
closed list, it means that the lowest-cost path to that node has been found.
To find the lowest cost path, a search tree is constructed in the following way:
1. Initialize a tree with the root node being the start node S.
2. Remove the top node from the open list for exploration.
3. Add the current node to the closed list.
4. Add all nodes that have an incoming edge from the current node as child nodes in the tree.
5. Update the lowest cost to reach the child node.
6. Compute the evaluation function for every child node and add them to the open list.
Just like in Dijkstra’s algorithm, the lowest cost is updated as the algorithm progresses in the
following way:
current_lowest_cost = min(current_lowest_cost, parent_node_cost + edge_weight)
All nodes except for the start node start with a lowest cost of infinity. The start node has an initial
lowest cost of 0.
The algorithm concludes when the goal node G is removed from the open list and explored,
indicating that a shortest path has been found. The shortest path is the path from the start node S to
the goal node G in the tree.
Note: The algorithm ends when the goal node G has been explored, NOT when it is added to the
open list.
Example
Consider the following example of trying to find the shortest path from S to G in the following graph:
Each edge has an associated weight, and each node has a heuristic cost (in parentheses).
An open list is maintained in which the node S is the only node in the list. The search tree can now
be constructed.
Exploring S:

A is the current most promising path, so it is explored next:

Exploring D:

Exploring F:
Notice that the goal node G has been found. However, it hasn’t been explored, so the algorithm
continues because there may be a shorter path to G. The node B has two entries in the open list: one
at a cost of 16 (child of S) and one at a cost of 18 (child of A). The one with the lowest cost is
explored next:

Exploring C:
The next node in the open list is again B. However, because B has already been explored, meaning a
shortest path to B has been found, it is not explored again and the algorithm continues to the next
candidate.

The next node to be explored is the goal node G, meaning the shortest path to G has been found!
The path is constructed by tracing the graph backward from G to S:
2. AO* Algorithm
The AO* algorithm, short for "Anytime Optimistic" algorithm, is a search algorithm used in artificial
intelligence and computer science to find the optimal path or solution in a graph or state space. It is
particularly useful in applications like robotics, pathfinding, and planning, where finding the best
possible solution is essential.
The AO* algorithm belongs to the family of informed search algorithms, meaning it utilizes
heuristics or estimated cost functions to guide the search process. It efficiently balances the trade-
off between computation time and the quality of the solution. Unlike some other algorithms that
focus solely on finding the optimal solution, AO* provides a series of progressively improving
solutions, making it adaptable to various scenarios.
Key Features of AO* Algorithm:
1. Anytime Nature:
AO* provides solutions incrementally, allowing users to interrupt the search at any time and
retrieve the best solution found so far. This feature is crucial in real-time systems where
immediate responses are necessary.
2. Optimistic Search:
AO* maintains an "optimistic" cost estimate for each state, which serves as a lower bound
on the true cost. This estimate helps prioritize promising paths during the search.
3. Adaptive Behaviour:
AO* can adapt its search strategy based on the available computational resources and user
requirements. It can allocate more time for an exhaustive search if needed or return a
solution quickly when computational resources are limited.
4. Heuristic Function:
Like other informed search algorithms, AO* relies on a heuristic function that estimates the
cost from the current state to the goal state. This function guides the search by prioritizing
states that appear more promising.
Working of AO* Algorithm
The AO* algorithm is designed to efficiently search through a state space or graph to find the
optimal solution while providing the flexibility to return intermediate solutions at any time. Its
operation can be broken down into several key steps:
1. Initialization
The algorithm begins with the initialization of critical components:
 Start State:
It starts from the initial state, which represents the current state of the problem or the
starting point in a graph.
 Cost Estimates:
For each state, AO* maintains an "optimistic" cost estimate, denoted as g*(s), which serves
as a lower bound on the true cost from the start state to that state. Initially, these cost
estimates are set to infinity for all states except the start state, which has a cost estimate of
zero.
 Priority Queue:
AO* uses a priority queue (often implemented as a binary heap) to keep track of states that
need to be expanded. States are prioritized in the queue based on their g*(s) values, with
states having lower cost estimates being higher in priority.
2. Iterative Expansion
The core of AO* is an iterative process that repeatedly selects and expands the most promising state
from the priority queue. This process continues until certain termination conditions are met. Here's
how it works:
 Selecting a State:
The algorithm selects the state with the lowest g*(s) value from the priority queue. This
state represents the most promising path discovered so far.
 Expanding a State:
Once a state is selected, AO* generates its successor states, which are the states reachable
from the current state by taking valid actions or moving along edges in the graph. These
successor states are generated and evaluated.
 Updating Cost Estimates:
For each successor state, the algorithm updates its g*(s) value. The updated value depends
on the cost of reaching that successor state from the current state and the g*(s) value of the
current state.
 Adding to Priority Queue:
The newly generated states, along with their updated g*(s) values, are added to the priority
queue.
3. Termination
The search process continues until certain termination conditions are met. These conditions can
include:
 A predefined time limit:
The algorithm stops after a specified amount of time has elapsed.
 A user request:
The user can request the algorithm to stop and return the best solution found so far.
 The discovery of an optimal solution:
If AO* finds a solution that satisfies the problem constraints, it can terminate.
4. Solution Retrieval
One of the unique features of AO* is its ability to return solutions incrementally. At any point during
the search, the user can decide to stop the algorithm and retrieve the best solution found so far. This
flexibility is particularly valuable in real-time systems where immediate responses are required, and
waiting for the optimal solution may not be feasible.
5. Adaptation
Another essential aspect of AO* is its adaptability. It can adjust its search strategy based on available
computational resources and user requirements. If more time or computational power is available,
AO* can perform a more exhaustive search to improve the solution quality. Conversely, if resources
are limited, it can return a solution quickly without completing the entire search.
Example - 2: Robotic Navigation
In the field of robotics, AO* can be used for path planning and navigation in dynamic environments.
Let's consider a scenario where a robot needs to navigate through an environment with moving
obstacles.
1. Initialization:
o Start State:
The robot's current position is the initial state.
o Cost Estimates:
Initially, cost estimates for states are set based on the distance from the current
position to possible goal positions.
o Priority Queue:
The priority queue is initialized with the robot's current position.
2. Iterative Expansion:
o The algorithm selects the state with the lowest g*(s) value from the priority queue,
which is the robot's current position initially.
o It generates successor states by simulating possible movements of the robot.
o The cost estimates for these successor states are updated based on the estimated
time or energy required to reach those states.
o The successor states and their updated cost estimates are added to the priority
queue.
3. Termination:
o The search process continues until a termination condition is met. This could be
when the robot reaches the goal, when a user intervention occurs, or when a
timeout occurs.
4. Solution Retrieval:
o AO* allows the robot to start moving toward the goal based on the best path found
so far, even if it's not the optimal path. This is particularly useful in scenarios where
the environment is changing, and the robot needs to adapt its path in real time.

Difference Between A* Algorithm and AO* Algorithm


Aspect A* Algorithm AO* Algorithm
Anytime Nature No Yes (Provides incremental solutions)
Optimistic Cost Single cost estimate based on
Optimistic cost estimates for each state
Estimates heuristics
Adaptability Fixed-depth search Adapts to available time and resources
Always seeks the single optimal
Prioritization Balances quality vs. time efficiently
path
Solution Provides a series of progressively improving
Finds the single optimal solution
Completeness solutions
Termination Typically continues until optimal Can be terminated at any time, returning the
Condition solution found best solution found so far
Used when finding the absolute Preferred in real-time systems and applications
Use Cases
best solution is top priority requiring adaptability
Real-time Widely used in robotics, video games, network
Less suitable for real-time systems
Applications routing, autonomous vehicles, etc.
Quality vs. Time Prioritizes solution quality over time Balances between solution quality and
Trade-off efficiency computation time efficiently
Fixed-depth search with no Adapts search strategy based on available
Search Strategy
adaptability computational resources

Example:
AO* Algorithm – Question tree
Here in the above example below the Node which is given is the heuristic value i.e h(n). Edge length
is considered as 1.
Step 1

AO* Algorithm (Step-1)


With help of f(n) = g(n) + h(n) evaluation function,
Start from node A,
f(A⇢B) = g(B) + h(B)
=1 + 5 ……here g(n)=1 is taken by default for path cost
=6

f(A⇢C+D) = g(c) + h(c) + g(d) + h(d)


=1+2+1+4 ……here we have added C & D because they are in AND
=8
So, by calculation A⇢B path is chosen which is the minimum path, i.e f(A⇢B)
Step 2
AO* Algorithm (Step-2)
According to the answer of step 1, explore node B
Here the value of E & F are calculated as follows,

f(B⇢E) = g(e) + h(e)


f(B⇢E) = 1 + 7
=8

f(B⇢f) = g(f) + h(f)


f(B⇢f) = 1 + 9
= 10
So, by above calculation B⇢E path is chosen which is minimum path, i.e f(B⇢E)
because B's heuristic value is different from its actual value The heuristic is
updated and the minimum cost path is selected. The minimum value in our situation is 8.
Therefore, the heuristic for A must be updated due to the change in B's heuristic.
So we need to calculate it again.

f(A⇢B) = g(B) + updated h(B)


=1+8
=9
We have Updated all values in the above tree.
Step 3

AO* Algorithm (Step-3) -


By comparing f(A⇢B) & f(A⇢C+D)
f(A⇢C+D) is shown to be smaller. i.e 8 < 9
Now explore f(A⇢C+D)
So, the current node is C

f(C⇢G) = g(g) + h(g)


f(C⇢G) = 1 + 3
=4

f(C⇢H+I) = g(h) + h(h) + g(i) + h(i)


f(C⇢H+I) = 1 + 0 + 1 + 0 ……here we have added H & I because they are in AND
=2

f(C⇢H+I) is selected as the path with the lowest cost and the heuristic is also left unchanged
because it matches the actual cost. Paths H & I are solved because the heuristic for those paths is 0,
but Path A⇢D needs to be calculated because it has an AND.

f(D⇢J) = g(j) + h(j)


f(D⇢J) = 1 + 0
=1
the heuristic of node D needs to be updated to 1.

f(A⇢C+D) = g(c) + h(c) + g(d) + h(d)


=1+2+1+1
=5

as we can see that path f(A⇢C+D) is get solved and this tree has become a solved tree now.
In simple words, the main flow of this algorithm is that we have to find firstly level 1st heuristic
value and then level 2nd and after that update the values with going upward means towards the
root node.

You might also like