0% found this document useful (0 votes)
9 views81 pages

SC Mod 4

This document covers Fuzzy Inference Systems (FIS) and Genetic Algorithms (GA), detailing their structures, methods, and applications. FIS utilizes fuzzy logic for decision-making through rules and defuzzification, while GA employs evolutionary principles for optimization. Both systems are compared to conventional methods, highlighting their advantages and unique characteristics.

Uploaded by

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

SC Mod 4

This document covers Fuzzy Inference Systems (FIS) and Genetic Algorithms (GA), detailing their structures, methods, and applications. FIS utilizes fuzzy logic for decision-making through rules and defuzzification, while GA employs evolutionary principles for optimization. Both systems are compared to conventional methods, highlighting their advantages and unique characteristics.

Uploaded by

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

MODULE 4


Fuzzy Inference System & Genetic algorithm
Fuzzy Inference Systems (FIS )

The key unit of a fuzzy logic system is FIS.

Fuzzy Inference System (FIS) is a process to interpret the values of the input vector and, on
the basis of some sets of fuzzy rules, it assigns corresponding values to the output vector.

This is a method to map an input to an output using fuzzy logic.

Fuzzy rule based systems, fuzzy models, and fuzzy expert systems are generally known as fuzzy
inference systems.

The primary work of this system is decision making.

FIS uses "IF THEN " rules along with connectors "OR" or "AND " for making necessary decision
rules.

The input may be fuzzy or crisp, but the output is always a fuzzy set.

Characteristics of FIS

Input to FIS may be fuzzy or crisp, but the output from FIS is
always a fuzzy set.

When FIS is used as a controller, it is necessary to have a crisp
output.

A defuzzification unit would be there with FIS to convert fuzzy
variables into crisp variables
Construction and Working Principle of FIS

1. Rule base : It contains fuzzy IF...THEN rules. Eg : IF A1 ∩ A2, perform min.

2. Database: It defines the membership functions of fuzzy set used in fuzzy rule. eg : in
above eg, We have to do min of µA1 and µA2 values. These values and membership
functions are stored in database.

3. Fuzzification Interface unit: It converts crisp quantity to fuzzy quantity.

4. Decision making unit: Input to this unit is a fuzzy quantity. It performs operations based
on IF-THEN rules

5. Defuzzification interface unit: It converts fuzzy quantity to crisp quantity
Methods of FIS
a. Mamdani FIS

Basically, it was anticipated to control a steam engine and boiler combination by
synthesizing a set of fuzzy rules obtained from people working on the system.

Eg1: rule1: If steam is x1 amount, then output will be output1

Eg2: rule2: If steam is less by x2 amount, then output will be output2 etc

When we give an input, decision should be made based on these rules

The output membership functions are expected to be fuzzy sets.

After aggregation process, each output variable contain a fuzzy set, hence
defuzzification is important at the output stage to get crisp data.

The fuzzy rules are formed using " IF THEN " statements and " AND-OR "
connectives.

The consequence of the rule can be obtained in two steps:
– 1. by computing the rule strength completely using the fuzzified inputs from the
fuzzy combination.
– 2. by clipping the output membership function at the rule strength.

The output of all the fuzzy rules are combined to obtain one fuzzy output
distribution. From FIS, it is desired to get only one crisp output.

So, this crisp output is obtained through defuzzification process.

IF x1 is A1 and x2 is A2, THEN y is B

Here, ‘x1 is A1’ and ‘x2 is A2’ are called antecedents

‘y is B’ is called consequence or conclusion

x1 and x2 are the input points we are going to give.

A1 and A2 are the input fuzzy sets

Y is the output point in the output fuzzy set B

Consider 2 rules:

Rule 1: if x0 is A10 and y0 is A20, then z0 is B0

Rule 2: if x0 is A11 and y0 is A21, then z0 is B1

Calculate result of each. Then find the aggregated area
A two input, two rule Mamdani FIS with a fuzzy input
Advantages of Mamdani FIS

It has widespread acceptance.

it is well suited for human input.

It is intuitive.
b. Takagi Sugeno Fuzzy Model(TS Method)

The format of the fuzzy rule of a Sugeno fuzzy model is
given by,

Where

A and B are fuzzy sets in the antecedents

z = f (x , y ) is a crisp function in the consequent

Difference between mamdani and sugeno is that the consequence is a crisp
function instead of a fuzzy set.

Generally, f (x , y ) is a polynomial in the input variables x and y.

If z = f (x , y ) is a first order polynomial, we get first order Sugeno fuzzy model.

