Lp-Ii (Ai CC)
Lp-Ii (Ai CC)
AIM: Aim of this practical is to develop DFS and BFS algorithm programs in programming
language.
1. To study BFS
2. To study DFS
3. To apply algorithmic logic in implementation of program.
1. 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.
Breadth-first search implemented using FIFO queue data structure.
Page 1 of 6
In the above tree structure, we have shown the traversing of the tree 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:
Time Complexity: Time Complexity of BFS algorithm can be obtained by the number of nodes
traversed in BFS until the shallowest Node. Where the d= depth of shallowest solution and b is a
node at every state.
T (b) = 1+b2+b3+. + bd= O (bd)
Space Complexity: Space complexity of BFS algorithm is given by the Memory size of frontier
which is O(bd).
Completeness: BFS is complete, which means if the shallowest goal node is at some finite
depth, then BFS will find a solution.
Optimality: BFS is optimal if path cost is a non-decreasing function of the depth of the node.
Algorithm:
1. Pick any node, visit the adjacent unvisited vertex, mark it as visited, display it, and
insert it in a queue.
2. If there are no remaining adjacent vertices left, remove the first vertex from the queue.
3. Repeat step 1 and step 2 until the queue is empty or the desired node is found.
Program:
graph = {
'A' : ['B','C'],
'B' : ['D', 'E'],
'C' : ['F'],
'D' : [],
'E' : ['F'],
'F' : []
}
visited = [] # List to keep track of visited nodes.
queue = [] #Initialize a queue
Page 2 of 6
visited.append(neighbour)
queue.append(neighbour)
# Driver Code
print("Following is the Path using Breadth-First Search")
bfs(visited, graph, 'A')
Output:
Following is the Path using Breadth-First Search
ABCDEF
2. Depth-first Search:
Depth-first search isa recursive algorithm for traversing a tree or graph data structure.
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.
DFS uses a stack data structure for its implementation.
The process of the DFS algorithm is similar to the BFS algorithm.
Example: In the below search tree, we have shown the flow of depth-first search, and it will
follow the order as:
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 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 node.
Page 3 of 6
Completeness: DFS search algorithm is complete within finite state space as it will expand every
node within a limited search tree.
Time Complexity: Time complexity of DFS will be equivalent to the node traversed by the
algorithm. It is given by:
Where, m= maximum depth of any node and this can be much larger than d (Shallowest
solution depth)
Space Complexity: DFS algorithm needs to store only single path from the root node, hence
space complexity of DFS is equivalent to the size of the fringe set, which is O(bm).
Optimal: DFS search algorithm is non-optimal, as it may generate a large number of steps or high cost to
reach to the goal node.
Algorithm:
1. We will start by putting any one of the graph's vertex on top of the stack.
2. After that take the top item of the stack and add it to the visited list of the vertex.
3. Next, create a list of that adjacent node of the vertex. Add the ones which aren't in the visited
list of vertexes to the top of the stack.
4. Lastly, keep repeating steps 2 and 3 until the stack is empty.
Program:
Page 4 of 6
# Using a Python dictionary to act as an adjacency list
graph = {
'A' : ['B','C'],
'B' : ['D', 'E'],
'C' : ['F'],
'D' : [],
'E' : ['F'],
'F' : []
}
# Driver Code
print("Following is the Path using Depth-First Search")
dfs(visited, graph, 'A')
Output:
Following is the Path using Depth-First Search
A
B
D
E
F
C
Conclusion: Thus we have studied BFS & DFS algorithm in detail and implemented using recursive
function.
Page 5 of 6
TITLE: Implement A* Algorithm for any game search problem
AIM: Aim of this practical is to apply algorithmic logic for any game
1. To study A* algorithm
2. To study different game search problems
3. To determine performance A* algorithm in various games
MOTIVATION: To approximate the shortest path in real-life situations, like- in maps, games
where there can be many hindrances.
INTRODUCTION
A* Search Algorithm:
A* Search algorithm is one of the best and popular technique used in path-finding and
graph traversals. 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). Consider a square grid having many obstacles and we are given a starting cell
and a target cell. We want to reach the target cell (if possible) from the starting cell as quickly as
possible. Here A* Search Algorithm comes to the rescue. What A* Search Algorithm does is that
at each step it picks the node according to a value-‘f’ which is a parameter equal to the sum of
two other parameters – ‘g’ and ‘h’. At each step it picks the node/cell having the lowest ‘f’, and
process that node/cell. We define ‘g’ and ‘h’ as simply as possible below
g = the movement cost to move from the starting point to a given square on the grid,
following the path generated to get there.
h = the estimated movement cost to move from that given square on the grid to the final
destination. This is often referred to as the heuristic, which is nothing but a kind of smart guess.
We really don’t know the actual distance until we find the path, because all sorts of things can be
in the way (walls, water, etc.). There can be many ways to calculate this ‘h’ which are discussed
in the later sections.
Page 2 of 7
Algorithm
We create two lists – Open List and Closed List (just like Dijkstra Algorithm)
// A* Search Algorithm
1. Initialize the open list
2. Initialize the closed list
put the starting node on the open
list (you can leave its f at zero)
Page 3 of 7
successor is in the OPEN list which has a
lower f than successor, skip this successor
So suppose as in the below figure if we want to reach the target cell from the source cell, then the A*
Search algorithm would follow path as shown below. Note that the below figure is made by
considering Euclidean Distance as a heuristics.
Page 4 of 7
Heuristics:
We can calculate g but how to calculate h ?
A) Either calculate the exact value of h (which is certainly time
consuming). OR
B) Approximate the value of h using some heuristics (less time consuming).
A) Exact Heuristics –
We can find exact values of h, but that is generally very time consuming.
Below are some of the methods to calculate the exact value of h.
1) Pre-compute the distance between each pair of cells before running the A* Search Algorithm.
2) If there are no blocked cells/obstacles then we can just find the exact value of h without any
pre-computation using the distance formula/Euclidean Distance
B) Approximation Heuristics –
There are generally three approximation heuristics to calculate h –
1) Manhattan Distance – It is nothing but the sum of absolute values of differences in the
goal’s x and y coordinates and the current cell’s x and y coordinates respectively, i.e.,
h = abs (current_cell.x – goal.x)
+ abs (current_cell.y – goal.y)
When to use this heuristic? – When we are allowed to move only in four directions only (right,
left, top, bottom)
The Manhattan Distance Heuristics is shown by the below figure (assume red spot as source cell
and green spot as target cell).
Page 5 of 7
2) Diagonal Distance-
It is nothing but the maximum of absolute values of differences in the goal’s x and y coordinates
and the current cell’s x and y coordinates respectively, i.e.,
dx = abs(current_cell.x –
goal.x) dy = abs(current_cell.y
– goal.y)
When to use this heuristic? – When we are allowed to move in eight directions only (similar to a
move of a King in Chess)
The Diagonal Distance Heuristics is shown by the below figure (assume red spot as source cell
and green spot as target cell).
3) Euclidean Distance-
As it is clear from its name, it is nothing but the distance between the current cell and the goal
cell using the distance formula
h = sqrt ( (current_cell.x – goal.x)2 +
(current_cell.y – goal.y)2 )
When to use this heuristic? – When we are allowed to move in any directions.
The Euclidean Distance Heuristics is shown by the below figure (assume red spot as source cell
and green spot as target cell).
Page 6 of 7
Implementation:
We can use any data structure to implement open list and closed list but for best
performance, we use a set data structure of C++ STL(implemented as Red-Black Tree)
and a boolean hash table for a closed list.
The implementations are similar to Dijsktra’s algorithm. If we use a Fibonacci heap to
implement the open list instead of a binary heap/self-balancing tree, then the
performance will become better (as Fibonacci heap takes O(1) average time to insert
into open list and to decrease key)
Page 7 of 7
Laboratory Practice II Third Year Computer Engineering
Assignment No: 3
1. Title of Assignment:
Implement Greedy search algorithm for Selection Sort.
2. Prerequisite:
Basic knowledge of Greedy algorithm and Sorting concept.
3. Objective:
In this experiment, we will be able to do the following:
● Study how selection sort works under greedy search algorithm.
4. Outcome: Successfully able to sort , unsorted list of numbers.
5. Software and Hardware Requirement:
Open Source C++ Programming tool like G++/GCC, python,java and Ubuntu.
6. Relevant Theory / Literature Survey:
In Selection Sort, we take the simplest, most intuitive approach to sort an array. Choose the
smallest number, place it in the first position. Then choose the next smallest number out of
the remaining elements, and place it in the second position and so on till the end.
Intuition Behind the Algorithm
1
Laboratory Practice II Third Year Computer Engineering
We will perform N-1 iterations on the array (N is the number of elements in the array). In
iteration i (1≤i≤N-1):
● We will traverse the array from the ith index to the end and find the smallest
number among these elements. Note that if there are two smallest elements of the
same value, we choose the one with the lower index.
● We will swap this smallest element with the ith element.
● Hence at the end of the ith iteration, we have found the ith smallest number,
and placed it at the ith position in the array.
In the (N-1)th iteration, we will place the (N-1)th smallest element, which is the 2nd largest
element in the array, at the second last position. This will leave us with one element which
would already be at its correct place.This completes our sorting! Selection Sort Algorithm.
2
Laboratory Practice II Third Year Computer Engineering
● To complete one iteration, we traverse a part of the array (from index i to the end)
exactly once (while keeping track of the smallest element encountered so far). Since
the longest length we ever traverse in any given iteration is N (in the first iteration
when i=1 -> from first to last element), time complexity of completing one iteration
is O(N).
● In Selection Sort, we run N iterations, each of which takes O(N) time. Hence
overall time complexity becomes O(N*N).
● Note that even if the array is fully sorted initially, Selection Sort will take O(N^2)
time to complete, just as it will take for a reverse sorted or randomly sorted array.
3
Laboratory Practice II Third Year Computer Engineering
7. Questions:
Q 1: What is the time and space complexity of selection sort?
Q 2: If an array is [6,1,9,10] , sort the list by selection sort, step wise.
Q 3: What is the maximum number of comparisons in one iteration for an array of size N?
Q 4: Draw Comparison chart with other sorting techniques with respect to time and space
complexity.
Q 5: What is a Stable Sort Algorithm? whether selection sort is a stable algorithm?
8. Conclusion:
In This way we have studied how to sort , unsorted list of numbers using selection sort.
4
TITLE: Implement a solution for a Constraint Satisfaction Problem using Branch and Bound and
Backtracking for n-queens problem or a graph coloring problem
AIM: To use Branch & Bound and Backtracking to solve CSP & n-queens or graph coloring
problem.
Theory:
Constraint Satisfaction Problems:
The objective of every problem-solving technique is one, i.e., to find a solution to reach
the goal. Although, in adversarial search and local search, there were no constraints on the agents
while solving the problems and reaching to its solutions. By the name, it is understood that
constraint satisfaction means solving a problem under certain constraints or rules.
Constraint satisfaction is a technique where a problem is solved when its values satisfy
certain constraints or rules of the problem. Such type of technique leads to a deeper
understanding of the problem structure as well as its complexity.
Constraint satisfaction depends on three components, namely:
X: It is a set of variables.
D: It is a set of domains where the variables reside. There is a specific domain for each variable.
C: It is a set of constraints which are followed by the set of variables.
In constraint satisfaction, domains are the spaces where the variables reside, following the
problem specific constraints. These are the three main elements of a constraint satisfaction
technique. The constraint value consists of a pair of {scope, rel}. The scope is a tuple of
variables which participate in the constraint and rel is a relation which includes a list of values
which the variables can take to satisfy the constraints of the problem.
Page 2 of 6
CSP Problems:
Constraint satisfaction includes those problems which contains some constraints while solving
the problem. CSP includes the following problems:
Graph Coloring: The problem where the constraint is that no adjacent sides can have the same
color.
n-queen problem: In n-queen problem, the constraint is that no queen should be placed either
diagonally, in the same row or column. The N Queen is the problem of placing N chess
queens on an N×N chessboard so that no two queens attack each other.
Page 3 of 6
1) Start in the leftmost column
Page 4 of 6
2) If all queens are
placed return true
3) Try all rows in the current
column. Do following for every
tried row.
a) If the queen can be placed safely in this
row then mark this [row, column] as part
of the solution and recursively check if
placing queen here leads to a solution.
b) If placing the queen in [row, column]
leads to a solution then return true.
c) If placing queen doesn't lead to a solution
then unmark this [row, column] (Backtrack)
and go to step (a) to try other rows.
3) If all rows have been tried and nothing
worked, return false to trigger
backtracking.
Page 5 of 6
1. For the 1st Queen, there are total 8 possibilities as we can place 1st Queen in any row of first
column. Let’s place Queen 1 on row 3.
2. After placing 1st Queen, there are 7 possibilities left for the 2nd Queen. But wait, we don’t
really have 7 possibilities. We cannot place Queen 2 on rows 2, 3 or 4 as those cells are
under attack from Queen 1. So, Queen 2 has only 8 – 3 = 5 valid positions left.
3. After picking a position for Queen 2, Queen 3 has even fewer options as most of the cells in
its column are under attack from the first 2 Queens.
We need to figure out an efficient way of keeping track of which cells are under attack. In
previous solution we kept an 8--by--8 Boolean matrix and update it each time we placed a
queen, but that required linear time to update as we need to check for safe cells.
Basically, we have to ensure 4 things:
1. No two queens share a column.
2. No two queens share a row.
3. No two queens share a top-right to left-bottom diagonal.
4. No two queens share a top-left to bottom-right diagonal.
Number 1 is automatic because of the way we store the solution. For number 2, 3 and 4,
we can perform updates in O(1) time. The idea is to keep three Boolean arrays that tell us
which rows and which diagonals are occupied.
Let’s do some pre-processing first. Let’s create two N x N matrix one for / diagonal and
other one for \ diagonal. Let’s call them slashCode and backslashCode respectively. The trick is
to fill them in such a way that two queens sharing a same /-diagonal will have the same value in
Page 6 of 6
matrix slashCode, and if they share same \-diagonal, they will have the same value in
backslashCode matrix.
For an N x N matrix, fill slashCode and backslashCode matrix using below formula – slashCode[row]
[col] = row + col
backslashCode[row][col] = row – col + (N-1)
The ‘N – 1’ in the backslash code is there to ensure that the codes are never negative
because we will be using the codes as indices in an array.
Now before we place queen i on row j, we first check whether row j is used (use an array
to store row info). Then we check whether slash code ( j + i ) or backslash code ( j – i + 7 ) are
used (keep two arrays that will tell us which diagonals are occupied). If yes, then we have to try
a different location for queen i. If not, then we mark the row and the two diagonals as used and
recurse on queen i + 1. After the recursive call returns and before we try another position for
queen i, we need to reset the row, slash code and backslash code as unused again
Conclusion: Thus we have studied how to solve n-queen (Constraint Satisfaction Problem) using
Backtracking and Branch & Bound.
Page 7 of 6
TITLE: Develop an elementary chatbot for any suitable customer interaction application
Theory:
Chatbots:
A chatbot can be defined as a computer program that converses with users over the
internet as any human would with natural language and sentiments. It is a program or piece of
software that automatically responds to messages sent over a website chatbox, email, social
media messaging app, or text.
For a deeper understanding of Chatbot, we can define it as a computer program that
impersonates human conversations in its natural format, which may include text (since the
advent of bots) or spoken language using artificial intelligence (AI) techniques such as Natural
Language Processing (NLP) and audio analysis. One of the primary aspects of an AI-based bot is
that it is dynamic.
A chatbot is a smart application that reduces human work and helps an organization to
solve basic queries of the customer. Today most of the companies, business from different sector
makes use of chatbot in a different way to reply their customer as fast as possible. chatbots also
help in increasing traffic of site which is top reason of business to use chatbots.
Chatbot asks for basic information of customers like name, email address, and the query.
If a query is simple like product fault, booking mistake, need some information then without any
human connection it can solve it automatically and If some problem is high then It passes the
details to the human head and helps customer to connect with organization manager easily. And
most of the customers like to deal and talk with a chatbot.
How do the Chatbots function?
The main technology that lies behind chatbots is NLP and Machine Learning.
When a question is presented to a chatbot, a series or complex algorithms process the
received input, understand what the user is asking, and based on that, determines the answer
suitable to the question.
Page 2 of 8
Chatbots have to rely on the ability of the algorithms to detect the complexity of both text
and spoken words. Some chatbots perform very well to the point it becomes difficult to
differentiate whether the user is a machine or a human.
However, handling complex conversations is a huge challenge; where there is a usage of
various figures of speech, it may be difficult for machines to understand.
Why we need Chatbots?
Cost and Time Effective: Humans cannot be active on-site 24/7 but chatbots can and the
replying power of chatbots is much fast than humans.
Cheap Development cost: with the advancement in technology many tools are developed that
help easy development and integration of chatbots with little investment.
Human Resource: Today Chatbots can also talk with text o speech technology so it gives the
feel as a human is talking on another side.
Business Branding: Businesses are changing with technology and chatbot is one out of them.
Chatbot also helps in advertising, branding of organization product and services and give daily
updates to users.
Types of Chatbots:
1. Rule-based chatbots: Chatbots follow a set of established rules or flows to respond to
questions posted by a user. All your simple applications contain rule-based chatbots,
which respond to queries based on the rules they are trained on. For instance, a weather
application, where you ask for weather forecast and it fetches the data from different
sources and responds with the information.
Rule-based chatbots may not be able to hold complex conversations. It can only
accomplish the tasks it is programmed to perform unless more improvements are made
by the developer.
2. Self-learning chatbots: Self-learning bots are highly efficient because they are capable
to grab and identify the user’s intent on their own. They are build using advanced tools
and techniques of Machine Learning, Deep Learning, and NLP. Self-learning bots are
further divided into 2 subcategories.
a. Retrieval-based chatbots:- Retrieval-based it is somewhat the same as Rule-
based where predefined input patterns and responses are embedded.
Page 3 of 8
b. Generative-Based chatbots:- It is based on the same phenomenon as
Machine Translation build using sequence 2 sequences neural network.
Most of the organization uses self-learning chatbot along with embedding some rules like Hybrid
version of both methods which makes chatbot powerful to handle each situation during a
conversation with a customer.
Page 4 of 8
via Facebook. Many businesses have used Facebook to their advantage and improved ways of
serving their customer base.
Skype for Business: This is another popular instant messaging platform utilized by many
businesses around the world for their internal or external communication. Bots like Skyscanner
allow you to make travel arrangements right in your Skype window. In addition, it helps you to
find the most affordable travel options. Bots like Bing Image Preview and Getty Images allow
you to search for images right from your Skype search bar.
Kik: It is an instant messaging platform, used for internal communication in businesses. One of
the most popular bots on this platform is The Weather Channel. It forecasts the weather for you
and lets you know if there is going to be any change in the weather. This is great for traveling
professionals as they can plan their schedules accordingly.
There are other messaging platforms with interesting bots that have been used to make
business operations smoother and easier.
How to Make a Chatbot in Python?
To build a chatbot in Python, you have to import all the necessary packages and initialize
the variables you want to use in your chatbot project. Also, remember that when working with
text data, you need to perform data preprocessing on your dataset before designing an ML
model.
This is where tokenizing helps with text data – it helps fragment the large text dataset into
smaller, readable chunks (like words). Once that is done, you can also go for lemmatization that
transforms a word into its lemma form. Then it creates a pickle file to store the python objects
that are used for predicting the responses of the bot.
Another vital part of the chatbot development process is creating the training and testing
datasets.
1. Prepare the Dependencies
The first step in creating a chatbot in Python with the ChatterBot library is to
install the library in your system. It is best if you create and use a new Python virtual
environment for the installation. To do so, you have to write and execute this command
in your Python terminal:
Page 5 of 8
You can also install ChatterBot’s latest development version directly from GitHub. For
this, you will have to write and execute the following command:
pip install git+git://github.com/gunthercox/ChatterBot.git@master
If you wish to upgrade the command, you can do so as well:
Now that your setup is ready, we can move on to the next step to create chatbot using python.
2. Import Classes: Importing classes is the second step in the Python chatbot creation
process. All you need to do is import two classes – ChatBot from chatterbot and
ListTrainer from chatterbot.trainers. To do this, you can execute the following command:
3. Create and Train the Chatbot: This is the third step on creating chatbot in python. The
chatbot you are creating will be an instance of the class “ChatBot.” After creating a new
ChatterBot instance, you can train the bot to improve its performance. Training ensures
that the bot has enough knowledge to get started with specific responses to specific
inputs. You have to execute the following command now:
Here, the argument (that corresponds to the parameter name) represents the name
of your Python chatbot. If you wish to disable the bot’s ability to learn after the training,
you can include the “read_only=True” command. The command “logic_adapters”
denotes the list of adapters used to train the chatbot.
While the “chatterbot.logic.MathematicalEvaluation” helps the bot to solve math
problems, the “chatterbot.logic.BestMatch” helps it to choose the best match from the list
of responses already provided.
Since you have to provide a list of responses, you can do it by specifying the lists
of strings that can be later used to train your Python chatbot, and find the best match for
Page 6 of 8
each query. Here’s an example of responses you can train your chatbot using python to
learn:
You can also create and train the bot by writing an instance of “ListTrainer” and
supplying it with a list of strings like so:
Page 7 of 8
However, it is essential to understand that the chatbot using python might not
know how to answer all your questions. Since its knowledge and training is still very
limited, you have to give it time and provide more training data to train it further.
5. Train your Python Chatbot with a Corpus of Data:
In this last step of how to make a chatbot in Python, for training your python
chatbot even further, you can use an existing corpus of data. Here’s an example of how to
train your Python chatbot with a corpus of data provided by the bot itself:
The good thing is that ChatterBot offers this functionality in many different
languages. So, you can also specify a subset of a corpus in a language you would prefer.
Conclusion: Thus we have successfully implemented elementary Chatbot for Customer interaction
application.
Page 8 of 8
TITLE: Implement any one of the following Expert System
I. Information management
Theory:
Expert System:
An expert system is a computer program that is designed to solve complex problems and
to provide decision-making ability like a human expert. It performs this by extracting knowledge
from its knowledge base using the reasoning and inference rules according to the user queries.
The expert system is a part of AI, and the first ES was developed in the year 1970, which
was the first successful approach of artificial intelligence. It solves the most complex issue as an
expert by extracting the knowledge stored in its knowledge base. The system helps in decision
making for complex problems using both facts and heuristics like a human expert. It is called so
because it contains the expert knowledge of a specific domain and can solve any complex
problem of that particular domain. These systems are designed for a specific domain, such as
medicine, science, etc.
The performance of an expert system is based on the expert's knowledge stored in its
knowledge base. The more knowledge stored in the KB, the more that system improves its
performance. One of the common examples of an ES is a suggestion of spelling errors while
typing in the Google search box.
Below is the block diagram that represents the working of an expert system:
Page 2 of 5
Below are some popular examples of the Expert System:
DENDRAL: It was an artificial intelligence project that was made as a chemical analysis expert
system. It was used in organic chemistry to detect unknown organic molecules with the help of
their mass spectra and knowledge base of chemistry.
MYCIN: It was one of the earliest backward chaining expert systems that was designed to find
the bacteria causing infections like bacteraemia and meningitis. It was also used for the
recommendation of antibiotics and the diagnosis of blood clotting diseases.
PXDES: It is an expert system that is used to determine the type and level of lung cancer. To
determine the disease, it takes a picture from the upper body, which looks like the shadow. This
shadow identifies the type and degree of harm.
CaDeT: The CaDet expert system is a diagnostic support system that can detect cancer at early
stages.
1. User Interface
With the help of a user interface, the expert system interacts with the user, takes queries
as an input in a readable format, and passes it to the inference engine. After getting the response
from the inference engine, it displays the output to the user. In other words, it is an interface that
helps a non-expert user to communicate with the expert system to find a solution.
Page 4 of 5
o Deterministic Inference engine: The conclusions drawn from this type of
inference engine are assumed to be true. It is based on facts and rules.
o Probabilistic Inference engine: This type of inference engine contains uncertainty
in conclusions, and based on the probability.
Inference engine uses the below modes to derive the solutions:
o Forward Chaining: It starts from the known facts and rules, and applies the
inference rules to add their conclusion to the known facts.
o Backward Chaining: It is a backward reasoning method that starts from the goal
and works backward to prove the known facts.
3. Knowledge Base
The knowledgebase is a type of storage that stores knowledge acquired from the different
experts of the particular domain. It is considered as big storage of knowledge. The more the
knowledge base, the more precise will be the Expert System.
It is similar to a database that contains information and rules of a particular domain or
subject. One can also view the knowledge base as collections of objects and their attributes. Such
as a Lion is an object and its attributes are it is a mammal, it is not a domestic animal, etc.
Conclusion:
Page 5 of 5
Laboratory Practice-II (Cloud Computing) TE Computer
Engineering
The instructor‘s manual is to be developed as a hands-on resource and reference. The instructor's
manual need to include prologue (about University/program/ institute/ department/foreword/
preface etc), University syllabus, conduction & Assessment guidelines, topics under consideration-
concept, objectives, outcomes, set of typical applications/practicals/ guidelines, and references.
The laboratory practical are to be submitted by student in the form of journal. Journal consists of
prologue, Certificate, table of contents, and handwritten write-up of each practical (Title,
Objectives, Problem Statement, Outcomes, software & Hardware requirements, Date of
Completion, Assessment grade/marks and assessor's sign, Theory- Concept in brief, algorithm,
flowchart, test cases, conclusion/analysis. Program codes with sample output of all perform
practical’s are to be submitted as softcopy.
As a conscious effort and little contribution towards Green IT and environment awareness,
attaching printed papers as part of write-ups and program listing to journal may be avoided. Use of
DVD containing students programs maintained by lab In-charge is highly encouraged. For reference
one or two journals may be maintained with program prints at Laboratory.
Continuous assessment of laboratory work is done based on overall performance and lab practicals
performance of student. Each lab practical assessment will assign grade/marks based on parameters
with appropriate weightage. Suggested parameters for overall assessment as well as each lab
practical assessment include- timely completion, performance, innovation, efficient codes,
punctuality and neatness.
Both internal and external examiners should jointly set problem statements. During practical
assessment, the expert evaluator should give the maximum weightage to the satisfactory
Laboratory Practice-II (Cloud Computing) TE Computer
Engineering
implementation of the problem statement. The supplementary and relevant questions may be asked
Laboratory Practice-II (Cloud Computing) TE Computer
Engineering
at the time of evaluation to test the student‘s for advanced learning, understanding of the
fundamentals, effective and efficient implementation. So encouraging efforts, transparent evaluation
and fair approach of the evaluator will not create any uncertainty or doubt in the minds of the
students. So adhering to these principles will consummate our team efforts to the promising start of
the student's academics.
The instructor is expected to frame the assignments by understanding the prerequisites, technological
aspects, utility and recent trends related to the topic. The assignment framing policy need to address
the average students and inclusive of an element to attract and promote the intelligent students. Use
of open source software is encouraged. Based on the concepts learned. Instructor may also set one
assignment or mini-project that is suitable to respective branch beyond the scope of syllabus.
Augmented and Virtual Reality :- Unity, C#, Blender, VRTK, ARTK, Vuforia VR Devices: HTC
Vive, Google Daydream and Samsung gear VR.
Cloud Computing :- NA
Software Modeling and Architectures: Front end:HTML5, Bootstrap, jQuery, JS etc. Backend:
MySQL/MongoDB/NodeJS
Laboratory Practice-II (Cloud Computing) TE Computer
Engineering
Cloud Computing
1 Case study on Amazon EC2 and learn about Amazon EC2 web services.
3
Creating an Application in SalesForce.com using Apex programming Language.
4 Design and develop custom Application (Mini Project) using Salesforce Cloud.
Mini-Project
Setup your own cloud for Software as a Service (SaaS) over the existing LAN
in your laboratory. In this assignment you have to write your own code for
5
cloud controller using open-source technologies to implement with HDFS.
Implement the basic operations may be like to divide the file in segments/blocks
and upload/ download file on/from cloud in encrypted form.
Laboratory Practice-II (Cloud Computing) TE Computer
Engineering
Practical No: 01
Practical Title: Case study on Amazon EC2 and learn about Amazon EC2 web services.
Objectives:
•To learn Amazon EC2 web services
•To study on Amazon EC2 and learn about Amazon EC2 web services.
Hardware Requirements :
•Pentium IV with latest configuration
Software Requirements :
•Ubuntu 20.04
Theory:
Open all the services and click on EC2 under Compute services. This will launch the
dashboard of EC2.
Here is the EC2 dashboard. Here you will get all the information in gist about the AWS
EC2 resources running.
Step 2) On the top right corner of the EC2 dashboard, choose the AWS Region in which
youwant to provision the EC2 server.
Here we are selecting N. Virginia. AWS provides 10 Regions all over the globe
Once your desired Region is selected, come back to the EC2 Dashboard.
Click on 'Launch Instance' button in the section of Create Instance (as shown below).
In the next step of the wizard, enter details like no. of instances you want to launch at a
time.
Here we are launching
one instance.Configure Instance
Step 1) No. of instances- you can provision up to 20 instances at a time. Here we are
launchingone instance.
Step 2) Under Purchasing Options, keep the option of 'Request Spot Instances' unchecked as
ofnow. (This is done when we wish to launch Spot instances instead of on- demand ones.
We will come back to Spot instances in the later part of the tutorial).
Step 3) Next, we have to configure some basic networking details for our EC2 server.
You have to decide here, in which VPC (Virtual Private Cloud) you want to launch your
instance and under which subnets inside your VPC. It is better to determine and plan this
prior to launching the instance. Your AWS architecture set-up should include IP ranges
for your subnets etc. pre-planned for better management. (We will see how to create a
new VPC in Networking section of the tutorial.
Laboratory Practice-II (Cloud Computing) Engineering TE Computer
Subnetting should also be pre-planned. E.g.: If it's a web server you should place it in the
public subnet and if it's a DB server, you should place it in a private subnet all inside
yourVPC.
Below,
1. Network section will give a list of VPCs available in our platform.
2. Select an already existing VPC
3. You can also create a new VPC
Here I have selected an already existing VPC where I want to launch my instance.
Once your instance is launched in a public subnet, AWS will assign a dynamic public
IPto it from their pool of IPs.
Step 5) In this step,
You can choose if you want AWS to assign it an IP automatically, or you want to do
itmanually later. You can enable/ disable 'Auto assign Public IP' feature here likewise.
Here we are going to assign this instance a static IP called as EIP (Elastic IP) later. So
we keep this feature disabled as of now.
Laboratory Practice-II (Cloud Computing) Engineering TE Computer
Laboratory Practice-II (Cloud Computing) Engineering TE Computer
Conclusion:
Thus, we saw in detail how to create an on-demand EC2 instance in this tutorial. Because it is an on-
demand server, you can keep it running when in use and 'Stop' it when it's unused to save on your
costs
Laboratory Practice-II (Cloud Computing) TE Computer
Engineering
Practical No : 2
Practical Title: Installation and configure Google App Engine.
Objectives:
•To learn basic of Google App Engine.
•To install and configure Google App Engine.
Hardware Requirements :
•Pentium IV with latest configuration
Software Requirements :
•Ubuntu 20.04, Web application i.e. Google App Engine
Theory:
Introduction
Google App Engine is a web application hosting service. By “web application,” we mean an
application or service accessed over the Web, usually with a web browser: storefronts with
shopping carts, social networking sites, multiplayer games, mobile applications, survey
applications, project management, collaboration, publishing, and all the other things we’re
discovering are good uses for the Web. App Engine can serve traditional website content too,
such as documents and images, but the environment is especially designed for real-time
dynamic applications. Of course, a web browser is merely one kind of client: web application
infrastructure is well suited to mobile applications, as well.
In particular, Google App Engine is designed to host applications with many
simultaneous users. When an application can serve many simultaneous users without degrading
performance, we say it scales. Applications written for App Engine scale automatically. As
more people use the application, App Engine allocates more resources for the application and
manages the use of those resources. The application itself does not need to know anything about
the resources it is using.
The app engine is a Cloud-based platform, is quite comprehensive and combines
infrastructure as a service (IaaS), platform as a service (PaaS) and software as a service (SaaS).
The app engine supports the delivery, testing and development of software on demand in a
Cloud computing environment that supports millions of users and is highly scalable.
The company extends its platform and infrastructure to the Cloud through its app
engine. It presents the platform to those who want to develop SaaS solutions at competitive
costs .Have you ever wondered as to who stands to benefit the most from the Google app
engine? If you are a business SME or enterprise which owns any web-based application that
needs to be scaled
Laboratory Practice-II (Cloud Computing) TE Computer
Engineering
without any compromise on the performance then Google App Engine is a good fit. Companies
like Best Buy and Khan Academy have chosen Google App Engine for their apps.
modules, SSL for custom domains, modules, remote access, and multitenancy.
Scalability
For any app’s success, this is among the deciding factors. Google creates its own apps
using GFS, Big Table and other such technologies, which are available to you when you
Laboratory Practice-II (Cloud Computing) TE Computer
Engineering
utilize the Google app engine to create apps. You only have to write the code for the app
and Google looks after the testing on account of the automatic scaling feature that the
app engine has. Regardless of the amount of data or number of users that your app
stores, the app engine can meet your needs by scaling up or down as required.
Cost Savings
You don’t have to hire engineers to manage your servers or to do that yourself. You can
invest the money saved into other parts of your business.
Platform Independence
You can move all your data to another environment without any difficulty as there is not
many dependencies on the app engine platform.
Conclusion :
Practical No: 3
Practical Title: Creating an Application in SalesForce.com using Apex programming
Language
Objectives:
•To learn salesforce cloud administration
•To create application in SalesForce.com using Apex programming
Hardware Requirements :
•Pentium IV with latest configuration
Software Requirements :
•Ubuntu 20.04, Web application i.e. salesforce.com
Theory:
What is Apex?
Apex is a proprietary language developed by the Salesforce.com. As per the official definition,
Apex is a strongly typed, object-oriented programming language that allows developers to
execute the flow and transaction control statements on the Force.com platform server in
conjunction with calls to the Force.com API.
It has a Java-like syntax and acts like database stored procedures. It enables the developers to
add business logic to most system events, including button clicks, related record updates, and
Visual force pages. Apex code can be initiated by Web service requests and from triggers on
objects. Apex is included in Performance Edition, Unlimited Edition, Enterprise Edition, and
Developer edition.
.
Laboratory Practice-II (Cloud Computing) TE Computer
Engineering
Apex has built in support for DML operations like INSERT, UPDATE, DELETE and also DML
Exception handling. It has support for inline SOQL and SOSL query handling which returns the
set of sObject records. We will study the sObject, SOQL, SOSL in detail in future chapters.
Apex is easy to use as it uses the syntax like Java. For example, variable declaration,
Apex is data focused and designed to execute multiple queries and DML statements together. It
issues multiple transaction statements on Database.
Strongly Typed
Apex is a strongly typed language. It uses direct reference to schema objects like Object and any
invalid reference quickly fails if it is deleted or if is of wrong data type.
Multitenant Environment
Apex runs in a multitenant environment. Consequently, the Apex runtime engine is designed to
guard closely against runaway code, preventing it from monopolizing shared resources. Any
code that violates limits fails with easy-to-understand error messages.
Upgrades Automatically
Apex is upgraded as part of Salesforce releases. We don't have to upgrade it manually.
Easy Testing
Apex provides built-in support for unit test creation and execution, including test results that
indicate how much code is covered, and which parts of your code can be more efficient.
Laboratory Practice-II (Cloud Computing) TE Computer
Engineering
using the pre-built and existing out of the box functionalities. Below are the cases where we
Apex Applications
over multiple objects at the same time and also custom validation
implementation.
functionality
or flows.
Flow of Actions
There are two sequence of actions when the developer saves the code and when an end user
performs some action which invokes the Apex code as shown below –
Laboratory Practice-II (Cloud Computing) TE Computer
Engineering
Developer Action
When a developer writes and saves Apex code to the platform, the platform application server
first compiles the code into a set of instructions that can be understood by the Apex runtime
When an end-user triggers the execution of Apex, by clicking a button or accessing a Visual
force page, the platform application server retrieves the compiled instructions from the metadata
and sends them through the runtime interpreter before returning the result. The end user
observes no differences in execution time as compared to the standard application platform
request.
Since Apex is the proprietary language of Salesforce.com, it does not support some features
which a general programming language does. Following are a few features which Apex does not
support −
in User Interface.
to
prevent the standard functionality execution.
to
prevent the standard functionality execution.
Variable Declaration
As strongly typed language, you must declare every variable with data type in Apex. As seen in
the code below (screenshot below), lstAcc is declared with data type as List of Accounts.
SOQL Query
This will be used to fetch the data from Salesforce database. The query shown in screenshot
This loop statement is used for iterating over a list or iterating over a piece of code for a
specified number of times. In the code shown in the screenshot below, iteration will be same as
whether to go for execution or to stop the execution of the particular piece of code. For example,
in the code shown below, it is checking whether the list is empty or it contains records.
DML Statement
Performs the records insert, update, upsert, delete operation on the records in database. For
example, the code given below helps in updating Accounts with new field value.
Conclusion:
Reference: https://www.tutorialspoint.com/apex/apex_overview.html
Laboratory Practice-II (Cloud Computing) TE Computer
Engineering
Practical No : 04
Practical Title: Design and develop custom Application (Mini Project) using Salesforce Cloud.
Objectives:
•To learn salesforce cloud administration
•To install and configure the salesforce cloud administrative features
Hardware Requirements :
•Pentium IV with latest configuration
Software Requirements :
•Ubuntu 20.04, Web application i.e. salesforce.com
Theory:
Introduction
Salesforce.com Inc. is an American cloud-based software company headquartered in San
Francisco, California. Though the bulk of its revenue comes from a customer relationship
management (CRM) product, Salesforce also sells a complementary suite of enterprise
applications focused on customer service, marketing automation, analytics and application
development.
Salesforce is the primary enterprise offering within the Salesforce platform. It provides
companies with an interface for case management and task management, and a system for
automatically routing and escalating important events. The Salesforce customer portal provides
customers the ability to track their own cases, includes a social networking plug-in that enables
the user to join the conversation about their company on social networking websites, provides
analytical tools and other services including email alert, Google search, and access to customers'
entitlement and contracts.
Lightning Platform
Lightning Platform (also known as Force.com) is a platform as a service (PaaS) that allows
developers to create add-on applications that integrate into the main Salesforce.com application.
These third-party applications are hosted on Salesforce.com's infrastructure. Force.com
applications are built using declarative tools, backed by Lightning and Apex (a proprietary Java-
like programming language for Force.com) and Lightning and Visual force (a framework that
includes an XML syntax typically used to generate HTML). The Force.com platform typically
receives three complete releases a year. As the platform is provided as a service to its
developers, every single development instance also receives all these updates.
Laboratory Practice-II (Cloud Computing) TE Computer
Engineering
Community Cloud
Community Cloud provides Salesforce customers the ability to create online web properties for
external collaboration, customer service, channel sales, and other custom portals I their instance
of Salesforce. Tightly integrated to Sales Cloud, Service Cloud, and App Cloud, Community
Cloud can be quickly customized to provide a wide variety of web properties Salesforce Sales
Cloud Salesforce Sales Cloud is a customer relationship management (CRM) platform designed
to support sales, marketing and customer support in both business-to-business (B2B) and
business-to-customer (B2C) contexts. Sales Cloud is a fully customizable product that brings all
the customer information together in an integrated platform that incorporates marketing, lead
generation, sales, customer service and business analytics and provides access to thousands of
applications through the AppExchange. The platform is provided as Software as a Service
(SaaS) for browser-based access; a mobile app is also available. A realtime social feed for
collaboration allows users to share information or ask questions of the user
community.Salesforce.com offers five versions of Sales Cloud on a per-user, per month basis,
from lowest to highest: Group, Professional, Enterprise, Unlimited and Performance. The
company offers three levels of support contracts: Standard Success Plan, Premier Success Plan
and Premier+ Success Plan.
1. From Setup, enter Apps in the Quick Find box, then select Apps.
2. Click New.
3. If the Salesforce console is available, select whether you want to define a custom app or
a Salesforce console.
4. Give the app a name and description.
An app name can have a maximum of 40 characters, including spaces.
5. Optionally, brand your app by giving it a custom logo.
6. Select which items to include in the app.
7. Optionally, set the default landing tab for your new app using the Default Landing
Tab drop-down menu below the list of selected tabs. This determines the first tab a
user sees when logging into this app.
Laboratory Practice-II (Cloud Computing) TE Computer
Engineering
8. Choose which profiles the app will be visible to.
9. Check the Default box to set the app as that profile’s default app, meaning that new
users with the profile see this app the first time they log in. Profiles with limits are
excluded from this list.
10. Click Save
What is the difference between custom application and console application in sales force?
A custom application is a collection of tabs, objects etc that function together to solve a
particular problem.
A console application uses a specific Salesforce UI - the console. Console applications are intended
to enhance productivity by allowing everything to be done from a single, tabbed, screen.
Conclusion:
Thus, We have designed and developed custom application using salesforce cloud.
Laboratory Practice-II (Cloud Computing) TE Computer
Engineering
Practical No : 05
Practical Title: Setup your own cloud for Software as a Service (SaaS) over the existing
LAN in your laboratory. In this assignment you have to write your own code for cloud
controller using open-source technologies to implement with HDFS. Implement the basic
operations may be like to divide the file in segments/blocks and upload/ download file
on/from cloud in encrypted form.
Objectives:
Software Requirements :
•Ubuntu 20.04, VMwareESXi cloud
Theory:
Host/NodeESXi installation:-
ESXiHardwareRequirements:-
• ESXi6.7requiresahostmachinewithatleasttwoCPUcores.
• ESXi6.7supports64-bitx86processors
• ESXi6.7requirestheNX/XDbit to be enabled for the CPU in the BIOS.
• ESXi6.7requiresaminimumof4GBofphysicalRAM.Itisrecommended to
provide atleast 8 GB of RAM to run virtual machines in typical
productionenvironments.
ESXiInstaller:
Accept Agreement:
Laboratory Practice-II (Cloud Computing) TE Computer
Engineering
Select storage :
Set IPV4
Set DNSeriver :
GUIAccess :
ClusterSetup
• CreatingDatacenter
• CreatingCluster
• Adding Hosts incluster
• Resourcesafteraddingcluster.
• DRS
• Failover
VCenter Access:
Laboratory Practice-II (Cloud Computing) TE Computer
Engineering
Create Datacenter:
Create cluster :
Add host .:
Add host IP :
Hot summary :
Finish:
Laboratory Practice-II (Cloud Computing) TE Computer
Engineering