Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 45

A Seminar

Report On

A * SEARCH ALGORITHM
Submitted in partial fulfillment of
the requirements For the award of
the degree of

Master Of Computer Applications


By
C S.MOHAMMED ASIF
(23FH1F0017)
Under the esteemed guidance of
SALMA KHATOON
Assistant
Professor

DEPARTMENT OF MASTERS OF COMPUTER APPLICATIONS


Accredited by NAAC Dr. K. V. SUBBA REDDY INSTITUTE OF
TECHNOLOGY
(Approved by AICTE, NEW DELHI, Accredited by NAAC+&Affiliated to JNTUA,
Anantapur)
AN ISO 9001:2000 CERTIFIED INSTITUTION
OPP. DUPADU (RS), NH-44, LAKSHMIPURAM (PO), KURNOOL – 518218 .
2023-2025
DR. K. V. SUBBA REDDY INSTITUTE OF TECHNOLOGY.
(Affiliated to JNTUA, Anantapur, Approved by
AICTE) Department Of Master OF Computer
Applications

(Autonomous)

CERTIFICATE

This is to certify that the seminar report entitled “A * SEARCH ALGORITHM” is a Bonafied Record of work done by

Mr. MOHAMMED ASIF (23FH1F0017) at Dr. K. V. Subba Reddy Institute Of Technology, Kurnool,

Affiliated to JNTUA, Anantapur in partial fulfillment of the requirements for the award of the degree of

MASTER OF COMPUTER APPLICATIONS.

SEMINAR GUIDE HOD

SALMA KHATOON BUSHRA THASEEN M. Tech, P h .D

Assistant professor Department of MCA


STUDENT DECLARATION

I, MOHAMMED ASIF Bearing the Roll Number 23FH1F0017 , hereby declare that
This seminar entitled “A * SEARCH ALGORITHM” done by me under the guidance of
SALMA KHATOON, Assistance professor, Department of MCA, and this work is not
copied And submitted anywhere for the award of any degree .

Date:
Place: Kurnool
(STUDENT NAME)
Preface
I have made this report file on the topic Internet of things I have tried my best to

elucidate all the relevant detail to the topic to be included in the report. While in the

beginning I have tried to give a general view about this topic. My efforts and

wholehearted cooperation of each and every one has ended on a successful note. I express

my sincere gratitude to SALMA KHATOON who assisting me throughout the preparation

of this topic I thank him for providing me the reinforcement, confidence and most

importantly the track for the topic whenever I needed it.

C S.MOHAMMED ASIF

(23FH1F0017)
A* SEARCH ALGORITHM

CONTENTS

1 INTRODUCTION............................................................................................. 07-08

2 THE SEARCH PROBLEM...................................................................................09

2.1 SHORTEST PATH..............................................................................................10

3 DIJKSTRA ALGORITHM................................................................................11-13

4 PROPERTIES................................................................................................... 14-15

5 COMPLEXITY.................................................................................................... 16-18

6 THE A * SEARCH.............................................................................................. 19-21

7 PROPERTIES OF A*...............................................................................................22

8 ADMISSIBLE HEURISTICS..............................................................................23-24

9 A* IN GAMES..........................................................................................................25

10 CONCLUSION..........................................................................................................26
ABSTRACT

A* (pronounced "A-star") is a graph traversal


and pathfinding algorithm, which is used in many fields
of computer science due to its completeness, optimality, and
optimal efficiency. Given a weighted graph, a source node and a
goal node, the algorithm finds the shortest path (with respect to the
given weights) from source to goal.
One major practical drawback is its space complexity where d is
the depth of the solution (the length of the shortest path) and b is
the branching factor (the average number of successors per state),
as it stores all generated nodes in memory. Thus, in practical travel-
routing systems, it is generally outperformed by algorithms that
can pre-process the graph to attain better performance, as well as
by memory- bounded approaches; however, A* is still the best
solution in many cases.
INTRODUCTION

A* is an informed search algorithm, or a best-first search, meaning that


it is formulated in terms of weighted graphs: starting from a specific
starting node of a graph, it aims to find a path to the given goal node
having the smallest cost (least distance travelled, shortest time, etc.). It
does this by maintaining a tree of paths originating at the start node and
extending those paths one edge at a time until the goal node is reached.
At each iteration of its main loop, A* needs to determine which of its paths
to extend. It does so based on the cost of the path and an estimate of the
cost required to extend the path all the way to the goal.
Specifically, A* selects the path that minimizes

f(n)=g(n)+h(n)
where n is the next node on the path, g(n) is the cost of the path from the
start node to ‘n’, and h(n) is a heuristic function that estimates the cost of
the cheapest path from n to the goal. The heuristic function is problem-
specific. If the heuristic function is admissible – meaning that it never
overestimates the actual cost to get to the goal – A* is guaranteed to
return a least-cost path from start to goal.
Typical implementations of A* use a priority queue to perform the
repeated selection of minimum (estimated) cost nodes to expand. This
priority queue is known as the open set, fringe or frontier. At each step of
the algorithm, the node with the lowest f(x) value is removed from the
queue, the f and g values of its neighbours are updated accordingly, and
these neighbours are added to the queue. The algorithm continues until a
removed node (thus the node with the lowest f value out of all fringe nodes)
is a goal node. The f value of that goal is then also the cost of the shortest
path, since h at the goal is zero in an admissible heuristic.
The algorithm described so far gives us only the length of the shortest path.
To find the actual sequence of steps, the algorithm can be easily revised so
that each node on the path keeps track of its predecessor. After this
algorithm is run, the ending node will point to its predecessor, and so on,
until some node's predecessor is the start node.As an example, when
searching for the shortest route on a map, h(x) might represent the straight-
line distance to the goal, since that is physically the smallest possible
distance between any two points. For a grid map from a video game, using
the Taxicab distance or the Chebyshev distance becomes better depending
on the set of movements available (4-way or 8-way).
If the heuristic h satisfies the additional condition h(x) ≤ d(x, y) + h(y) for
every edge (x, y) of the graph (where d denotes the length of that edge),
then h is called monotone, or consistent. With a consistent heuristic, A* is
guaranteed to find an optimal path without processing any node more than
once and A* is equivalent to running Dijkstra's algorithm with the reduced
cost d'(x, y) = d(x, y) + h(y) − h(x).
The Search Problem
Starting from a node n find the shortest path to a goal
node g