If result of f is a constant, we get zero order Sugeno fuzzy model.

Here, antecedents : fuzzy and consequence: f(inputs)

Eg: IF x1 is A1k and x2 is A2k, THEN output y is f(x1,x2)

Sugeno output membership functions are either linear or constant.

Calculate the output yk by performingweighted
average using y1, y2, α1, α2

Sugeno rule: IF x = 3 and y = 5 then output is z = ax + by + c
Advantages of TS Method

It is computationally efficient.

It is compact and works well with linear technique, optimization technique
and adaptive technique.

It is best suited for mathematical analysis.

It has a guaranteed continuity on the output surface.
What are Genetic Algorithms?


GAs are adaptive heuristics search algorithm based on the evolutionary ideas of natural
selection and genetics.

It is a Search based optimization technique based on principles of genetics and natural
selection.

Frequently used to find optimal/near solutions to difficult problems which otherwise
would take a lifetime to solve.

Optimization is the process of making something better.

It refers to finding the values of inputs in such a way that we get the ‘best’ output values

The main idea is survival of the fittest.
Biological background

The science that deals with the mechanisms responsible for similarities and differences in a species is called genetics.

It helps us to differentiate between heredity and variations during the process of evolution.
Terminologies
a. The Cell

Every animal/human cell is a complex of many small factories that work together.

Center of this is cell nucleus.

The genetic information is contained in the cell nucleus.
b. Chromosomes

All the genetic information gets stored in the chromosomes.

Each chromosome is build of DNA.

In humans, chromosomes exist in pairs.

Chromosomes are divided into several parts called genes.

Genes code the properties of species.

Genes determine traits in an individual eg:skin, hair or eye colour

The combination of genes for one property are called alleles. Alleles are responsible for diverse features of a given
trait .Examples: Black, brown, blue or green eyes colour

Set of all possible alleles present in a particular population forms gene pool.

Size of gene pool determines the diversity of the individual in the population.

Set of all the genes of a specific species is called genome.

Each and every gene has a unique position on the genome called locus.

Entire combination of genes is called genotype.
Terminology relationships between natural evolution and genetic algorithm
Genetic Algorithm
Why Genetic Algorithms?

They are better than conventional algorithms.

They are more robust.

They do not break easily even if the inputs are changed slightly or in the
presence of reasonable noise.
Comparison
GA differs from conventional optimization techniques in following ways

I. GAs operate with coded versions of the problem parameters rather than parameters
themselves, i.e., GA works with the coding of solution set and not with the solution
itself.

2. Almost all conventional optimization techniques search from a single point, but
GAs always operate on a whole population of points (strings), i.e., GA uses
population of solutions rather than a single solution for searching. This plays a major
role to the robustness of GAs. It improves the chance of reaching the global optimum
and also helps in avoiding local stationary point.

3. GA uses fitness function for evaluation rather than derivatives. As a result, they
can be applied to any kind of continuous or discrete optimization problem. The key
point to be performed here is to identify and specify a meaningful decoding function.

4. GAs use probabilistic transition operates while conventional methods for
continuous optimization apply deterministic transition operates, i.e., GAs do not use
deterministic rules.
Advantages of GA

Limitations of GA
Applications of Genetic Algorithm
Operators in Genetic Algorithm

1. ENCODING
1. Encoding

Encoding is a process of representing individual genes.

The process can be performed using bits, numbers, trees, arrays, lists .

It depends mainly on solving the problem.
Encoding Methods
a.Binary Encoding

The most common way of encoding is a binary (bit ) string.

Each chromosome encodes a binary (bit) string.

Ie, Binary coded strings with 1s and 0s.

Each bit in the string represent some characteristics of the solution.

Every bit string therefore is a solution but not necessarily the best solution.

The whole string can represent a number.

The way bit strings can code differs from problem to problem.Binary encoding gives many possible
chromosomes with a smaller number of alleles.

The length of the string depends on the accuracy.
– Integers are represented exactly.
– Finite number of real numbers can be represented.
– Number of real numbers represented with string length.
b.Octal Encoding

Octal encoding uses string made up of octal numbers (0 -7 ) to represent genes.

c. Hexadecimal Encoding

Hexadecimal encoding uses string made up of hexadecimal

numbers ( 0- 9, A -F ).
d. Permutation Encoding ( Real Number Coding )

Every chromosome is a string of numbers, represented in a sequence.

In Permutation encoding, every chromosome is a string of integer/real values, which
represent number in a sequence.

