You are on page 1of 38

[[ Soft Computing]]

[ IT - 8002]

Submitted By: Submitted To:


Sandesh Singhal Mrs. Rakhi Arora
0905IT161047 Asst.Prof.(CS/IT)

---------------------------------------------------------------------------------------------
Nh-75 Opp. Sithouli Railway Station, Sithouli, Gwalior, Madhya
Pradesh 475001

Sandesh Singhal
[ INDEX]
S.No. Content

1. Draw and sketch neat and clean diagram of biological neuron.

2. WAP for implementing linear saturating function.

3. Write a program of Perceptron Training Algorithm.

4. Write a program to implement Hebb’s rule.

5. Write a program to implement of delta rule.

6. Write a program for Back Propagation Algorithm.

Study and analysis of ART on the basis of following


(i) Architecture
7. (ii) Need of theory
(iii) Working Introduction

8. Study and Analysis of Counter Propagation Network.

Study and analysis of Genetic Algorithm on the basis of following


(i) Basic concept
9. (ii) Working principle
(iii) Advantages & Disadvantage

Study and analysis of fuzzy Vs crisp logic.


10.

Sandesh Singhal
EXPERIMENT-1
Object: Draw and sketch neat and clean diagram of biological neuron.

The human brain consists of a large number; more than a billion of neural cells that process
information. Each cell works like a simple processor. The massive interaction between all cells
and their parallel processing only makes the brain’s abilities possible.

Dendrites are branching fibres that extend from the


cell body or soma.

Soma or Cell Body of a neuron contains the nucleus


and other structures, support chemical processing
and production of neurotransmitters.

Axon is a singular fibre carries information away


from the soma to the synaptic sites of other neuron
(dendrites and somas), muscles, or glands.

Axon Hillock is the site of summation for incoming


information. At any moment the collective influence
of all neurons that conducts impulses to a given
neuron will determine whether or not an action potential will be initiated at the axon hillock and
propagated along the axon.

Myelin Sheath consists of fat-containing cells that insulate the axon from electrical activity. This
insulation acts to increase the rate of transmission of signals. A gap exists between each myelin
sheath cell along the axon. Since fat inhibits the propagation of electricity, the signals jump from
one gap to the next.

Nodes of Ranvier are the gaps (about 1 µm) between myelin sheath cells long axons are Since fat
serves as a good insulator, the myelin sheaths speed the rate of transmission of an electrical impulse
along the axon.

Synapse is the point of connection between two neurons or a neuron and a muscle or a gland.
Electrochemical communication between neurons takes place at these junctions.

Terminal Buttons of a neuron are the small knobs at the end of an axon that release chemicals
called neurotransmitters.

Sandesh Singhal
Information flow in a Neural Cell

The input /output and the propagation of information are shown below.

i. Dendrites receive activation from other neurons.

ii. Soma processes the incoming activations and converts them into output activations. Axons
act as transmission lines to send activation to other neurons.

iii. Synapses the junctions allow signal transmission between the axons and dendrites. .

iv. The process of transmission is by diffusion of chemicals called neuro-transmitters.

Sandesh Singhal
EXPERIMENT-2

Object: WAP for implementing linear saturating function.


PROGRAM:

#include<iostream.h>

#include<conio.h>

void main()

clrscr();

float x,b,w,net;

float out;

cout<<"enter the input X=";

cin>>x;

cout<<"enter the bias b=";

cin>>b;

cout<<"enter the weight W=";

cin>>w;

net=(w*x+b);

cout<<"net="<<net<<endl;

if(net<0)

out=0;

else

if((net>=0)&&(net<=1))

out=net;

else Sandesh Singhal


out=1;

cout<<"output="<<out<<endl;

getch();

OUTPUT:

When, net<0:

When, ((net>=0) && (net<=1)):

Sandesh Singhal
When, net>1:

Sandesh Singhal
EXPERIMENT-3
Object: Write a program of Perceptron Training Algorithm.

Algorithm:

Start with a randomly chosen weight vector w0;


Let k=1;
While these exists input vector that are misclassified by: Wk-1 do
Let i be a misclassified input vector
Let Xk=class(ij)ij, impling that Wk-1.Xk<0
Update the weight vector to Wk= Wk-1 + nXk;
increment k;
End while;

Program:

#include<iostream.h>
#include<conio.h>

