A.I Notes
A.I Notes
Rationality
Rationality is nothing but status of being reasonable, sensible, and
having good sense of judgment.
The reflex agent of AI directly maps states into action. Whenever these agents fail to
operate in an environment where the state of mapping is too large and not easily
performed by the agent, then the stated problem dissolves and sent to a problem-solving
domain which breaks the large stored problem into the smaller storage area and resolves
one by one. The final integrated action will be the desired outcomes.
1. Breadth-first Search
2. Depth-first Search
Breadth-first Search:
o Breadth-first search is the most common search strategy for traversing a tree or
graph. This algorithm searches breadthwise in a tree or graph, so it is called
breadth-first search.
o BFS algorithm starts searching from the root node of the tree and expands all
successor node at the current level before moving to nodes of next level.
o The breadth-first search algorithm is an example of a general-graph search
algorithm.
o Breadth-first search implemented using FIFO queue data structure.
Advantages:
Disadvantages:
o It requires lots of memory since each level of the tree must be saved into memory
to expand the next level.
o BFS needs lots of time if the solution is far away from the root node.
Depth-first Search
o Depth-first search isa recursive algorithm for traversing a tree or graph data structure.
o It is called the depth-first search because it starts from the root node and follows each
path to its greatest depth node before moving to the next path.
o DFS uses a stack data structure for its implementation.
o The process of the DFS algorithm is similar to the BFS algorithm.
Advantage:
o DFS requires very less memory as it only needs to store a stack of the nodes on
the path from root node to the current node.
o It takes less time to reach to the goal node than BFS algorithm (if it traverses in
the right path).
Disadvantage:
o There is the possibility that many states keep re-occurring, and there is no
guarantee of finding the solution.
o DFS algorithm goes for deep down searching and sometime it may go to the
infinite loop.
1. f(n)= g(n).
Advantages:
o Best first search can switch between BFS and DFS by gaining the advantages of
both the algorithms.
o This algorithm is more efficient than BFS and DFS algorithms.
Disadvantages:
A* Search Algorithm is a simple and efficient search algorithm that can be used to find the
optimal path between two nodes in a graph. It will be used for the shortest path finding. It is an
extension of Dijkstra’s shortest path algorithm (Dijkstra’s Algorithm). The extension here is that,
instead of using a priority queue to store all the elements, we use heaps (binary trees) to store
them. The A* Search Algorithm also uses a heuristic function that provides additional
information regarding how far away from the goal node we are. This function is used in
conjunction with the f-heap data structure in order to make searching more efficient.
Applications of A* Algorithm
The A* algorithm is widely used in various domains for pathfinding and optimization
problems. It has applications in robotics, video games, route planning, logistics, and
artificial intelligence. In robotics, A* helps robots navigate obstacles and find optimal
paths. In video games, it enables NPCs to navigate game environments intelligently.
Route planning applications use A* to find the shortest or fastest routes between
locations. Logistics industries utilize A* for vehicle routing and scheduling. A* is also
employed in AI systems, such as natural language processing and machine learning, to
optimize decision-making processes. Its versatility and efficiency make it a valuable
algorithm in many real-world scenarios.
‘g’ is the distance it takes to get to a certain square on the grid from the starting point,
following the path we generated to get there.
‘h’ is the heuristic, which is the estimation of the distance it takes to get to the finish
line from that square on the grid.
AO* search:
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.
a. First, evaluate the difference between Initial State and final State.
b. Select the various operators which can be applied for each difference.
c. Apply the operator at each difference, which reduces the difference between the
current state and goal state.
Difference between the A* Algorithm and AO*
algorithm
A* algorithm and AO* algorithm both works on the best first search.
They are both informed search and works on given heuristics values.
A* always gives the optimal solution but AO* doesn’t guarantee to give the
optimal solution.
Once AO* got a solution doesn’t explore all possible paths but A* explores
all paths.
When compared to the A* algorithm, the AO* algorithm uses less memory.
opposite to the A* algorithm, the AO* algorithm cannot go into an
endless loop.
o As we have seen in the minimax search algorithm that the number of game states
it has to examine are exponential in depth of the tree. Since we cannot eliminate
the exponent, but we can cut it to half. Hence there is a technique by which
without checking each node of the game tree we can compute the correct
minimax decision, and this technique is called pruning. This involves two
threshold parameter Alpha and beta for future expansion, so it is called alpha-
beta pruning. It is also called as Alpha-Beta Algorithm.
o Alpha-beta pruning can be applied at any depth of a tree, and sometimes it not
only prune the tree leaves but also entire sub-tree.
o The two-parameter can be defined as:
a. Alpha: The best (highest-value) choice we have found so far at any point
along the path of Maximizer. The initial value of alpha is -∞.
b. Beta: The best (lowest-value) choice we have found so far at any point
along the path of Minimizer. The initial value of beta is +∞.
o The Alpha-beta pruning to a standard minimax algorithm returns the same move
as the standard algorithm does, but it removes all the nodes which are not really
affecting the final decision but making algorithm slow. Hence by pruning these
nodes, it makes the algorithm fast.
The main condition which required for alpha-beta pruning is: α>=β
UNIT – II
Inference system
Inference means deriving new sentences from old. Inference system allows us to add a
new sentence to the knowledge base. A sentence is a proposition about the world.
Inference system applies logical rules to the KB to deduce new information.
Inference system generates new facts so that an agent can update the KB. An inference
system works mainly in two rules which are given as:
o Forward chaining
o Backward chaining
1. TELL: This operation tells the knowledge base what it perceives from the
environment.
2. ASK: This operation asks the knowledge base what action it should perform.
3. Perform: It performs the selected action.
2. Logical level:
At this level, we understand that how the knowledge representation of
knowledge is stored. At this level, sentences are encoded into different logics. At
the logical level, an encoding of knowledge into logical sentences occurs. At the
logical level we can expect to the automated taxi agent to reach to the
destination B.
3. Implementation level:
This is the physical representation of logic and knowledge. At the implementation
level agent perform actions as per logical and knowledge level. At this level, an
automated taxi agent actually implement his knowledge and logic so that he can
reach to the destination.
Approaches to designing a knowledge-based
agent:
There are mainly two approaches to build a knowledge-based agent:
Problem Statement:
The Wumpus world is a cave with 16 rooms (4×4). Each room is connected to
others through walkways (no rooms are connected diagonally). The knowledge-
based agent starts from Room[1, 1]. The cave has – some pits, a treasure and
a beast named Wumpus. The Wumpus can not move but eats the one who
enters its room. If the agent enters the pit, it gets stuck there. The goal of the
agent is to take the treasure and come out of the cave. The agent is rewarded,
when the goal conditions are met. The agent is penalized, when it falls into a pit
or being eaten by the Wumpus.
Some elements support the agent to explore the cave, like -The wumpus’s
adjacent rooms are stenchy. -The agent is given one arrow which it can use to
kill the wumpus when facing it (Wumpus screams when it is killed). – The
adjacent rooms of the room with pits are filled with breeze. -The treasure room
is always glittery.
1.
Sensors:
Devices which helps the agent in sensing the following from the
environment.
Breeze
Stench
Glitter
Scream (When the Wumpus is killed)
Bump (when the agent hits a wall)
1. Deductive logic
2. Inductive logic
1) Deductive logic
In deductive logic, the complete evidence is provided about the truth of the
conclusion made. Here, the agent uses specific and accurate premises that lead
to a specific conclusion. An example of this logic can be seen in an expert system
designed to suggest medicines to the patient. The agent gives the complete
proof about the medicines suggested by it, like the particular medicines are
suggested to a person because the person has so and so symptoms.
2) Inductive logic
In Inductive logic, the reasoning is done through a ‘bottom-up’ approach. What
this means is that the agent here takes specific information and then generalizes
it for the sake of complete understanding. An example of this can be seen in the
natural language processing by an agent in which it sums up the words according
to their category, i.e. verb, noun article, etc., and then infers the meaning of that
sentence.