0% found this document useful (0 votes)
360 views33 pages

AI Lab Lab Manual 23 24

This document provides an overview of the Artificial Intelligence lab for semester 5. It outlines the lab objectives which include designing agent architectures, implementing knowledge representation and reasoning, problem solving agents, and reasoning under uncertainty. The lab outcomes are also listed, which are skills students should gain related to implementing search techniques, logic programming, Bayesian networks, and case studies of AI systems. The document then lists 10 experiments covering applications of AI, agent architectures, Prolog programming, search techniques, adversarial search, local search, logical inference, Bayesian networks, and case studies. Details are provided for the first experiment which involves studying different AI applications using the PEAS framework to analyze performance measures, environments, actuators, and sensors. Examples of agents described include

Uploaded by

ANIKET LOHKARE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
360 views33 pages

AI Lab Lab Manual 23 24

This document provides an overview of the Artificial Intelligence lab for semester 5. It outlines the lab objectives which include designing agent architectures, implementing knowledge representation and reasoning, problem solving agents, and reasoning under uncertainty. The lab outcomes are also listed, which are skills students should gain related to implementing search techniques, logic programming, Bayesian networks, and case studies of AI systems. The document then lists 10 experiments covering applications of AI, agent architectures, Prolog programming, search techniques, adversarial search, local search, logical inference, Bayesian networks, and case studies. Details are provided for the first experiment which involves studying different AI applications using the PEAS framework to analyze performance measures, environments, actuators, and sensors. Examples of agents described include

Uploaded by

ANIKET LOHKARE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

Laboratory Manual

Artificial Intelligence Lab


Subject Code: CSL502(C Scheme)

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

 Our strengths are dedicated to impart quality technical education based on a


balanced program of instructions and practical experiences.
 Our strength is to provide value based technical education to develop core
competencies and ethics for overall personality development.
 Our endeavor is to impart in-depth knowledge and versatility to meet the global
challenges.
CSL502 Artificial Intelligence Lab,Sem. – V, AIM

Artificial Intelligence Lab


Semester–V

Lab Objectives:

1. To design suitable Agent Architecture for a given real world AI problem

2 To implement knowledge representation and reasoning in AI language

3 To design a Problem-Solving Agent

4 To incorporate reasoning under uncertainty for an AI agent

Lab Outcomes:

At the end of the course, students will be able to:

1. Identify suitable Agent Architecture for a given real world AI problem

2 Implement simple programs using Prolog.

3 Implement various search techniques for a Problem-Solving Agent.

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

SSJCOE, Sonarpada Page 3


CSL502 Artificial Intelligence Lab,Sem. – V, AIM

Artificial Intelligence Lab


Semester–V

List of experiment

Sr Aim of Experiment Page


No No.
1 Study of different applications of AI which provides peas
description and task environment.
2 Identify suitable agent architecture for the problem
Solving
3 Write the program using PROLOG as an AI programming
Languages
4 Implement any one of the Uninformed search
techniques.
5 Implement any one of the inform search techniques.
6 Implement adversarial search using min-max algorithm.
7 Implement any one of the Local Search techniques. E.g.
Hill Climbing, Simulated Annealing, Genetic algorithm.
8 Prove the goal sentence from the following set of
statements in FOPL by applying forward, backward and
resolution inference algorithms.
9 Create a Bayesian network for the given problem
statement and draw inferences from it.
10 Case study of any existing successful AI system.

SSJCOE, Sonarpada Page 4


CSL502 Artificial Intelligence Lab,Sem. – V, AIM

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

SSJCOE, Sonarpada Page 5


CSL502 Artificial Intelligence Lab,Sem. – V, AIM

Performance
Agent Measure Environment Actuator Sensor

Hospital Patient’s health, Prescription, Symptoms,


Management Admission Hospital, Doctors, Diagnosis, Scan Patient’s
System process, Payment Patients report response

The comfortable
trip, Safety, Steering wheel,
Automated Car Maximum Roads, Traffic, Accelerator, Camera, GPS,
Drive Distance Vehicles Brake, Mirror Odometer

Maximize scores, Classroom, Desk,


Subject Improvement is Chair, Board, Smart displays, Eyes, Ears,
Tutoring students Staff, Students Corrections Notebooks

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

(A) Automated car driving agent


i) Performance measures that which should be satisfied by the automated car driver.

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.

SSJCOE, Sonarpada Page 6


CSL502 Artificial Intelligence Lab,Sem. – V, AIM

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.

B) Part picking ARM robot


i) Performance measures: - number of parts in correct container.
ii) Environment: - conveyor belt used for handling parts, containers used to keep parts, and
parts.
iii) Actuators: - arm with tooltips, to pick and drop parts from one place to another.
iv) Sensors: - camera to scan the position from where part should be picked and joint angle
sensors which are use to sense the obstacles and move in appropriate place.

(C) Medical diagnosis system


i) Performance measures

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.

(D)Soccer player robot


i) Performance: - number of goals, speed legal game.
ii) Environment: team players, opponent team players, playing around, goal net.
iii) Sensors: camera, proximity sensors, infrared sensors

