SC Lab Manual 2017 18
SC Lab Manual 2017 18
Laboratory Manual
Soft Computing
For
Manual Prepared by
Mr.R.A.Sarwade
To achieve and evolve as a center of academic excellence and research center in the field of
Computer Science and Engineering. To develop computer engineers with necessary analytical
ability and human values who can creatively design, implement a wide spectrum of computer
systems for welfare of the society.
The department strives to continuously engage in providing the students with in-depth
understanding of fundamentals and practical training related to professional skills and their
applications through effective Teaching- Learning Process and state of the art laboratories
pertaining to CSE and inter disciplinary areas. Preparing students in developing research,
design, entrepreneurial skills and employability capabilities.
College of Engineering
Technical Document
This technical document is a series of Laboratory manuals of Computer Science & Engineering
Department and is a certified document of College of Engineering, Osmanabad. The care has
been taken to make the document error-free. But still if any error is found. Kindly bring it to the
notice of subject teacher and HOD.
Recommended by,
HOD
Approved by,
Principal
Copies:
1. Departmental Library
2. Laboratory
3. HOD
4. Principal
FOREWORD
It is my great pleasure to present this laboratory manual for Final year Engineering students for
the subject – “ Soft Computing”.
As a student, many of you may be wondering with some of the questions in your mind regarding
the subject and exactly what has been tried is to answer through this manual
Faculty members are also advised that covering these aspects in initial stage itself will greatly
relieve them in future as much of the load will be taken care by the enthusiasm energies of the
students once they are conceptually clear
H.O.D.
CSE Dept.
LABORATORY MANUAL CONTENTS
This manual is intended for the final year students of Computer Science and Engineering in the
subject of Soft Computing. This manual typically contains practical/Lab Sessions related to the
subject on the MATLAB/Scilab platform covering various aspects of the subject to enhance
understanding.
Students' are advised to thoroughly go through this manual rather than only topics mentioned in
the syllabus as practical aspects are the key to understanding and conceptual visualization of
theoretical aspects covered in the books.
Mr. R.A.Sarwade.
SUBJECT INDEX:-
2. Lab Exercises
3.Quiz
4.Conduction of viva voce examination
5.Evaluation & marking scheme
1.Do’s and Don’ts in the laboratory
1. Make entry in the Log Book as soon as you enter the Laboratory.
2. All the students should sit according to their roll numbers starting from their left
to right.
3. All the students are supposed to enter the terminal number in the log book.
4. Do not change the terminal on which you are working.
5. All the students are expected to get at least the algorithm of the program/concept
to be implemented.
6. Strictly observe the instructions given by the teacher/Lab Instructor
1. Submission related to whatever lab work has been completed should be done
during the next lab session. The immediate arrangements for printouts related to
submission on the day of practical assignments.
2. Students should be taught for taking the printouts under the observation of lab
teacher
Pre-lab (Introduction to MATLAB)
Questions:
Objectives:
• To implement AND logic gate
• To implement OR logic gate
Instructions:
1. Study MP Model
2. Study logic gates: AND,OR,NOT,Exclusive-OR
3. Write a program to implement AND gate without using neural network toolbox.
4. Write a program to implement OR gate without using neural network toolbox.
Output :-
Objectives:
• To implement ANDNOT logic gate
Instructions:
1.Study MP Model
2.Study logic gates: AND,OR,NOT,Exclusive-OR
3.Write a program to implement ANDNOT gate without using neural network toolbox.
Output :-
Title: Generate XOR function using McCulloch-Pitts neural net by MATLAB program.
Objectives:
• To implement XOR logic gate
Instructions:
1.Study MP Model
2.Study logic gates: AND,OR,NOT,Exclusive-OR
3.Write a program to implement XOR gate without using neural network toolbox.
Title: Write a program for solving linearly separable problem using Perceptron Model.
Objectives:
To implement AND function using Perceptron
Instructions:
5. Study Perceptron Model
6. Write a program to implement AND function
7. Draw the diagram of AND using Perceptron used below
Output
Enter Learning rate=1
Enter Threshold value=0.5
Perceptron for AND function
Final Weight matrix
1 1
Final Bias
-1
EXPERIMENT NO. 5
Title: Perceptron net for an AND function with bipolar inputs and targets.
Objectives:
To implement AND function using Perceptron
Instructions:
8. Study Perceptron Model
9. Write a program to implement AND function
10. Draw the diagram of AND using Perceptron used below
Output :-
Title: Write a program to store a pattern (1 1 1 0). Test the network using Discrete
Hopfield Net by giving the input with mistakes in First and Second position.
Objectives:
To understand the concept of Pattern storage
To implement Discrete Hopfield Net
Training Algorithm:
Describe about Pattern Storage networks
Write theory for Hopfield Net.
Output:
Title: Program for Pattern storage of 10 digits with Discrete Hopfield Network
Objectives:
To study pattern storage function using Discrete Hopfield Network using build in
function of MATLAB
To test the network for noisy inputs
Theory: Write theory of Discrete Hopfield Network. Draw the diagram of the network too.
Algorithm:
Write the training and the testing algorithm used in the program below.
Source Code:
%Program for Pattern storage of 10 digits - 0-9- using Discrete Hopfield
%Network. Testing the network using a noisy input pattern.
close all
clc
clear
load ('D:\MSJ\pat.mat')
figure(1)
pat2=pat;
pat2(pat2>=0)=255;
pat2(pat2<0)=0;
pat2=reshape(pat2, [10 100/10*size(pat,2)]);
image(pat2)
iterations=10;
character=5;
net=newhop(pat);
d2=pat(:,character);
r=rand(size(d2));
figure(2)
digit(d2)
title(sprintf('Original digit %i',character))
%A bit is 'flipped' with probalility (1-lim)
lim=.7;
d2(r>lim)=-d2(r>lim);
figure(3)
digit(d2)
title(sprintf('Digit %i with noise added',character))
[Y, Pf, Af] = sim(net, {1 iterations}, [ ], {d2});
Y=cell2mat(Y);
figure(4)
digit(Y)
title('All iterations of Hopfield Network')
axis equal
%------End of Program------------
%-----Function------------
function [ ] = digit(pat)
%load pat
% change color
pat2=pat;
pat2(pat2>=0)=255;
pat2(pat2<0)=0;
%pat2(pat2==-1)=255;
pat2=reshape(pat2, [10 100/10*size(pat,2)]);
image(pat2)
end
%--Input Data----------
% File pat.mat
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 –1
1 1 1 1 1 1 1 1 1 –1
1 1 1 1 1 1 1 1 1 –1
1 1 1 1 1 1 1 1 1 –1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 –1 –1 1 –1 1 1 1 1 1
1 1 1 1 –1 1 1 –1 1 –1
1 1 1 1 –1 –1 1 –1 1 1
1 1 1 1 –1 –1 1 –1 1 1
1 1 1 1 1 –1 1 1 1 1
1 1 1 1 1 –1 1 –1 1 1
1 1 1 1 1 –1 1 –1 1 –1
1 –1 –1 1 1 –1 1 –1 1 1
1 –1 1 1 –1 1 1 1 1 1
1 –1 –1 1 1 1 1 1 1 1
–1 1 1 –1 –1 1 –1 –1 1 –1
1 1 1 –1 1 –1 1 1 1 1
1 1 1 –1 1 1 1 1 1 1
1 1 1 –1 –1 1 1 1 1 1
1 1 1 –1 1 –1 1 –1 1 1
1 1 1 1 1 1 1 1 1 1
1 –1 1 1 1 1 1 1 1 1
1 –1 1 1 1 1 1 1 1 –1
1 –1 –1 1 –1 –1 –1 –1 1 1
1 –1 –1 1 1 1 1 1 1 –1
–1 1 1 1 –1 –1 –1 –1 1 1
1 1 1 1 1 1 1 1 –1 1
1 1 1 1 1 1 1 1 –1 1
1 1 1 1 –1 1 1 1 –1 1
1 1 1 –1 1 –1 1 –1 1 1
1 –1 1 1 1 1 1 1 1 1
1 –1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 –1 1 1 1
–1 –1 –1 1 –1 –1 1 –1 1 –1
–1 –1 –1 1 1 –1 1 1 1 –1
–1 1 1 1 –1 1 –1 –1 –1 1
–1 1 1 1 1 1 1 1 1 1
–1 1 1 1 1 1 1 1 1 1
–1 1 –1 1 1 1 1 1 1 1
–1 –1 –1 –1 –1 –1 1 –1 –1 1
–1 –1 1 1 1 1 1 1 1 1
–1 1 1 1 1 1 –1 1 1 1
–1 1 1 1 1 1 1 1 1 1
–1 –1 –1 1 –1 –1 1 –1 –1 –1
1 –1 –1 1 1 1 1 1 1 1
1 1 1 1 –1 1 –1 1 –1 –1
1 1 1 1 1 1 1 –1 1 1
1 1 1 1 1 1 1 –1 1 1
1 –1 –1 1 1 1 1 –1 1 1
1 –1 –1 –1 1 1 1 1 –1 1
1 1 1 1 –1 –1 –1 –1 1 1
1 1 1 1 –1 –1 1 –1 1 1
1 1 1 1 –1 –1 1 –1 –1 –1
–1 –1 –1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 –1 –1 –1 1 1 1 1 –1 1
1 –1 –1 –1 1 1 –1 1 1 –1
1 –1 –1 –1 1 1 –1 1 1 1
1 –1 1 –1 1 1 –1 1 1 1
1 1 1 –1 1 1 –1 1 –1 1
1 1 –1 –1 1 1 1 1 1 1
1 1 –1 –1 1 1 1 1 –1 –1
1 1 –1 –1 1 1 1 1 1 1
1 –1 1 –1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 –1 1
1 1 1 1 1 1 1 1 –1 –1
1 1 1 1 1 1 1 1 –1 –1
1 1 1 1 1 1 1 1 –1 –1
1 1 1 1 1 1 1 1 –1 –1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
Experiment No. 8
____________________________________________________________
Title: Program for To perform Union,Intersection and Complement operations.
Objectives:
To understand the concept of Pattern Fuzzy Sets.
To implement Union,Intersection and Complement operations.
Theory: Write theory of Fuzzy Sets. Draw the diagram of the network.
%Enter Data
u=input('Enter First Matrix');
v=input('Enter Second Matrix');
%To Perform Operations
w=max(u,v);
p=min(u,v);
q1=1-u;
q2=1-v;
%Display Output
display('Union Of Two Matrices');
display(w);
display('Intersection Of Two Matrices');
display(p);
display('Complement Of First Matrix');
display(q1);
display('Complement Of Second Matrix');
display(q2);
Output:-
Enter First Matrix [0.3 0.4]
Enter Second Matrix [0.1 0.7]
Union Of Two Matrices
w =0.3000 0.7000
Intersection Of Two Matrices
p = 0.1000 0.4000
Complement Of First Matrix
q1 =0.7000 0.6000
Complement Of Second Matrix
q2 =0.9000 0.3000
Experiment No. 9
____________________________________________________________
Title: Write a program in MATLAB to implement De-Morgan’s Law.
Objectives:
To understand the concept of De-Morgan’s Law.
To implement De-Morgan’s Law.
Theory:-
FIS stands for Fuzzy Inference System.In FIS fuzzy rules are used for approximate reasoning.It
is the logical framework that allows us to design reasoning systems based on fuzzy set theory.
To illustrate these concepts we use example of Water Tank:-
FIS editor consists of following units:-
i) Input
ii) Inference System
iii) Output
The Water Level is considered as the Input variable and Valve status is taken as Output
Variable.
The Input-Output Variable’s Membership functions should be plotted along with their ranges:-
The following screen appearance is obtained by clicking on the FIS Rule system indicator:-
Rules are added by selecting variable’s values and clicking on add rule menu each time a new
rule is added.
The fuzzy Rules defined for water tank are:-
IF level is ok,THEN there is no change in valve.
IF level is low,THEN valve is open in fast mode.
IF level is high,THEN valve is closed in fast mode.
The result is displayed as plots of input-output membership functions :-
Water Level(ok,low,high)
Valve Status(no change,open fast,closed fast)
The output in accordance with the input and rules provided by user is shown as(view-rule
viewer):-
Output
3. Quiz on the Subject.
1:
Core of soft Computing is
A. Fuzzy Computing, Neural Computing, Genetic Algorithms
B. Fuzzy Networks and Artificial Intelligence
C. Artificial Intelligence and Neural Science
D. Neural Science and Genetic Science
Answer
Option: A
2:
Who initiated the idea of Soft Computing
A. Charles Darwin
B. Lofti A Zadeh
C. Rechenberg
D. Mc_Culloch
Answer
Option: B
3:
Fuzzy Computing
A. mimics human behaviour
B. doesnt deal with 2 valued logic
C. deals with information which is vague, imprecise, uncertain, ambiguous, inexact, or
probabilistic
D. All of the above
Answer
Option: D
4:
Neural Computing
A. mimics human brain
B. information processing paradigm
C. Both (a) and (b)
D. None of the above
Answer
Option: C
5:
Genetic Algorithm are a part of
A. Evolutionary Computing
B. inspired by Darwin's theory about evolution - "survival of the fittest"
C. are adaptive heuristic search algorithm based on the evolutionary ideas of natural
selection and genetics
D. All of the above
Answer
Option: D
6:
What are the 2 types of learning
A. Improvised and unimprovised
B. supervised and unsupervised
C. Layered and unlayered
D. None of the above
Answer
Option: B
7:
Supervised Learning is
A. learning with the help of examples
B. learning without teacher
C. learning with the help of teacher
D. learning with computers as supervisor
Answer
Option: C
8:
Unsupervised learning is
A. learning without computers
B. problem based learning
C. learning from environment
D. learning from teachers
Answer
Option: C
9:
Conventional Artificial Intelligence is different from soft computing in the sense
A. Conventional Artificial Intelligence deal with prdicate logic where as soft computing
deal with fuzzy logic
B. Conventional Artificial Intelligence methods are limited by symbols where as soft
computing is based on empirical data
C. Both (a) and (b)
D. None of the above
Answer
Option: C
10:
In supervised learning
A. classes are not predefined
B. classes are predefined
C. classes are not required
D. classification is not done
Answer
Option: B
4.Conduction of VIVA-VOCE Examinations:
Teacher should conduct oral exams of the students with full preparation. Normally the objective
questions with guess are to be avoided. To make it meaningful, the questions should be such that
depth of the student in the subject is tested. Oral Exams are to be conducted in co-cordial
situation. Teachers taking oral exams should not have ill thoughts about each other & courtesies
should be offered to each other in case of opinion, which should be critically suppressed in front
of the students.