void main( )
{
clrscr( );
int in[3],d,w[3],a=0;
for(int i=0;i<3,i++)
{
cout<<”\n initialize the weight vector w”<<i;
cin>>w[i]
}
for(i=0;i<3:i++}
{
cout<<”\n enter the input vector i”<<i;
cin>>in[i];
}
cout<<”\n enter the desined output”;
cin>>d;
int ans=1;
while(ans= = 1)
{
for (a= 0, i==0;i<3;i++)
{
a = a + w[i] * in[i];
} Sandesh Singhal
clrscr( );
cout<<”\n desired output is”<<d;
cout<<”\n actual output is “<<a;
int e;
e=d-a;
cout<<”\n error is “<<e;
cout<<”\n press 1 to adjust weight else 0”;
cin>>ans;
if (e<0)
{
for(i=0;i<3;i++)
{
w[i]=w[i]-1;
}
}
else if (e>0)
{
for(i=0;i<3:i++)
{
w[i]=w[i]+1;
}
}
getch( );
}

Sandesh Singhal
OUTPUT:

Sandesh Singhal
EXPERIMENT-4

Object: Write a program to implement Hebb’s rule.


PROGRAM:

#include<<iostream.h>>
#include<<conio.h>>
void main()
{
float n,w,t,net,div,a,al;
cout<<”consider o single neuron percetron with a single i/p”;
cin>>w;
cout<<”enter the learning cofficient”;
cin>>d;
for (i=0;i<10;i++)
{
net = x+w;
if(wt<0)
a=0;
else
a=1;
div=at+a+w;
w=w+div;
cout<<”i+1 in fraction are i”<<a<<”change in weight”<<dw<<”adjustment at=”<<w;
}
}

Sandesh Singhal
OUTPUT:

Sandesh Singhal
EXPERIMENT-5

Object: Write a program to implement of delta rule.


PROGRAM:

#include<<iostream.h>>

#include<<conio.h>>

void main()

clrscr( );

float input[3],d,weight[3],delta;
for(int i=0;i < 3 ; i++)
{
cout<<”\n initilize weight vector “<<i<<”\t”;
cin>>input[i];
}
cout<<””\n enter the desired output\t”;
cin>>d;
do
{

del=d-a;

if(del<0)
for(i=0 ;i<3 ;i++)
w[i]=w[i]-input[i];
else if(del>0)
for(i=0;i<3;i++)
weight[i]=weight[i]+input[i];
for(i=0;i<3;i++)
{
val[i]=del*input[i];
weight[+1]=weight[i]+val[i];
}
cout<<”\value of delta is “<<del;
cout<<”\n weight have been adjusted”;
}while(del ≠ 0)
if(del=0)
cout<<”\n output is correct”;

Sandesh Singhal
OUTPUT:

Sandesh Singhal
EXPERIMENT-6

Object: Write a program for Back Propagation Algorithm.

PROGRAM:

# include <iostream.h>
#include <conio.h>
void main ()
{
int i ;
float delta, com, coeff = 0.1;
struct input
{
float val,out,wo, wi;
int top;
} s[3] ;

cout<< “\n Enter the i/p value to target o/p” << “\t”;
for (i=0; i<3 ; i++)
cin>> s [i], val>> s[i], top);
i = 0;
do
{
if (i = = 0)
{
W0 = -1.0;
W1 = -0.3;
}
else
{
W0 = del [i - 1], W0 ;
W1 = del [i - 1] , Wi ;
}
del [i]. aop = w0 + (wi * del [i]. val);
del [i].out = del [i]. aop);
delta = (top – del [i]. out) * del [i].out * (1 – del [i].out);
corr = coeff * delta * del [i].[out];
del [i].w0 = w1 + corr;
del [i]. w1 = w1 + corr;
i++;
}While ( i ! = 3)
Sandesh Singhal
cout<< “VALUE”<<”Target”<<”Actual”<<”w0” <<”w1”<<’\n;
for (i=0; i=3; i++)

cout<< s [i].val<< s[i].top<<s[i].out << s[i]. w0<< s[i]. w1;

cout<< “\n”;

getch ();

OUTPUT:

Sandesh Singhal
EXPERIMENT-7

Object: Study and analysis of ART on the basis of following

(iv) Architecture
(v) Need of theory
(vi) Working Introduction

Adaptive Resonance Theory (ART):

ART (Adaptive Resonance Theory) models are a neural network that performs
clustering and can allow the no. of cluster to vary with problem size.

The difference between ART and other clustering model is that ART allows the
user to control the degree of similarity between no. of same cluster by means of a user define
constants called vigilance parameter.

The 1st version of ART was ART1, developed by Carpenter and Gross berg in
1988.

Block Diagram of ART:

It consist of two layers of neurons labelled “Comparison” and “Recognition”. Gain1, Gain2 and
reset provide control functions needed for training and classification.

In a real world, the network will be exposed to constantly changing environment