20
15
10 5
15
20 25
18
?
33
Shortest Path

Consider the following weighted undirected graph:


20
10 22 20
18
7 9 16
2 6
8
24
5 4
6
66
10 20
We want: A path 5  v1  v2  …  20
Such that g(20) = cost(5v1) + cost(v1 v2) + … +
cost ( 20) is minimum
Djikstra Algorithm
Greedy algorithm: from the candidate nodes select the
one that has a path with minimum cost from the starting
node

20
15
10 5
15
20 25
18 ?
33
Djikstra Algorithm
Given a Graph G = (V,E) and T a subset of V, the fringe
of T, is defined as:

Fringe(T) = { (w,x) in E : w  T and x V − T}

Djikstra’s algorithm pick the edge v in Fringe(T) that has


minimum distance to the starting node g(v) is minimum
Example

22 20
20
10
7

8 18
9
2 6
24

5 4 6
66
10 20
Properties

Dijkstra’s is a greedy algorithm.


Why Dijkstra’s Algorithm works?
The path from u to every node in T is the minimum
path

T
V T
7
s
x
20
u
w 6 v
20
15 r
What does Djikstra’s algorithm will do? (minimizing g(n))
Problem: Visit too many nodes, some clearly out of
the question
Complexity

• Actual complexity is O(|E|log2 |E|)


• Is this good?
Actually it is bad for very large graphs!

Branching
factor:b

# nodes = b(# levels) ….


………….…………………..………………….

Another Example: think of the search space in chess


Better Solution: Make a ‘hunch”!

• Use heuristics to guide the search


– Heuristic: estimation or “hunch” of how to
search for a
solution
• We define a heuristic function:
h(n) = “estimate of the cost of the cheapest path
from
the starting node to the goal node”
Lets Try A Heuristic

Heuristic: minimize h(n) = “Euclidean distance to


destination”
Problem: not optimal (through Rimmici Viicea and Pitesti is
shorter)
The A* Search

• Difficulty: we want to still be able to


generate the path with minimum cost

• A* is an algorithm that:
– Uses heuristic to guide search
– While ensuring that it will
compute a path with minimum
cost
“estim
ated
cost”
• A* computes the function f(n) = g(n) + h(n)

“actual cost”
A*
• f(n) = g(n) + h(n)
– g(n) = “cost from the starting node to reach n”
– h(n) = “estimate of the cost of the cheapest path
from n
to the goal node”

h(n
2 )
g(n)
0 1 n
10 5
5
1
5 1
2 8
2 5
3
3
Example

A*: minimize f(n) = g(n) + h(n)


Properties of A*

• A* generates an optimal solution if h(n) is an


admissible heuristic and the search space is a tree:
– h(n) is admissible if it never
overestimates the cost to reach the
destination node
• A* generates an optimal solution if h(n)
is a consistent heuristic and the search
space is a graph:
– h(n) is consistent if for every node n and for every
successor node n’ of n:
h(n) ≤ c(n,n’) + h(n’)

h(n)
C(n,n’) p
n
n’

• If h(n) is consistent then h(n) is admissible


• Frequently when h(n) is admissible, it is also
consistent
Admissible Heuristics
• A heuristic is admissible if it is too
optimistic, estimating the cost to be smaller
than it actually is.

• Example:
In the road map domain,

h(n) = “Euclidean distance to destination”

is admissible as normally cities are not


connected by roads that make straight lines
Example: Admissible Heuristics in 8-
Puzzle Game

• Heuristic: a tile A can be moved to any tile B


– H1(n) = “number of misplaced tiles in board n”

• Heuristic: a tile A can be moved to a tile B if B is


adjacent to A
– H2(n) = “sum of distances of misplaced tiles to
goal positions
in board n”

• Some experimental results reported in Russell &


Norvig (2002):
– A* with h2 performs up to 10 times better than A*
with h1
– A* with h2 performs up to 36,000 times better
than a classical uninformed search algorithm
(iterative deepening)
A* in Games
• Path finding (duh!)
– We will have several presentations on the topic
– We will see that sometimes
even A* speed improvements
are not sufficient
– Additional improvements are required

• A* can be used for planning moves


computer-controlled player (e.g., chess)

F.E.A.R. uses A* to plan its search


CONCLUSION

A-star (A*) is a powerful artificial intelligence algorithm


with many applications. But it is only as effective as its
heuristic function. A* is the most often used pathfinding
algorithm because of its reasonable flexibility. It has
found use in a variety of software systems, including
game creation where characters must navigate through
difficult terrain and obstacles to get to the user, as well
as machine learning and search optimization

You might also like