UNIT-2 AI Notes
UNIT-2 AI Notes
UNIT-2 AI Notes
Problem-solving agents
In artificial intelligence, a problem-solving agent refers to a type of intelligent agent designed
to address and solve complex problems or tasks in its environment. These agents are a
fundamental concept in AI and are used in various applications, from game-playing
algorithms to robotics and decision-making systems. Here are some key characteristics and
components of a problem-solving agent:
Uninformed searches rely solely on the given problem definition and operate systematically
to find a solution. Examples of uninformed search algorithms include breadth-first search
(BFS), depth-first search (DFS),uniform-cost search (UCS), depth-limited search ,
and iterative deepening depth-first search. Although all these examples work in a brute force
way, they differ in the way they traverse the nodes.
Breadth-first search
The breadth-first search (BFS) algorithm is commonly used for traversing trees or graphs,
where it explores the neighboring nodes in a breadth-first manner, visiting the nodes at the
same level before moving to the next level. The breadth-first search approach uses a queue to
facilitate its implementation.
Depth-first search
Depth-first search (DFS) is an uninformed search algorithm that helps traverse a tree or
graph using the concept of backtracking. This algorithm traverses all nodes by advancing
along a specific path and uses backtracking when it reaches the end of that path, allowing
exploration of alternative paths. The DFS approach uses a stack to facilitate its
implementation.
Iterative deepening depth first search
Iterative deepening depth-first search (IDDFS) is an algorithm that is an important part of an
Uninformed search strategy just like BFS and DFS. We can define IDDFS as an algorithm of
an amalgam of BFS and DFS searching techniques. In IDDFS, We have found certain
limitations in BFS and DFS so we have done hybridization of both the procedures for
eliminating the demerits lying in them individually. We do a limited depth-first search up to a
fixed “limited depth”. Then we keep on incrementing the depth limit by iterating the
procedure unless we have found the goal node or have traversed the whole tree whichever is
earlier.
2 for d = 0 to infinity:
3 if (DLS(T, d)):
4 return 1
5 else
6 return 0
Bidirectional search
Searching a graph is quite famous problem and have a lot of practical use. We have already
discussed here how to search for a goal vertex starting from a source vertex using BFS. In
normal graph search using BFS/DFS we begin our search in one direction usually from
source vertex toward the goal vertex, but what if we start search from both direction
simultaneously.
Bidirectional search is a graph search algorithm which find smallest path from source to
goal vertex. It runs two simultaneous search –
1. Forward search from source/initial vertex toward goal vertex
2. Backward search from goal/target vertex toward source vertex
Bidirectional search replaces single search graph(which is likely to grow exponentially)
with two smaller sub graphs – one starting from initial vertex and other starting from goal
vertex. The search terminates when two graphs intersect.
Just like A* algorithm, bidirectional search can be guided by a heuristic estimate of
remaining distance from source to goal and vice versa for finding shortest path possible.
Consider following simple example-
It is a handy algorithm that is often used for map traversal to find the shortest path to be
taken. A* was initially designed as a graph traversal problem, to help build a robot that can
find its own course. It still remains a widely popular algorithm for graph traversal.
It searches for shorter paths first, thus making it an optimal and complete algorithm. An
optimal algorithm will find the least cost outcome for a problem, while a complete algorithm
finds all the possible outcomes of a problem.
Another aspect that makes A* so powerful is the use of weighted graphs in its
implementation. A weighted graph uses numbers to represent the cost of taking each path or
course of action. This means that the algorithms can take the path with the least cost, and find
the best route in terms of distance and time.
Best-first search is what the AO* algorithm does. The AO* method divides any given
difficult problem into a smaller group of problems that are then resolved using the AND-
OR graph concept. AND OR graphs are specialized graphs that are used in problems that can
be divided into smaller problems. The AND side of the graph represents a set of tasks that
must be completed to achieve the main goal, while the OR side of the graph represents
different methods for accomplishing the same main goal.
AND-OR Graph
In the above figure, the buying of a car may be broken down into smaller problems or tasks
that can be accomplished to achieve the main goal in the above figure, which is an example
of a simple AND-OR graph. The other task is to either steal a car that will help us accomplish
the main goal or use your own money to purchase a car that will accomplish the main goal.
The AND symbol is used to indicate the AND part of the graphs, which refers to the need
that all subproblems containing the AND to be resolved before the preceding node or issue
may be finished.
The start state and the target state are already known in the
knowledge-based search strategy known as the AO* algorithm, and the best path is
identified by heuristics. The informed search technique considerably reduces the
algorithm’s time complexity. The AO* algorithm is far more effective in searching AND-
OR trees than the A* algorithm.
Working of AO* algorithm:
The evaluation function in AO* looks like this:
f(n) = g(n) + h(n)
f(n) = Actual cost + Estimated cost
here,
f(n) = The actual cost of traversal.
g(n) = the cost from the initial node to the current node.
h(n) = estimated cost from the current node to the goal state.