i.e. it may never see the same training vector twice, in such cases any of the conventional ANN
seems till now will learn nothing.

ART network is a vector classifier. It accepts the inputs and classifies it on the
basis of already stored patterns to which it most resembles. The classification is done by the
recognition layer.

If the input vector does not match any already stored pattern, a new pattern or
category is created which matches the input vector.

No stored pattern is ever modified, if it does not match the current input within the
vigilance.

1. Comparison Layer: It works on 2/3 rule. This layer receives the binary layer input vector
represented by X and initially passes it through unchanged to become the vector C.
For one iteration C=X, in later case binary vector R is produce from
Recognition layer. Each neuron in the comparison layer receives three binary inputs.

a. The components Xi from the input vector X.


Sandesh Singhal
b. The feedback signal Pj i.e. the weighted sum of recognition layer output.
c. The input from the gain signal i.e. Gain1 (G1).

OR of X OR of R G2

Component Component

0 0 0

1 0 1

1 1 0

0 1 0

2. Recognition Layer: The recognition layer serves to classify the input vector. Each
recognition layer neuron has an associated weight vector bj only the neuron with the weight
vector best matching the input vectors, fire all other neurons are inhibited.
The weights in the recognition layer make a stored pattern for a category of input
output vector, these weights are real number.
Sandesh Singhal
The binary version of same pattern is stored in the corresponding set of weights in
the comparision layer.

Operation perform in Recognition Layer: Each recognition layer neuron computes a dot(.)
product between its weights and incoming vector C. The neuron which has the highest dot
product will win the competition and will fire, the response of recognition layer is in the fashion
“winner takes all”.

a. GAIN2 (G2) -> It is set to 1 if one of the component of input vector X is 1. G2 is logically
“OR” of the component of X.

b. GAIN1 (G1) -> Like GAIN2, the output of GAIN1 is 1. If any component of binary input
vector is 1.
But if any component of R is 1 then, G1 is force to become 0.

c. Reset Signal -> The Reset modules measures the similarity between the vector X and C.
Generally, this similarity is the ratio of 1’s in the vector X.
If this ratio is below the vigilance parameter, a reset signal is issue and inhibits
the neuron of recognition layer.

The vigilance parameter p is closer to 1 for accuracy & its value is 0.9

Introduction:

One of the nice features of human memory is its ability to learn many new things without
necessarily forgetting things learned in the past. A frequently cited example is the ability to
recognize your parents even if you have not seen them for some time and have learned many new
faces in the interim. It would be highly desirable if we could impart this same capability to an
Artificial Neural Networks. Most neural networks will tend to forget old information if we attempt
to add new information incrementally. When developing an artificial neural network to perform a
particular pattern-classification operation, we typically proceed by gathering a set of exemplars,
or training patterns, then using these exemplars to train the system.

During the training, information is encoded in the system by the adjustment of weight values. Once
the training is deemed to be adequate, the system is ready to be put into production, and no
additional weight modification is permitted. This operational scenario is acceptable provided the
problem domain has well-defined boundaries and is stable. Under such conditions, it is usually
possible to define an adequate set of training inputs for whatever problem is being solved.
Unfortunately, in many realistic situations, the environment is neither bounded nor stable.
Consider a simple example. Suppose you intend to train a backpropagation to recognize the
silhouettes of a certain class of aircraft. The appropriate images can be collected and used to train
the network, which is potentially a time-consuming task depending on the size of the network
required. After the network has learned successfully to recognize all of the aircraft, the training
Sandesh Singhal
period is ended and no further modification of the weights is allowed. If, at some future time,
another aircraft in the same class becomes operational, you may wish to add its silhouette to the
store of knowledge in your neural network. To do this, you would have to retrain the network with
the new pattern plus all of the previous patterns. Training on only the new silhouette could result
in the network learning that pattern quite well, but forgetting previously learned patterns. Although
retraining may not take as long as the initial training, it still could require a significant investment.

The Adaptative Resonance Theory: ART

In 1976, Grossberg (Grossberg, 1976) introduced a model for explaining biological phenomena.
The model has three crucial properties:

1. A normalisation of the total network activity. Biological systems are usually very adaptive to large
changes in their environment. For example, the human eye can adapt itself to large variations in
light intensities;
2. Contrast enhancement of input patterns. The awareness of subtle di
erences in input patterns can mean a lot in terms of survival. Distinguishing a hiding panther from
a resting one makes all the diference in the world. The mechanism used here is contrast
enhancement;
3. Short-term memory (STM) storage of the contrast-enhanced pattern. Before the input pattern can
be decoded, it must be stored in the short-term memory. The long-term memory (LTM)
implements an arousal mechanism (i.e., the classication), whereas the STM is used to cause
gradual changes in the LTM.

