A I Notes
A I Notes
Artificial Intelligence Artificial Intelligence which is ready to create a new revolution in the
world by making intelligent machines. The Artificial Intelligence is
Unit I: now all around us. It is currently working with a variety of subfields,
ranging from general to specific, such as self-driving cars, playing
Introduction- What is Artificial Intelligence, Foundations of AI, chess, proving theorems, playing music, Painting, etc.
History, AI - Past, Present and Future. Intelligent Agents-
Environments- Specifying the task environment, Properties of task AI is one of the fascinating and universal fields of Computer science
environments, Agent based programs-Structure of Agents, Types of which has a great scope in future. AI holds a tendency to cause a
agents-Simple reflex agents, Model-based reflex agents, Goal-based machine to work as a human.
agents; and Utility-based agents.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Artificial Intelligence exists when a machine can have human based
skills such as learning, reasoning, and solving problems
What is Artificial Intelligence? With Artificial Intelligence you do not need to pre-program a
machine to do some work, despite that you can create a machine
In today's world, technology is growing very fast, and we are getting with programmed algorithms which can work with own intelligence,
in touch with different new technologies day by day. and that is the awesomeness of AI.
Artificial Intelligence Notes Page No: 1
It is believed that AI is not a new technology, and some people says o Playing chess
that as per Greek myth, there were Mechanical men in early days o Plan some surgical operation
which can work and behave like humans. o Driving a car in traffic
5. Creating some system which can exhibit intelligent behavior, learn
new things by itself, demonstrate, explain, and can advise to its user.
Why Artificial Intelligence?
Before Learning about Artificial Intelligence, we should know that What Comprises to Artificial Intelligence?
what is the importance of AI and why should we learn it. Following
Artificial Intelligence is not just a part of computer science even it's
are some main reasons to learn about AI:
so vast and requires lots of other factors which can contribute to it.
o With the help of AI, you can create such software or devices which To create the AI first we should know that how intelligence is
can solve real-world problems very easily and with accuracy such as health composed, so the Intelligence is an intangible part of our brain which
issues, marketing, traffic issues, etc. is a combination of Reasoning, learning, problem-solving
o With the help of AI, you can create your personal virtual Assistant, perception, language understanding, etc.
such as Cortana, Google Assistant, Siri, etc.
o With the help of AI, you can build such Robots which can work in an To achieve the above factors for a machine or software Artificial
environment where survival of humans can be at risk. Intelligence requires the following discipline:
o AI opens a path for other new technologies, new devices, and new
Opportunities. o Mathematics
o Biology
Goals of Artificial Intelligence o Psychology
o Sociology
Following are the main goals of Artificial Intelligence: o Computer Science
o Neurons Study
1. Replicate human intelligence o Statistics
2. Solve Knowledge-intensive tasks
3. An intelligent connection of perception and action
4. Building a machine which can perform tasks that requires human
intelligence such as:
o Proving a theorem
Artificial Intelligence Notes Page No: 2
o Useful as a public utility: AI can be very useful for public utilities
such as a self-driving car which can make our journey safer and hassle-free,
facial recognition for security purpose, Natural language processing to
communicate with the human in human-language, etc.
Every technology has some disadvantages, and the same goes for
Artificial intelligence. Being so advantageous technology still, it has
some disadvantages which we need to keep in our mind while
creating an AI system. Following are the disadvantages of AI:
Advantages of Artificial Intelligence
o High Cost: The hardware and software requirement of AI is very
Following are some main advantages of Artificial Intelligence: costly as it requires lots of maintenance to meet current world
requirements.
o High Accuracy with less errors: AI machines or systems are prone o Can't think out of the box: Even we are making smarter machines
to less errors and high accuracy as it takes decisions as per pre-experience with AI, but still they cannot work out of the box, as the robot will only do
or information. that work for which they are trained, or programmed.
o High-Speed: AI systems can be of very high-speed and fast- o No feelings and emotions: AI machines can be an outstanding
decision making, because of that AI systems can beat a chess champion in performer, but still it does not have the feeling so it cannot make any kind
the Chess game. of emotional attachment with human, and may sometime be harmful for
o High reliability: AI machines are highly reliable and can perform users if the proper care is not taken.
the same action multiple times with high accuracy. o Increase dependency on machines: With the increment of
o Useful for risky areas: AI machines can be helpful in situations such technology, people are getting more dependent on devices and hence they
as defusing a bomb, exploring the ocean floor, where to employ a human are losing their mental capabilities.
can be risky. o No Original Creativity: As humans are so creative and can imagine
o Digital Assistant: AI can be very useful to provide digital assistant some new ideas but still AI machines cannot beat this power of human
to the users such as AI technology is currently used by various E-commerce intelligence and cannot be creative and imaginative.
websites to show the products as per customer requirement.
Simple reflex agents ignore the rest of the percept history and act
only on the basis of the current percept. Percept history is the
history of all that an agent has perceived to date. The agent function
is based on the condition-action rule. A condition-action rule is a
rule that maps a state i.e., a condition to an action. If the condition
is true, then the action is taken, else not. This agent function only
succeeds when the environment is fully observable. For simple reflex
agents operating in partially observable environments, infinite loops
are often unavoidable. It may be possible to escape from infinite
loops if the agent can randomize its actions.
Model-Based Reflex Agents Example: Self-driving cars are a great example of a model-based
reflex agent. The car is equipped with sensors that detect obstacles,
It works by finding a rule whose condition matches the current such as car brake lights in front of them or pedestrians walking on
situation. A model-based agent can handle partially observable the sidewalk. As it drives, these sensors feed percepts into the car's
environments by the use of a model about the world. The agent memory and internal model of its environment.
has to keep track of the internal state which is adjusted by each
percept and that depends on the percept history. The current state Goal-Based Agents
is stored inside the agent which maintains some kind of structure
describing the part of the world which cannot be seen. These kinds of agents take decisions based on how far they are
currently from their goal(description of desirable situations). Their
Updating the state requires information about: every action is intended to reduce their distance from the goal. This
Artificial Intelligence Notes Page No: 7
allows the agent a way to choose among multiple possibilities, Utility-Based Agents
selecting the one which reaches a goal state. The knowledge that
supports its decisions is represented explicitly and can be modified, The agents which are developed having their end uses as building
which makes these agents more flexible. They usually require search blocks are called utility-based agents. When there are multiple
and planning. The goal-based agent’s behavior can easily be possible alternatives, then to decide which one is best, utility-based
changed. agents are used. They choose actions based on a preference
(utility) for each state. Sometimes achieving the desired goal is not
enough. We may look for a quicker, safer, cheaper trip to reach a
destination. Agent happiness should be taken into consideration.
Utility describes how “happy” the agent is. Because of the
uncertainty in the world, a utility agent chooses the action that
maximizes the expected utility. A utility function maps a state onto
a real number which describes the associated degree of happiness.
Goal-Based Agents
Learning Agent
A learning agent in AI is the type of agent that can learn from its
past experiences or it has learning capabilities. It starts to act with
basic knowledge and then is able to act and adapt automatically
through learning. A learning agent has mainly four conceptual
components, which are:
In a homogeneous MAS, all the agents have the same These agents are organized into a hierarchy, with high-level agents
capabilities, goals, and behaviors. overseeing the behavior of lower-level agents. The high-level
In contrast, in a heterogeneous MAS, the agents have agents provide goals and constraints, while the low-level agents
different capabilities, goals, and behaviors. carry out specific tasks. Hierarchical agents are useful in complex
environments with many tasks and sub-tasks.
This can make coordination more challenging but can also lead to
more flexible and robust systems. Hierarchical agents are agents that are organized into a
hierarchy, with high-level agents overseeing the behavior of lower-
Cooperative MAS involves agents working together to achieve a
level agents. The high-level agents provide goals and constraints,
common goal, while competitive MAS involves agents working
while the low-level agents carry out specific tasks. This structure
against each other to achieve their own goals. In some cases, MAS
allows for more efficient and organized decision-making in complex
can also involve both cooperative and competitive behavior, where
environments.
agents must balance their own interests with the interests of the
Hierarchical agents can be implemented in a variety of
group.
applications, including robotics, manufacturing, and transportation
systems. They are particularly useful in environments where there
MAS can be implemented using different techniques, such as game
are many tasks and sub-tasks that need to be coordinated and
theory, machine learning, and agent-based modeling. Game theory
prioritized.
is used to analyze strategic interactions between agents and predict
Artificial Intelligence Notes Page No: 10
In a hierarchical agent system, the high-level agents are Uses of Agents
responsible for setting goals and constraints for the lower-level
agents. These goals and constraints are typically based on the Agents are used in a wide range of applications in artificial
overall objective of the system. For example, in a manufacturing intelligence, including:
system, the high-level agents might set production targets for the
lower-level agents based on customer demand. Robotics: Agents can be used to control robots and
The low-level agents are responsible for carrying out specific automate tasks in manufacturing, transportation, and other
tasks to achieve the goals set by the high-level agents. These tasks industries.
may be relatively simple or more complex, depending on the Smart homes and buildings: Agents can be used to control
specific application. For example, in a transportation system, low- heating, lighting, and other systems in smart homes and buildings,
level agents might be responsible for managing traffic flow at optimizing energy use and improving comfort.
specific intersections. Transportation systems: Agents can be used to manage
Hierarchical agents can be organized into different levels, traffic flow, optimize routes for autonomous vehicles, and improve
depending on the complexity of the system. In a simple system, logistics and supply chain management.
there may be only two levels: high-level agents and low-level Healthcare: Agents can be used to monitor patients, provide
agents. In a more complex system, there may be multiple levels, with personalized treatment plans, and optimize healthcare resource
intermediate-level agents responsible for coordinating the activities allocation.
of lower-level agents. Finance: Agents can be used for automated trading, fraud
One advantage of hierarchical agents is that they allow for detection, and risk management in the financial industry.
more efficient use of resources. By organizing agents into a Games: Agents can be used to create intelligent opponents
hierarchy, it is possible to allocate tasks to the agents that are best in games and simulations, providing a more challenging and
suited to carry them out, while avoiding duplication of effort. This realistic experience for players.
can lead to faster, more efficient decision-making and better overall Natural language processing: Agents can be used for
performance of the system. language translation, question answering, and chatbots that can
communicate with users in natural language.
Overall, hierarchical agents are a powerful tool in artificial Cybersecurity: Agents can be used for intrusion detection,
intelligence that can help solve complex problems and improve malware analysis, and network security.
efficiency in a variety of applications.
The domain of artificial intelligence is huge in breadth and width. Problem-solving agents:
While proceeding, we consider the broadly common and
prospering research areas in the domain of AI – In Artificial Intelligence, Search techniques are universal problem-
solving methods. Rational agents or Problem-solving agents in AI
mostly used these search strategies or algorithms to solve a specific
problem and provide the best result. Problem-solving agents are the
goal-based agents and use atomic representation. In this topic, we
will learn various problem-solving search algorithms.
Informed Search
o Breadth-first search is the most common search strategy for 1. S---> A--->B---->C--->D---->G--->H--->E---->F---->I----
traversing a tree or graph. This algorithm searches breadthwise in a tree or >K
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:
Completeness: BFS is complete, which means if the shallowest goal o There is the possibility that many states keep re-occurring, and
node is at some finite depth, then BFS will find a solution. there is no guarantee of finding the solution.
o DFS algorithm goes for deep down searching and sometime it
Optimality: BFS is optimal if path cost is a non-decreasing function may go to the infinite loop.
of the depth of the node.
Example:
Artificial Intelligence Notes Page No: 17
In the below search tree, we have shown the flow of depth-first It requires lots of memory since each level of the tree must be saved
search, and it will follow the order as: into memory to expand the next level.
Root node--->Left node ----> right node. o BFS needs lots of time if the solution is far away from the root
node.
It will start searching from root node S, and traverse A, then B, then
D and E, after traversing E, it will backtrack the tree as E has no other Example:
successor and still goal node is not found. After backtracking it will
traverse node C and then G, and here it will terminate as it found goal In the below tree structure, we have shown the traversing of the tree
node. using BFS algorithm from the root node S to goal node K. BFS search
algorithm traverse in layers, so it will follow the path which is shown
by the dotted arrow, and the traversed path will be:
1. S---> A--->B---->C--->D---->G--->H--->E---->F---->I----
>K
2. Depth-first Search In the below search tree, we have shown the flow of depth-first
search, and it will follow the order as:
o Depth-first search isa recursive algorithm for traversing a tree
or graph data structure. Root node--->Left node ----> right node.
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 It will start searching from root node S, and traverse A, then B, then
to the next path. D and E, after traversing E, it will backtrack the tree as E has no other
o DFS uses a stack data structure for its implementation. successor and still goal node is not found. After backtracking it will
o The process of the DFS algorithm is similar to the BFS traverse node C and then G, and here it will terminate as it found goal
algorithm. node.
Advantages:
Disadvantages:
Completeness: DLS search algorithm is complete if the solution is
above the depth-limit. o It does not care about the number of steps involve in
searching and only concerned about path cost. Due to which this
ℓ
Time Complexity: Time complexity of DLS algorithm is O(b ). algorithm may be stuck in an infinite loop.
Optimal:
Advantages:
Hence, the worst-case time complexity of Uniform-cost search is
O(b1 + [C*/ε])/. o It combines the benefits of BFS and DFS search algorithm in
terms of fast search and memory efficiency.
Space Complexity:
Disadvantages:
Artificial Intelligence Notes Page No: 22
o The main drawback of IDDFS is that it repeats all the work of Completeness:
the previous phase.
This algorithm is complete is if the branching factor is finite.
Example:
Time Complexity:
Optimal:
Disadvantages:
Example:
In the below search tree, bidirectional search algorithm is applied. Completeness: Bidirectional Search is complete if we use BFS in both
This algorithm divides one graph/tree into two sub-graphs. It starts searches.
traversing from node 1 in the forward direction and starts from goal
node 16 in the backward direction. Time Complexity: Time complexity of bidirectional search using BFS
is O(bd).
The algorithm terminates at node 9 where two searches meet.
Space Complexity: Space complexity of bidirectional search is O(bd).
Advantages:
Advantages:
Step1: Place the starting node in the OPEN list. o It does not always produce the shortest path as it mostly
based on heuristics and approximation.
Step 2: Check if the OPEN list is empty or not, if the list is empty then o A* search algorithm has some complexity issues.
return failure and stops. o The main drawback of A* is memory requirement as it keeps
all generated nodes in the memory, so it is not practical for various
large-scale problems.
Artificial Intelligence Notes Page No: 28
Example:
Points to remember:
=6
Step 2
f(B⇢f) = g(f) + h(f)
f(B⇢f) = 1 + 9
= 10
because B's heuristic value is different from its actual value The
heuristic is
=1+8
Step 3 =4
=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,
f(D⇢J) = 1 + 0
=1
=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.
********