It is useful for ordering problems.eg: Travelling through n cities where order is important

e. Value Encoding

In Value encoding, every chromosome is a string of some values.

Values can be anything connected to problem, numbers, real numbers or characters.

Value encoding is very good for some special problems.
f. Tree Encoding

Tree encoding is mainly used for evolving program expressions for genetic
programming.

Eg: for programs that involve if,if then, if then else cases

Every chromosome is a tree of some objects such as functions and
commands of a programming language.
Population
Population initialization
Fitness function
2. SELECTION
2. Selection

Selection is the process of choosing two parents from the population for crossing.

Selection is a method that picks chromosomes out of the population according to their
evaluation function.

The selection pressure is defined as the degree to which the better individuals are
favored.

The purpose of selection is to emphasize fitter individuals in the population in
hopes that their offspring have higher fitness.

Convergence rate of the GA is largely determined by magnitude of the selection
pressure.
Types of Selection scheme
1. Proportionate based selection picks out individuals based upon their fitness values relative to the fitness of the other
individuals in the population.

Every individual can become a parent with a probability which is proportional to its fitness.

But, Fitter individuals have a higher chance of mating and propagating their features to next generation.

It is the most popular scheme.
2. Ordinal based selection select individuals not upon their raw fitness, but upon their rank within the population.
– This requires that the selection pressure is independent of the fitness distribution of the population, and is solely based
upon the relative ordering (ranking) of the population.
3. Random based : selects individuals from population randomly.

The picked individuals may not necessarily be of highest fitness value.

Selection Methods

Roulette Wheel Selection

Random Selection

Rank Selection

Tournament Selection

Boltzmann Selection

Stochastic Universal Sampling
a. Roulette Wheel Selection

Roulette selection is one of the traditional GA selection techniques.

The commonly used reproduction operator is the proportionate reproductive operator where a string is selected from the
mating pool with a probability proportional to the fitness.

The principle of Roulette Selection is a linear search through a Roulette wheel with the slots in the wheel weighted in
proportion to the individual’s fitness values.

A target value is set which is a random proportion to the sum of the fitness in the population.

The population is stepped through until the target value is reached.

This is only a moderately strong selection technique, since fit individuals are not guaranteed to be selected for, but
somewhat have a greater chance.

A fit individual will contribute more to the target value, bur if it does not exceed it, the next chromosome in line has a chance,
and it may be weak.

A fixed point is chosen on the wheel circumference and the wheel is rotated.

The region of the wheel which comes infront of the fixed point is chosen as parent.

For the second parent, same process is repeated.

Roulette wheel selection is easier to implement but
is noisy.

The rate of evolution depends on the variance of
fitness's in the population.
b. Random Selection

Random selection randomly selects a parent from the Population.

There is no selection pressure towards fitter individuals.

In terms of disruption of generic codes, random selection is a little more disruptive, on
average, than Roulette wheel selection.
c. Rank Selection

This method also works with negative fitness values.

Mostly used when the individuals in the population have very close fitness values.

This leads to almost equal share of the pie by each individual.

Thus, each individual no matter how fit relative to each other has an approximately same
probability of getting selected as a parent.

So, here we remove the concept of fitness value. However, every individual in population is
ranked according to their fitness.

Selection of the parents depends on the rank of each individual.

The highest ranked individuals are preferred more than lowest ranked ones.

It preserves diversity and hence leads to successful search.
d. Tournament Selection

Tournament Selection strategy provides selective pressure by holding a tournament
competition among n individuals.

We select k individuals from population at random and select the best out of these to
become parent.

The same process is repeated for selecting the next parent.

Selected parents may not be of highest fitness score in the population
e. Boltzmann Selection

Based on the process of slow cooling of molten metal.

Boltzmann concept: Maximum energy of a metal depends on the ambient temperature.

Probability of energy generated, P(E)=exp(-E/kT)

In GA, for an individual, E= Fmax(x)-F(xi)

In Boltzmann Selection a continuously varying temperature controls the rate of selection according to a
present schedule.

The temperature starts out high, which means that the selection pressure is low.

The temperature is gradually lowered by the passage of time, which gradually increases the selection
pressure, thereby allowing the GA to narrow in more closely to the best part of the search space while
maintaining the appropriate degree of diversity.
● Ie, the selection will be biased towards individuals with better fitness.

Outdated and rarely used method
k


NOTE: G is the maximum number of generations to be generated. k is the
Boltzmann constant

Final state is reached when T =0
f. Stochastic Universal Sampling