The system consists of two layers, F1 and F2, which are connected to each other via the LTM

Sandesh Singhal
The input pattern is received at F1, whereas classification takes place in F2. As mentioned before,
the input is not directly classified. First a characterization takes place by means of extracting
features, giving rise to activation in the feature representation field. The expectations, residing in
the LTM connections, translate the input pattern to a categorization in the category representation
field. The classification is compared to the expectation of the network, which resides in the LTM
weights from F2 to F1. If there is a match, the expectations are strengthened, otherwise the
classification is rejected.

ART1: The simplified neural network model

The ART1 simplified model consists of two layers of binary neurons (with values 1 and 0), called
F1 (the comparison layer) and F2 (the recognition layer)

Each neuron in F1 is connected to all neurons in F2 via the continuous-valued forward long term
memory (LTM) Wf , and vice versa via the binary-valued backward LTM Wb. The other modules
are gain 1 and 2 (G1 and G2), and a reset module. Each neuron in the comparison layer receives
three inputs: a component of the input pattern, a component of the feedback pattern, and a gain
G1. A neuron outputs a 1 if and only if at least three of these inputs are high: the 'two-thirds rule.'
The neurons in the recognition layer each compute the inner product of their incoming
(continuous-valued) weights and the pattern sent over these connections. The winning neuron then
inhibits all the other neurons via lateral inhibition. Gain 2 is the logical 'or' of all the elements in
the input pattern x. Gain 1 equals gain 2, except when the feedback pattern from F2 contains any
1; then it is forced to zero. Finally, the reset signal is sent to the active neuron in F2 if the input
vector x and the output of F1 dier by more than some vigilance level.

Sandesh Singhal
Operation

The network starts by clamping the input at F1. Because the output of F2 is zero, G1 and G2 are
both on and the output of F1 matches its input.The pattern is sent to F2, and in F2 one neuron
becomes active. This signal is then sent back over the backward LTM, which reproduces a binary
pattern at F1. Gain 1 is inhibited, and only the neurons in F1 which receive a 'one' from both x and
F2 remain active. If there is a substantial mismatch between the two patterns, the reset signal will
inhibit the neuron in F2 and the process is repeated.

1. Initialisation:

where N is the number of neurons in F1, M the number of neurons in F2, 0 i < N,
and 0 ≤ j <M. Also, choose the vigilance threshold ρ, 0 ≤ ρ ≤ 1;

2. Apply the new input pattern x:

3. compute the activation values y0 of the neurons in F2:


4. select the winning neuron k (0 ≤ k <M):
5. vigilance test: if

where . denotes inner product, go to step 7, else go to step 6. Note that essentially is the
inner product ,which will be large if and near to each other;

6. neuron k is disabled from further activity. Go to step 3;


7. Set for all l, 0 ≤ l < N:

Sandesh Singhal
8. re-enable all neurons in F2 and go to step 2.

An example of the behaviour of the Carpenter Grossberg network for letter patterns. The binary
input patterns on the left were applied sequentially. On the right the stored patterns (i.e., the
weights of Wb for the first four output units) are shown.

ART1: The original model

In later work, Carpenter and Grossberg (Carpenter & Grossberg, 1987a, 1987b) present several
neural network models to incorporate parts of the complete theory. We will only discuss the first
model, ART1. The network incorporates a follow-the-leader clustering algorithm (Hartigan,
1975). This algorithm tries to fit each new input pattern in an existing class. If no matching class
can be found, i.e., the distance between the new pattern and all existing classes exceeds some
threshold, a new class is created containing the new pattern. The novelty in this approach is that
the network is able to adapt to new incoming patterns, while the previous memory is not corrupted.
In most neural networks, such as the backpropagation network, all patterns must be taught
Sandesh Singhal
sequentially; the teaching of a new pattern might corrupt the weights for all previously learned
patterns. By changing the structure of the network rather than the weights, ART1 overcomes this
problem.

Sandesh Singhal
Experiment: 8
Object: Study and Analysis of Counter Propagation Network.

Counter Propagation Network (CPN):

Counter Propagation Network (CPN) is not as general as Back Propagation. But it provides a
solution for those application that cannot tolerate long training time.

It is a combination of two well-known algorithm i.e. Self-Organizing Map of Korhonen and


Grossberg out star. The training process associates the input vector with the corresponding
output vector.

These vectors may be binary or continuous. It has the generalization capability. The
generalization capability of network allows it to produce a correct output even when it is given
an input vector i.e. partially incomplete or partially incorrect.