SSJCOE, Sonarpada Page 7


CSL502 Artificial Intelligence Lab,Sem. – V, AIM

iv) Actuators: joint, angles, motors

CONCLUSION: - We have studied different applications of AI which provides PEAS description


and task environment.

SSJCOE, Sonarpada Page 8


CSL502 Artificial Intelligence Lab,Sem. – V, AIM

EXPERIMENT 2

Aim: Identify suitable agent architecture for the problem Solving

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

1. Simple reflex agents

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.

SSJCOE, Sonarpada Page 9


CSL502 Artificial Intelligence Lab,Sem. – V, AIM

2. Model-based reflex agents

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.

SSJCOE, Sonarpada Page 10


CSL502 Artificial Intelligence Lab,Sem. – V, AIM

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.

SSJCOE, Sonarpada Page 11


CSL502 Artificial Intelligence Lab,Sem. – V, AIM

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.

SSJCOE, Sonarpada Page 12


CSL502 Artificial Intelligence Lab,Sem. – V, AIM

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:

The applications of prolog are as follows:

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

SSJCOE, Sonarpada Page 13


CSL502 Artificial Intelligence Lab,Sem. – V, AIM

Code:-

Output:-

Conclusion: - From this experiment we have study that how PROLOG is used in AI.

SSJCOE, Sonarpada Page 14


CSL502 Artificial Intelligence Lab,Sem. – V, AIM

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.

SSJCOE, Sonarpada Page 15


CSL502 Artificial Intelligence Lab,Sem. – V, AIM

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 :-

SSJCOE, Sonarpada Page 16


CSL502 Artificial Intelligence Lab,Sem. – V, AIML

Output: -

SSJCOE, Sonarpada Page 17


CSL502 Artificial Intelligence Lab,Sem. – V, AIML

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.

SSJCOE, Sonarpada Page 18


CSL502 Artificial Intelligence Lab,Sem. – V, AIML

Code :-

SSJCOE, Sonarpada Page 19


CSL502 Artificial Intelligence Lab,Sem. – V, AIML

SSJCOE, Sonarpada Page 20


CSL502 Artificial Intelligence Lab,Sem. – V, AIML

Output :-

SSJCOE, Sonarpada Page 21


CSL502 Artificial Intelligence Lab,Sem. – V, AIML

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.

SSJCOE, Sonarpada Page 22


CSL502 Artificial Intelligence Lab,Sem. – V, AIML

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.

SSJCOE, Sonarpada Page 23


CSL502 Artificial Intelligence Lab,Sem. – V, AIML

Code:

SSJCOE, Sonarpada Page 24


CSL502 Artificial Intelligence Lab,Sem. – V, AIML

SSJCOE, Sonarpada Page 25


CSL502 Artificial Intelligence Lab,Sem. – V, AIML

SSJCOE, Sonarpada Page 26


CSL502 Artificial Intelligence Lab,Sem. – V, AIML

Output:

Conclusion:- In this experiment we have studied genetic algorithm local search techniques.

SSJCOE, Sonarpada Page 27


CSL502 Artificial Intelligence Lab,Sem. – V, AIML

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.

Steps for Resolution:


1. Conversion of facts into first-order logic.
2. Convert FOL statements into CNF

3. Negate the statement which needs to prove (proof by contradiction)

4. Draw resolution graph (unification).

To better understand all the above steps, we will take an example in which we will apply
resolution.

SSJCOE, Sonarpada Page 28


CSL502 Artificial Intelligence Lab,Sem. – V, AIML

Conclusion: From this experiment we are studying how resolution works in AI.

SSJCOE, Sonarpada Page 29


CSL502 Artificial Intelligence Lab,Sem. – V, AIML

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.

SSJCOE, Sonarpada Page 30


CSL502 Artificial Intelligence Lab,Sem. – V, AIML

Conclusion: from this experiment they are study what is Bayesian network in AI

SSJCOE, Sonarpada Page 31


CSL502 Artificial Intelligence Lab,Sem. – V, AIML

EXPERIMENT 10
Aim: Case study of any existing successful AI system.
Theory: SAMPLE CASE STUDY

Face recognition is a technology capable of identifying or verifying a subject


through an image, video, or any audiovisual element of his face. Generally, this
identification is used to access an application, system, or service. It is a method
of biometric identification that uses that body measures, in this case, face and
head, to verify the identity of a person through its facial biometric pattern and data.
The technology collects a set of unique biometric data of each person associated
with their face and facial expression to identify, verify and/or authenticate a
person. The procedure simply requires any device that has digital photographic
technology to generate and obtain the images and data necessary to create and
record the biometric facial pattern of the person that needs to be identified.

Unlike other identification solutions such as passwords, verification by email,


selfies or images, or fingerprint identification, Biometric facial recognition uses
unique mathematical and dynamic patterns that make this system one of the
safest and most effective ones.

How face recognition works?

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.

SSJCOE, Sonarpada Page 32


CSL502 Artificial Intelligence Lab,Sem. – V, AIML

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

SSJCOE, Sonarpada Page 33

You might also like