Stochastic Universal Sampling provides zero bias and minimum spread

The individuals are mapped to contiguous segments of a line such that each
individual’s segment is equal in size to its fitness.

Here, equally spaced pointers are placed over the line, as many as there are
individuals to be selected.

Stochastic universal sampling is quite similar to Roulette wheel selection.

Difference: Instead of having just one fixed point, we have multiple fixed points.

Thus, all the parents are chosen in just one spin of the wheel.
3. CROSSOVER
3. Crossover( Recombination )

Crossover is the process of taking two parent solutions and producing a child from them.

After the selection process, the population is enriched with better individuals.

Reproduction makes clones of good strings but does not create new ones.

Crossover is a genetic operator used to vary the programming of a chromosome or
chromosomes from one generation to the next.

Crossover is a recombination operator that proceeds in three steps:
– The reproduction operator selects at random, a pair of two individual string for the
mating.
– A cross site (/cross point) is selected at random along the string length.
– Finally, the position values are swapped between the two strings following the cross site.
Crossover Techniques
i). Single Point Crossover

A single crossover point on the parent string is selected.

All data beyond that point in the organism string is swapped between the two
parent organisms.

ie, all bits next to the cross point are exchanged
ii).Two-Point Crossover

Two random points are chosen on the individual chromosomes (strings) and the
genetic material is exchanged at these points.

ie, 2 points are chosen and contents between these points are exchanged to produce
children.
iii). Multipoint crossover

Step 1- Select two parents for mating.


Step 2- Select multiple crossover points at random and swap the bits at the alternate
sites.


After crossover, the new offsprings generated look as follows:
iv). Uniform Crossover:

Each gene (bit) is selected randomly from one of the corresponding genes of the parent chromosomes.

Eg1: Use tossing of a coin as an example technique


Eg2: A binary crossover mask of same length of the parent chromosomes can also be generated
randomly for each parent set to determine the offsprings
v. Three parent crossover

3 parents are randomly chosen.

Each bit of the first parent is compared with the bit of the second parent.

If both are same, the bit is taken for the offspring,otherwise the bit is taken from the
3rd parent.


Repeat the same steps to generate offsprings O2 and O3 using (P1, P3, P2) and (P2,
P3, P1) combinations respectively.
vi. Crossover with reduced surrogate

Always produce new individuals whenever possible.

This is implemented by restricting the location of crossover points such that crossover points
only occur where gene values in 2 parents differ.

This method reduces the chance of producing duplicate offsprings.

Step 1: A list of crossover points where gene difference occurs is saved

Step2: Randomly select a crossover point & the information of parents are copied to
offsprings by interchanging at crossover points

Eg: Parent 1 11100010
Parent 2 01001000


Both parents differ by genes at positions 1,3,5,7 Parent 1 11100010
Parent 2 01001000

Randomly choose a crossover point from the list . Let it be 5.

New offspring created is o1 11100000

o2 01001010
Vii. Shuffle crossover

Shuffle crossover is similar to uniform crossover.

Difference is that uniform crossover exchanges bits, not segments.

A single crossover position (as in single point crossover) is selected.

But before the variables are exchanged, they are randomly shuffled in both parents.

After recombination, the variables in the offspring are unshuffled(means reshuffle in reverse).

This removes positional bias as the variables are randomly reassigned each time crossover is
performed.

Eg : consider 2 parents Parent 1 11010000
Parent 2 01101001

Determine a single crossover point
Parent 1 11010000
Parent 2 01101001

Before exchanging, randomly shuffle in both parents


Parents after shuffling are :
Parent 1 11000001
Parent 2 01011100


Combining the shuffled parents, offsprings obtained are:


Reshuffle back the genes in the offspring, we get
offspring1 11101000
offspring2 01010001
Viii. Precedence preservative crossover
Mainly developed for routing problems.
Steps
1. A vector representing the no.of operations involved in the problem is randomly filled with elements of the
set {1,2}
2. This vector defines the order in which operations are successively drawn from p1 and p2.
3. Parents & offsprings are lists where “append” and “delete” are defined.
4. Initialize offspring as empty
5. Leftmost operation in one of the parents are selected based on precedence of vector defined.
6. After operation is selected, it is deleted in both parents.
7. selected operation is appended to offspring.
8. Repeat till parents are empty & offsprings contains all the operations involved.
P1 A B C D E F
P2 C A B F D E
Select parent 1 2 1 1 2 2
(vector)
1: So consider p1. A is chosen. Append A to offspring & delete A from both P1 and P2.
O=A, P1= B C D E F and P2= C B F D E
2: So consider P2. C is chosen. Append C to offspring & delete C from both P1 and P2
O=A C, p1=B D E F and P2= B F D E
1: So consider P1. B is chosen. Append B to offspring & delete B from both P1 and P2
O= A C B, p1=D E F and P2= F D E
1: So consider P1. D is chosen. Append D to offspring & delete D from both P1 and P2
O= A C B D, p1= E F and P2= F E
2: So consider P2. F is chosen. Append F to offspring & delete F from both P1 and P2
O= A C B D F , p1= E and p2=E P1 A B C D E F
2: So consider P2. E is chosen. Append E to offspring & delete E from both P1 and P2 P2 C A B F D E
O=A C B D F E, p1= empty and p2= empty Select parent 1 2 1 1 2 2
(vector)
offspring A C B D F E
ix. Ordered crossover

Ordered two point crossover is used when problem is order based. Eg: u-shaped assembly,
line balancing etc.

Given 2 parents. Choose 2 random crossover points partitioning into left, right and middle.

Child 1 inherits left & right from parent1, its middle is determined by the genes in the
middle section of parent1 in order in which these values appear in parent2.

Similarly, Child 2 inherits left & right from parent2, its middle is determined by the
genes in the middle section of parent2 in order in which these values appear in
parent1.
x. Partially matched crossover

Can be used in travelling salesman problem where permutation coding is used.

Step 1: Two chromosomes are alligned.

Step 2: Select two crossover points

Step 3: Exchange operation is done in middle section position by position.

Step 4: Alleles are moved to their new position in the offspring

Eg:

Chromosome1: 9 8 4 5 6 7 1 3 2 10

Chromosome2: 8 7 1 2 3 10 9 5 4 6

Consider the above 2 strings

After applying position wise exchange, the 2 offsprings obtained (ie, by exchanging 2 &5, 6&3, 7&10 )
are:

O1: 9 8 4 2 3 10 1 6 5 7

O2: 8 10 1 5 6 7 9 2 4 3
4. MUTATION
Mutation

Crossover exploits the current solution to find better ones.

Whereas mutation helps to explore the whole search space.

It introduce new genetic structures in the population by randomly modifying some of its building blocks.

It maintains diversity in the population.

In case of binary representation, mutation is inversing of bits 0 to1 and 1 to 0
Mutation probability(pm): It decides how often parts of chromosome will be mutated.
– If pm is 100%, whole chromosome is mutated, if pm is 0%, then nothing is changed.
Crossover probability(pc): It describes how often crossover will be performed.
– If no crossover, offsprings will be exact copies of parents.
– If there is crossover, offspring is made from both parent’s chromosome.
– If pc is 100%, all offsprings are made by crossover.
– If pc is 0%, new generation doesnt contain any new offsprings.
Different types of mutation
1. Flipping

Flipping involves changing 0 to 1 and 1 to 0 based on a mutation chromosome
generated.

For a 1 in mutation chromosome, the corresponding bit in parent chromosome is
flipped(0 to1 and 1 to 0) and child chromosome is produced.
2. Interchanging/ swap mutation

Two random positions of the string are chosen and the bits corresponding to those positions are
interchanged

3. Reversing

A random position is chosen and all the bits next to that position are reversed and thus child is produced.

Suppose chosen position is 6, then the bits 7 & 8 are reversed.
4. Scramble mutation

It is popular with permutation representation.

A subset of genes is chosen from the entire chromosome & their values are
scrambled / shuffled randomly

Parent 0123456789
Child 0136425789

We know, the flowchart of GA is :
Stopping Condition for Genetic Algorithm Flow

1. Maximum generations: The GA stops when the specified number of generations
has evolved.

2. Elapsed time : The genetic process will end when a specified time has elapsed.
– Note: If the maximum number of generation has been reached before the specified
time has elapsed, the process will end.

3. No change in fitness: The genetic process will end if there is no change to the
population's best fitness for a specified number of generations.
– Note: If the maximum number of generation has been reached before the specified
number of generation with no changes has been reached, the process will end.

4. Stall generations: The algorithm stops if there is no improvement in the objective
function for a sequence of consecutive generations of length "Stall generations."

5. Stall time limit : The algorithm stops if there is no improvement in the objective
function during an interval of time in seconds equal to "Stall time limit."

The termination or convergence criterion finally brings the search to a halt.

The following are the few methods of termination techniques.

You might also like