CPN is used to compress the data before sending and decompress the data before receiving. With
the help of these network we can compress audio data up to 100:1 and video data up to 10:1.

Architecture Of CPN:

It consist of one input layer, one Kohonen layer and one Grossberg layer. All the units of input
layer are fully interconnected by weights to the units of Kohonen layer. Similarly, all the units of
Kohonen layer are fully interconnected by weights to the Grossberg layer.

It works in two mode.

1. Normal Mode -> When we apply the input vector and get the desired output.
2. Training Mode -> Apply input vector and modify the network weights so that, we get
the desired output.

Advantages of CPN:

1. It is simple and it forms a good statistical model of its input vector environment.
2. CPN trains rapidly. If appropriately applied, it can safe large amount of computer time.
3. It is also useful for rapid prototyping of system, where the greater accuracy of Back
Propagation makes it the method of choice in the final version. But a quick approximation
is important so, CPN is more useful then Back Propagation.

Sandesh Singhal
Counter Propagation is not as general as back propagation,but it provides a solution for those
applications that can not tolerate long training sessions. We Point out that in addition to
overcomeing the limitations of other networks, counter propagation has some interesting and
useful features of its own.

Counter propagation is sa combination of two well-known algorithms – The self-organizing map


of Kohonen and the Grossberg outstar.Together they posses properties not available in either one
alone.

Techniques like counter porpagation that combine network paradigims in building-block fashion
may produce Networks closer to the brain’s architecture than any homogenous structure. It Does
indeed seem that the brain Cascades varoius specialized modules to produce the desired
computation.

Counter propagation network functions as a lookup table capable of generalization. The training
process associates Input vectors with corresponding output vectors. These vectors may be in
binary, consisting of ones and zeros, or continous. Once the network is trained, application of an
input vectors produces the desired output vector. The generalization capability of the network
allows it to produce a correct output even when it is given an input vector That is partially
incomplete or partially incorrect.

The advantage of the counter propagation network is that it can be trained to perform associative
mappings much faster than a typical two layer network. Counter propagation network has been
used successfully for function approxmiation, hetero-association and the data compression, and its
training occurs much faster than the back porpagation.

Sandesh Singhal
Counter propagations can be used as a continious function approximator. Assume that the training
pairs are (xi,zi) and zi- g(x) where g is a continous function on the set of input vectors [x]. The
mean square of approximation can be made small as desired by choosing a sufficiently large
number of p of Kohonen’s layer neurons. However, for the continous function approximation, the
network is not as efficeint as error back propagation trained networks since it requires many more
neurons for comparable accuracy. Counter propagation networks can be used for rapid prototyping
of a mapping and to speed up system development, since they typically require orders of magnitude
fewer training cycles than is usally needed in error back propagation training.

Fig. Conter Propagation Network

The full counter propagation network is shown in fig. In normal operation, input vectors X and Y
are applied and the trained network produces output vectors X’ and Y’, which are approximations
of X and Y, respectively. In this case, X and Y are assumed to be normalized unit vectors; hence,
they will tend to produce normalized vectors an the output.

During training, vectors X and Y are applied both as inputs to the network and as desired outputs.
X is used to train the X’ outputs, while Y is used to train the X’ outputs, while Y is used to train
the Y’ outputs of the Gossberg layer.

The full counter propagation network is trained using the same method as for the feedforward
network. The Kohonen neurons receive inputs form both the X and Y vectors, but these are
indistinguisable form a single larger vector composed of the X and Y vectors; thus this
arrangement does not affect the training algorithm.

The result is an identity mapping in which the application of pair of input vectors produces their
replicas on the Output. They do not seem very intresting until one realizes that applying only the
X vector (With the Y vector set to 0) produces both the X’ and Y’ outputs, if F is a function
mapping X to Y’, then the network approximates it. Also, if the inverse of F exists, applying only
the Y vector (setting X to 0) produces X’. This unique ability to generate a function and its inverse
makes the counter propagation network useful in a number of applications.

The main diffrence between full and forward only counter porpagation neural network is that the
former treats both ip and dp without any special preference; both function similarly in finding the
Sandesh Singhal
winner cluster node of the hidden layer. The full counter propagation neural network is designed
to function in both directions-

1. To predict ip, given dp


2. To predict dp, given ip

As in the forward counter popagation, the training set consists of many patterns –
{(ip,dp):p=1,…..,P} and the network is trained in two phases. Initially, all sets of weights assigned
random values between 0 and 1. The first phase adjusts the weights associated with connections
leading into the hidden nodes. This part of training algorithm is similar to the first phase of the
forward algorithm except that ip and dp are both used in this process. The main porpose of the
second phase is to adjust the weights associated with the connections leading away from the hidden
nodes. When training is completed the network can be used in either direction.

