AI Lab Lab Manual 23 24
AI Lab Lab Manual 23 24
Semester–V
Prepared by
Prof. Sanket Singhania
Department of AIML
Shivajirao S. Jondhale College of Engineering, Dombivli(E)
Affiliated to University of Mumbai
Shivajirao S Jondhale College of Engineering, Dombivli(E)
Affiliated to University of Mumbai
VISION
To impart quality technical education for creating competent and ethically strong
professionals with capabilities of accepting new challenges.
MISSION
Lab Objectives:
Lab Outcomes:
4 Represent natural language description as statements in Logic and apply inference rules to it.
5 Construct a Bayesian Belief Network for a given problem and draw probabilistic inferences
from it
List of experiment
Experiment No. 1
EXPERIMENT 1
Aim: - Study of different applications of AI which provides peas description and task environment.
Theory:-
We know that there are different types of agents in AI. PEAS System is used to categorize similar
agents together. The PEAS system delivers the performance measure with respect to the
environment, actuators, and sensors of the respective agent. Most of the highest performing agents
are Rational Agents.
Rational Agent: The rational agent considers all possibilities and chooses to perform a highly
efficient action. For example, it chooses the shortest path with low cost for high
efficiency. PEAS stands for a Performance measure, Environment, Actuator, Sensor.
1. Performance Measure: Performance measure is the unit to define the success of an agent.
Performance varies with agents based on their different precepts.
2. Environment: Environment is the surrounding of an agent at every instant. It keeps changing
with time if the agent is set in motion. There are 5 major types of environments:
Fully Observable & Partially Observable
Episodic & Sequential
Static & Dynamic
Discrete & Continuous
Deterministic & Stochastic
3. Actuator: An actuator is a part of the agent that delivers the output of action to the environment.
4. Sensor: Sensors are the receptive parts of an agent that takes in the input for the agent
Performance
Agent Measure Environment Actuator Sensor
The comfortable
trip, Safety, Steering wheel,
Automated Car Maximum Roads, Traffic, Accelerator, Camera, GPS,
Drive Distance Vehicles Brake, Mirror Odometer
Part-picking Percentage of parts Conveyor belt with Jointed arms and Camera, joint
robot in correct bins parts; bins hand angle sensors
camera
proximity
Soccer player number of parts in joint, angles, sensors infrared
robot correct container team players motors sensors
Safety: Automated system should be able to drive the car safely without
dashing anywhere.
Optimum speed: Automated system should be able to maintain the optimal
speed depending upon the surroundings.
Comfortable journey: Automated system should be able to give a
comfortable journey to the end user i.e. depending upon the road it should
ensure the comfort of the end user.
Maximize profits: Automated system should provide good mileage on
various rows the amount of energy consumed to automate the system should
not be very high etc. such features ensures that the user is benefited with the
automated features of the system and it can be useful for maximizing the
profits.
ii) Environment
Roads: - automated car drivers should be able to drive on any kind of roads ranging
from city to highway.
Traffic conditions: - You will find different set of traffic condition for different type
of roads. Automated systems should be able to drive efficiently in all types of traffic
condition. Sometimes traffic condition are formed because of pedestrians, animals,
etc.
Clients: - Automated cars are created depending on the client’s environment. For
example in some countries you will see left hand drive and in some countries there
is a right hand drive. Every country or state can have different weather condition.
Depending upon such constraints automated car drivers should be designed.
iii) Actuators: - are responsible for performing actions or providing output to an
environment. In case of car driving agent following are the actuators :
1. Steering wheel which can be used to direct a car in desired direction that is right
or left.
2. Accelerator, gear, etc. can be useful to increase or decrease the speed of the car.
3. Brake is used to stop the car.
4. Light signal, horn can be very useful as indicators for an automated car.
iv) Sensors: - To take input from environment in car driving example cameras, sonar
system, speedometer, GPS, engine sensors, etc. are used as sensors.
Healthy patients: - System should make use of sterilized instruments to ensure the safety
(healthiness) of the patient
Minimize cost: - the automated system results should not be very costly otherwise overall
expenses of the patient may increase, lawsuits. Medical diagnosis system should be legal.
ii) Environment: - patient, doctors, hospital environment.
iii) Sensors: - screen, printer.
iv) Actuators: - keyboard and mouse which is useful to make entry of symptoms, findings,
patient’s answers to given questions. Scanner to scan the reports, camera to click pictures of
patients.
EXPERIMENT 2
Theory:
Artificial intelligence is defined as the study of rational agents. A rational agent could be anything
that makes decisions, as a person, firm, machine, or software. It carries out an action with the best
outcome after considering past and current percepts(agent’s perceptual inputs at a given
instance). An AI system is composed of an agent and its environment. The agents act in their
environment. The environment may contain other agents.
Agents can be grouped into five classes based on their degree of perceived intelligence and
capability
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,
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.
It works by finding a rule whose condition matches the current situation. A model-based agent can
handle partially observable environments by the use of a model about the world. The agent has
to keep track of the internal state which is adjusted by each percept and that depends on the
percept history.
3. Goal-based agents
These kinds of agents take decisions based on how far they are currently from their goal
(description of desirable situations). Their every action is intended to reduce its distance from the
goal. This allows the agent a way to choose among multiple possibilities, selecting the one which
reaches a goal state. The knowledge that supports its decisions is represented explicitly and can
be modified, which makes these agents more flexible. They usually require search and planning.
The goal-based agent’s behavior can easily be changed.
4. 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.
5. Utility-based agents
The agents which are developed having their end uses as building blocks are called utility-based
agents. When there are multiple possible alternatives, then to decide which one is best, utility-
based 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.
Conclusion: We have studied that how to identify suitable architecture from all types of agents for
problem.
EXPERIMENT 3
Aim: Write the program using PROLOG as an AI programming Languages
Theory:
Prolog is a logic programming language. It has important role in artificial intelligence. Unlike
many other programming languages, Prolog is intended primarily as a declarative programming
language. In prolog, logic is expressed as relations (called as Facts and Rules). Core heart of prolog
lies at the logic being applied. Formulation or Computation is carried out by running a query over
these relations.
Prolog stands for programming in logic. In the logic programming paradigm, prolog language is
most widely available. Prolog is a declarative language, which means that a program consists of data
based on the facts and rules (Logical relationship) rather than computing how to find a solution. A
logical relationship describes the relationships which hold for the given application.
Applications of Prolog:
o Specification Language
o Robot Planning
o Natural language understanding
o Machine Learning
o Problem Solving
o Intelligent Database retrieval
o Expert System
o Automated Reasoning
Code:-
Output:-
Conclusion: - From this experiment we have study that how PROLOG is used in AI.
EXPERIMENT 4
Aim: - Implement any one of the Uninformed search techniques.
Theory: - Uninformed search is a class of general-purpose search algorithms which operates in
brute force-way. Uninformed search algorithms do not have additional information about state or
search space other than how to traverse the tree, so it is also called blind search.
Following are the various types of uninformed search algorithms:
⦁ Breadth-first Search
⦁ Depth-first Search
⦁ Depth-limited Search
⦁ Iterative deepening depth-first search
⦁ Uniform cost search
⦁ Bidirectional Search
Breadth-first Search:
⦁ 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.
⦁ 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.
⦁ The breadth-first search algorithm is an example of a general-graph search algorithm.
Advantages:
⦁ BFS will provide a solution if any solution exists.
⦁ If there are more than one solutions for a given problem, then BFS will provide the
minimal solution which requires the least number of steps.
Disadvantages:
⦁ It requires lots of memory since each level of the tree must be saved into memory to
expand the next level.
⦁ BFS needs lots of time if the solution is far away from the root node.
Example:
in the following graph, we start traversal from vertex 2. When we come to vertex 0, we look for
all adjacent vertices of it. 2 is also an adjacent vertex of 0. If we don’t mark visited vertices, then
2 will be processed again and it will become a non-terminating process. A Breadth First Traversal
of the following graph is 2, 0, 3, 1.
Conclusion: - In this experiment we are study how many types are there in Uninformed Search
technique & how BFS (Breadth-First-Search) is working in AI.
Code :-
Output: -
EXPERIMENT 5
Aim: - Implement any one of the inform search techniques.
Theory:- Informed Search algorithms have information on the goal state which helps in more
efficient searching. This information is obtained by a function that estimates how close a state
is to the goal state. Example: A* algorithm for 8 puzzle problem.
A* Search algorithm is one of the best and popular technique used in path-finding and graph
traversals.
Why A* Search Algorithm?
Informally speaking, A* Search algorithms, unlike other traversal techniques, it has “brains”.
What it means is that it is really a smart algorithm which separates it from the other
conventional algorithms. This fact is cleared in detail in below sections.
And it is also worth mentioning that many games and web-based maps use this algorithm to
find the shortest path very efficiently (approximation).
We have introduced Branch and Bound and discussed the 0/1 Knapsack problem in the below
posts.
Branch and Bound | Set 1 (Introduction with 0/1 Knapsack)
Branch and Bound | Set 2 (Implementation of 0/1 Knapsack)
In this puzzle solution of the 8 puzzle problem is discussed.
Given a 3×3 board with 8 tiles (every tile has one number from 1 to 8) and one empty space.
The objective is to place the numbers on tiles to match the final configuration using the empty
space. We can slide four adjacent (left, right, above, and below) tiles into the empty space.
For example,
Conclusion:- From this experiment we are study how inform search works and how A* algorithm working in
AI.
Code :-
Output :-
EXPERIMENT 6
Aim: - Implement adversarial search using min-max algorithm.
Theory: -
Minimax is a recursive algorithm which is used to choose an optimal move for a player
assuming that the other player is also playing optimally.
It is used in games such as tic-tac-toe, go, chess, Isola, checkers, and many other two-
player games.
Such games are called games of perfect information because it is possible to see all
the possible moves of a particular game.
Let us combine what we have learnt so far about minimax and evaluation function to
write a proper Tic-Tac-Toe AI (Artificial Intelligence) that plays a perfect game. This
AI will consider all possible scenarios and makes the most optimal move.
Finding the Best Move :
We shall be introducing a new function called findBestMove(). This function evaluates
all the available moves using minimax() and then returns the best move the maximizer
can make.
Checking for GameOver state :
To check whether the game is over and to make sure there are no moves left we use
isMovesLeft() function. It is a simple straightforward function which checks whether
a move is available or not and returns true or false respectively.
Making our AI smarter :
One final step is to make our AI a little bit smarter. Even though the following AI
plays perfectly, it might choose to make a move which will result in a slower victory
or a faster loss. Lets take an example and explain it.
Conclusion: - From this experiment we are studied that how min-max algorithm works
for any games in AI.
EXPERIMENT 7
Aim:- Implement any one of the Local Search techniques. E.g. Hill Climbing,
Simulated Annealing, Genetic algorithm.
Theory:-
Genetic Algorithms(GAs) are adaptive heuristic search algorithms that belong to the
larger part of evolutionary algorithms. Genetic algorithms are based on the ideas of
natural selection and genetics. These are intelligent exploitation of random search
provided with historical data to direct the search into the region of better performance
in solution space. They are commonly used to generate high-quality solutions for
optimization problems and search problems.
Genetic algorithms simulate the process of natural selection which means those
species who can adapt to changes in their environment are able to survive and
reproduce and go to next generation. In simple words, they simulate “survival of the
fittest” among individual of consecutive generation for solving a problem. Each
generation consist of a population of individuals and each individual represents a
point in search space and possible solution. Each individual is represented as a string
of character/integer/float/bits. This string is analogous to the Chromosome.
Code:
Output:
Conclusion:- In this experiment we have studied genetic algorithm local search techniques.
EXPERIMENT 8
Aim: Prove the goal sentence from the following set of statements in FOPL by
applying forward, backward and resolution inference algorithms.
Theory:
Resolution is a theorem proving technique that proceeds by building refutation proofs, i.e.,
proofs by contradictions. It was invented by a Mathematician John Alan Robinson in the
year 1965.
Resolution is used, if there are various statements are given, and we need to prove a
conclusion of those statements. Unification is a key concept in proofs by resolutions.
Resolution is a single inference rule which can efficiently operate on the conjunctive
normal form or clausal form.
To better understand all the above steps, we will take an example in which we will apply
resolution.
Conclusion: From this experiment we are studying how resolution works in AI.
EXPERIMENT 9
Aim: Create a Bayesian network for the given problem statement and draw
inferences from it.
Theory:
Bayesian belief network is key computer technology for dealing with probabilistic events
and to solve a problem which has uncertainty. We can define a Bayesian network as:
"A Bayesian network is a probabilistic graphical model which represents a set of variables
and their conditional dependencies using a directed acyclic graph."
It is also called a Bayes network, belief network, decision network, or Bayesian model.
Bayesian networks are probabilistic, because these networks are built from a probability
distribution, and also use probability theory for prediction and anomaly detection.
Real world applications are probabilistic in nature, and to represent the relationship
between multiple events, we need a Bayesian network. It can also be used in various tasks
including prediction, anomaly detection, diagnostics, automated insight, reasoning,
time series prediction, and decision making under uncertainty.
Problem:
Calculate the probability that alarm has sounded, but there is neither a burglary, nor
an earthquake occurred, and David and Sophia both called the Harry.
Conclusion: from this experiment they are study what is Bayesian network in AI
EXPERIMENT 10
Aim: Case study of any existing successful AI system.
Theory: SAMPLE CASE STUDY
You might be good at recognizing faces. You probably find it a cinch to identify the
face of a family member, friend, or acquaintance. You’re familiar with their facial
features — their eyes, nose, mouth — and how they come together.
That’s how a facial recognition system works, but on a grand, algorithmic scale.
Where you see a face, recognition technology sees data. That data can be stored
and accessed.
Conclusion: From this case study we are study face recognition is working in AI.
Tip for AI exp 10 : select your own Topic for Case study