Sandesh Singhal
EXPERIMENT-9

Object: Study and analysis of Genetic Algorithm on the basis of following

(iv) Basic concept


(v) Working principle
(vi) Advantages & Disadvantage

Basic concept:

In the computer science field of artificial intelligence, a genetic algorithm (GA) is


a search heuristic that mimics the process of natural evolution. This heuristic is routinely used to
generate useful solutions to optimization and search problems. Genetic algorithms belong to the
larger class of evolutionary algorithms (EA), which generate solutions to optimization problems
using techniques inspired by natural evolution, such as inheritance, mutation, selection,
and crossover.
It is a heuristic search algorithm based on the mechanism of biological evolution. On the evolution
of biological diversity is the variation among individual organisms of the chromosome. Variations
of this chromosome will affect the rate of reproduction and level of ability of organisms to stay
alive.
In these algorithms, search techniques performed well on a number of possible solutions are known
as populations. Individuals who present in a population referred to as chromosomes. This
chromosome is a solution that was shaped symbol. Initial population is built randomly, while the
next population is the result of the evolution of chromosomes through the iterations are referred to
as generations. In each generation, chromosomes are going through the evaluation process by using
a measuring instrument called a fitness function. The fitness of a chromosome will show the quality
of the chromosomes in the population. The next generation is known as a child (offspring) formed
from the combination of two chromosomes present generation that acts as a parent (the parent) by
crossing operator (crossover). In addition to crossing operators, a chromosome can also be
modified by using mutation operators. Population new generation is formed by selecting the fitness
of the parent chromosome (parent) and child fitness values of chromosomes (offspring), and reject
the other chromosomes so that the population size (number of chromosomes in a population)
constant. After going through several generations, then the algorithm will converge to the best
chromosome.

Genetic Algorithm is a search heuristic (experience) that follows the process of natural evolution.
This heuristic is used to generate useful solutions to optimization and search problems.Genetic
Algorithm belong to the larger class of evolutionary algorithm (EA) which generate solutions to
Sandesh Singhal
optimization problems and using techniques inspired by natural evolution like – inheritance,
mutation, selection, crossover. Genetic Algorithm need design space to be converted into genetic
space. Genetic Algorithm works with coding variables.. Genetic Algorithm uses population of
point at one time in contrast to the single point approach. It means that genetic algorithm processes
a number of designs at the same time. The advantage of coding of variable is that coding
discretizes the search space even though the function may be continuous. Traditional optimization
methods use transition rules that are deterministic in nature. While genetic algorithm uses
randomize operators. Randomize operator improve the search space in an adaptive manner.

There are three important aspects of Genetic Algorithm are-

1. Definition of objective function.


2. Definition and implementation of genetic representation.
3. Definition and implementation of Genetic operators.

Working principle-

In a genetic algorithm, a population of strings (called chromosomes or the genotype of


the genome), which encode candidate solutions (called individuals, creatures, or phenotypes) to an
optimization problem, evolves toward better solutions. Traditionally, solutions are represented in
binary as strings of 0s and 1s, but other encodings are also possible. The evolution usually starts
from a population of randomly generated individuals and happens in generations. In each
generation, the fitness of every individual in the population is evaluated, multiple individuals
are stochastically selected from the current population (based on their fitness), and modified
(recombined and possibly randomly mutated) to form a new population. The new population is
then used in the next iteration of the algorithm. Commonly, the algorithm terminates when either
a maximum number of generations has been produced, or a satisfactory fitness level has been
reached for the population. If the algorithm has terminated due to a maximum number of
generations, a satisfactory solution may or may not have been reached.

A typical genetic algorithm requires:

(1) A genetic representation of the solution domain,


(2) A fitness function to evaluate the solution domain.

A standard representation of the solution is as an array of bits. Arrays of other types and structures
can be used in essentially the same way. The main property that makes these genetic
representations convenient is that their parts are easily aligned due to their fixed size, which
facilitates simple crossover operations. Variable length representations may also be used, but
crossover implementation is more complex in this case. Tree-like representations are explored
in genetic programming and graph-form representations are explored in evolutionary
programming.
Sandesh Singhal
The fitness function is defined over the genetic representation and measures the quality of the
represented solution. The fitness function is always problem dependent. For instance, in
the knapsack problem one wants to maximize the total value of objects that can be put in a
knapsack of some fixed capacity. A representation of a solution might be an array of bits, where
each bit represents a different object, and the value of the bit (0 or 1) represents whether or not the
object is in the knapsack. Not every such representation is valid, as the size of objects may exceed
the capacity of the knapsack. The fitness of the solution is the sum of values of all objects in the
knapsack if the representation is valid, or 0 otherwise. In some problems, it is hard or even
impossible to define the fitness expression; in these cases, interactive genetic algorithms are used.

Once the genetic representation and the fitness function are defined, a GA proceeds to initialize a
population of solutions (usually randomly) and then to improve it through repetitive application of
the mutation, crossover, inversion and selection operators.

Initialization

Initially many individual solutions are (usually) randomly generated to form an initial population.
The population size depends on the nature of the problem, but typically contains several hundreds
or thousands of possible solutions. Traditionally, the population is generated randomly, allowing
the entire range of possible solutions (the search space). Occasionally, the solutions may be
"seeded" in areas where optimal solutions are likely to be found.

Selection

During each successive generation, a proportion of the existing population is selected to breed a
new generation. Individual solutions are selected through a fitness-based process,
where fitter solutions (as measured by a fitness function) are typically more likely to be selected.
Certain selection methods rate the fitness of each solution and preferentially select the best
solutions. Other methods rate only a random sample of the population, as the latter process may
be very time-consuming.

Reproduction

The next step is to generate a second generation population of solutions from those selected
through genetic operators: crossover (also called recombination), and/or mutation.

For each new solution to be produced, a pair of "parent" solutions is selected for breeding from
the pool selected previously. By producing a "child" solution using the above methods of crossover
Sandesh Singhal
and mutation, a new solution is created which typically shares many of the characteristics of its
"parents". New parents are selected for each new child, and the process continues until a new
population of solutions of appropriate size is generated. Although reproduction methods that are
based on the use of two parents are more "biology inspired", some research suggests that more
than two "parents" generate higher quality chromosomes.

These processes ultimately result in the next generation population of chromosomes that is
different from the initial generation. Generally the average fitness will have increased by this
procedure for the population, since only the best organisms from the first generation are selected
for breeding, along with a small proportion of less fit solutions, for reasons already mentioned
above.

Although Crossover and Mutation are known as the main genetic operators, it is possible to use
other operators such as regrouping, colonization-extinction, or migration in genetic algorithms.

Termination

This generational process is repeated until a termination condition has been reached. Common
terminating conditions are:

(1) A solution is found that satisfies minimum criteria


(2) Fixed number of generations reached
(3) Allocated budget (computation time/money) reached
(4) The highest ranking solution's fitness is reaching or has reached a plateau such that
successive iterations no longer produce better results
(5) Manual inspection
(6) Combinations of the above.

Simple generational genetic algorithm procedure:

(1) Choose the initial population of individuals


(2) Evaluate the fitness of each individual in that population
(3) Repeat on this generation until termination (time limit, sufficient fitness achieved, etc.):
(4) Select the best-fit individuals for reproduction
(5) Breed new individuals through crossover and mutation operations to give birth
to offspring
(6) Evaluate the individual fitness of new individuals
Sandesh Singhal
(7) Replace least-fit population with new individuals.

Genetic Algorithm Steps :-

1. BEGIN
2. Create initial population ;
3. Compute fitness of each individuals ;
4. WHILE NOT finished DO Loop
5. BEGIN
6. Select individuals from old generation for mating ;
7. Create offspring by applying crossover or mutation to the selected individuals ;
8. Compute fitness of new individuals ;
9. Kill old individuals to make a room for new chromosomes and insert offspring in the new
generation ;
10. If population has converged
11. Then fitness=TRUE ;
12. END
13. END

ADVANTAGES & DISADVANTAGES-

Advantages-

➢ The first and most important point is that genetic algorithms are intrinsically parallel. Most other
algorithms are serial and can only explore the solution space to a problem in one direction at a
time, and if the solution they discover turns out to be suboptimal, there is nothing to do but abandon
all work previously completed and start over. However, since GAs have multiple offspring, they
can explore the solution space in multiple directions at once. If one path turns out to be a dead end,
they can easily eliminate it and continue work on more promising avenues, giving them a greater
chance each run of finding the optimal solution.
➢ Due to the parallelism that allows them to implicitly evaluate many schema at once, genetic
algorithms are particularly well-suited to solving problems where the space of all potential
solutions is truly huge - too vast to search exhaustively in any reasonable amount of time. Most
problems that fall into this category are known as "nonlinear". In a linear problem, the fitness of
each component is independent, so any improvement to any one part will result in an improvement
of the system as a whole.
➢ Another notable strength of genetic algorithms is that they perform well in problems for which the
fitness landscape is complex - ones where the fitness function is discontinuous, noisy, changes
over time, or has many local optima. Most practical problems have a vast solution space,
impossible to search exhaustively; the challenge then becomes how to avoid the local optima -
Sandesh Singhal
solutions that are better than all the others that are similar to them, but that are not as good as
different ones elsewhere in the solution space. Many search algorithms can become trapped by
local optima: if they reach the top of a hill on the fitness landscape, they will discover that no better
solutions exist nearby and conclude that they have reached the best one, even though higher peaks
exist elsewhere on the map.
Evolutionary algorithms, on the other hand, have proven to be effective at escaping local optima
and discovering the global optimum in even a very rugged and complex fitness landscape.
➢ However, crossover is the key element that distinguishes genetic algorithms from other methods
such as hill-climbers and simulated annealing. Without crossover, each individual solution is on
its own, exploring the search space in its immediate vicinity without reference to what other
individuals may have discovered. However, with crossover in place, there is a transfer of
information between successful candidates - individuals can benefit from what others have
learned, and schemata can be mixed and combined, with the potential to produce an offspring that
has the strengths of both its parents and the weaknesses of neither.
➢ Another area in which genetic algorithms excel is their ability to manipulate many parameters
simultaneously Many real-world problems cannot be stated in terms of a single value to be
minimized or maximized, but must be expressed in terms of multiple objectives, usually with
tradeoffs involved: one can only be improved at the expense of another. GAs are very good at
solving such problems: in particular, their use of parallelism enables them to produce multiple
equally good solutions to the same problem.

Advantages of Genetic Algorithm (GA) :-

1. It shows simplicity.
2. Ease of operation.
3. Minimal requirement.
4. Global perspective.
5. It does not guarantee to find global minimum solutions but acceptably good solutions to
“acceptably quickly “.

Disadvantages-

Although genetic algorithms have proven to be an efficient and powerful problem-solving strategy,
they are not a panacea. GAs do have certain limitations; however, it will be shown that all of these
can be overcome and none of them bear on the validity of biological evolution.

➢ The first, and most important, consideration in creating a genetic algorithm is defining a
representation for the problem. The language used to specify candidate solutions must be robust;

Sandesh Singhal
i.e., it must be able to tolerate random changes such that fatal errors or nonsense do not consistently
result.
➢ The problem of how to write the fitness function must be carefully considered so that higher fitness
is attainable and actually does equate to a better solution for the given problem. If the fitness
function is chosen poorly or defined imprecisely, the genetic algorithm may be unable to find a
solution to the problem, or may end up solving the wrong problem.
➢ In addition to making a good choice of fitness function, the other parameters of a GA - the size of
the population, the rate of mutation and crossover, the type and strength of selection - must be also
chosen with care. If the population size is too small, the genetic algorithm may not explore enough
of the solution space to consistently find good solutions. If the rate of genetic change is too high
or the selection scheme is chosen poorly, beneficial schema may be disrupted and the population
may enter error catastrophe, changing too fast for selection to ever bring about convergence.
➢ One type of problem that genetic algorithms have difficulty dealing with are problems with
"deceptive" fitness functions those where the locations of improved points give misleading
information about where the global optimum is likely to be found
➢ One well-known problem that can occur with a GA is known as premature convergence. If an
individual that is more fit than most of its competitors emerges early on in the course of the run, it
may reproduce so abundantly that it drives down the population's diversity too soon, leading the
algorithm to converge on the local optimum that that individual represents rather than searching
the fitness landscape thoroughly enough to find the global optimum

Sandesh Singhal
Flowchart of Genetic Algorithm (GA) :-

Sandesh Singhal
EXPERIMENT-10

Object: Study and analysis of fuzzy Vs crisp logic.

FUZZY LOGIC: Fuzzy logic is a form of many valued Logic. It deals with reasoning i.e.
approximate or inexact.

Fuzzy logic has been extended to handle the concept of partial truth where the truth value will be
in the range between completely true and completely false.

Fuzzy logic began with the 1965 by Lotfi Zadeh. Fuzzy logic has been applied to many fields
from control theory to artificial intelligence.

CRISP LOGIC: In older days, Crisp logic was used to handle the problem of binary value i.e., 0
and 1. Crisp logic is also known as traditional, conventional or binary logic.

Crisp logic have two valued logic first is true and other is false. Crisp logic is based on the
reasoning which is exact and fixed. It is based on the logic of completely true and completely
false.

We can define completely true as one (1) and completely false as zero (0).
Sandesh Singhal
Sandesh Singhal

You might also like