You are on page 1of 69
Genetic Algorithms and Fuzzy Logic
Genetic Algorithms and
Fuzzy Logic
Introduction  After scientists became disillusioned with classical and neo-classical attempts at modeling intelligence, they looked
Introduction
After scientists became disillusioned with
classical and neo-classical attempts at
modeling intelligence, they looked in other
directions.
Two prominent fields arose, connectionism
(neural networking, parallel processing) and
evolutionary computing.
It is the latter that this essay deals with -
genetic algorithms and genetic programming.
What is GA  A genetic algorithm (or GA) is a search technique used in computing
What is GA
A genetic algorithm (or GA) is a search technique
used in computing to find true or approximate
solutions to optimization and search problems.
Genetic algorithms are categorized as global search
heuristics.
Genetic algorithms are a particular class of
evolutionary algorithms that use techniques inspired
by evolutionary biology such as inheritance,
mutation, selection, and crossover (also called
recombination).
What is GA  Genetic algorithms are implemented as a computer simulation in which a population
What is GA
Genetic algorithms are implemented as a computer
simulation in which a population of abstract
representations (called chromosomes or the genotype
or the genome) of 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.
What is GA  The evolution usually starts from a population of randomly generated individuals and
What is GA
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
selected from the current population (based on their
fitness), and modified (recombined and possibly
mutated) to form a new population.
What is GA  The new population is then used in the next iteration of the
What is GA
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.
Simple Genetic Algorithm produce an initial population of individuals evaluate the fitness of all individuals while
Simple Genetic Algorithm
produce an initial population of individuals
evaluate the fitness of all individuals
while termination condition not met do
select fitter individuals for reproduction
recombine between individuals
mutate individuals
evaluate the fitness of the modified individuals
generate a new population
End while
7
The Evolutionary Cycle parents selection modification modified offspring initiate & population evaluation evaluate evaluated offspring deleted
The Evolutionary Cycle
parents
selection
modification
modified
offspring
initiate &
population
evaluation
evaluate
evaluated offspring
deleted
members
discard
Introduction to Genetic Algorithms
8
Key terms Individual - Any possible solution  Population - Group of all individuals  Search
Key terms
Individual - Any possible solution
Population - Group of all individuals
Search Space - All possible solutions to the problem
Chromosome - Blueprint for an individual
Trait - Possible aspect (features) of an individual
Allele - Possible settings of trait (black, blond, etc.)
Locus - The position of a gene on the chromosome
Genome - Collection of all chromosomes for an
individual
Chromosome, Genes and Genomes
Chromosome, Genes and
Genomes
Genotype and Phenotype Genotype:  – Particular set of genes in a genome Phenotype:  –
Genotype and Phenotype
Genotype:
– Particular set of genes in a genome
Phenotype:
– Physical characteristic of the genotype
(smart, beautiful, healthy, etc.)
Genotype and Phenotype
Genotype and Phenotype
GA Requirements A typical genetic algorithm requires two things to be defined:  a genetic representation
GA Requirements
A typical genetic algorithm requires two things to be defined:
a genetic representation of the solution domain, and
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, that facilitates simple crossover operation.
Variable length representations may also be used, but
crossover implementation is more complex in this case.
Tree-like representations are explored in Genetic
programming.
Representation Chromosomes could be: Bit strings (0101 1100)  Real numbers (43.2 -33.1  Permutations of
Representation
Chromosomes could be:
Bit strings
(0101
1100)
Real numbers
(43.2 -33.1
Permutations of element
Lists of rules
(E11 E3 E7
(R1 R2 R3
0.0 89.2)
E1 E15)
R22 R23)
Program elements
...
(genetic programming)
...
any data structure ...
GA Requirements  The fitness function is defined over the genetic representation and measures the quality
GA Requirements
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 we want to maximize
the total value of objects that we can 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.
A fitness function
A fitness function
Basics of GA The most common type of genetic algorithm works like this:   a
Basics of GA
The most common type of genetic algorithm works like this:
a population is created with a group of individuals created
randomly.
The individuals in the population are then evaluated.
The evaluation function is provided by the programmer and
gives the individuals a score based on how well they perform
at the given task.
Two individuals are then selected based on their fitness, the
higher the fitness, the higher the chance of being selected.
These individuals then "reproduce" to create one or more
offspring, after which the offspring are mutated randomly.
This continues until a suitable solution has been found or a
certain number of generations have passed, depending on the
needs of the programmer.
General Algorithm for GA Initialization   Initially many individual solutions are randomly generated to form
General Algorithm for GA
Initialization
Initially many individual solutions are 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,
covering 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.
General Algorithm for GA Selection   During each successive generation, a proportion of the existing
General Algorithm for GA
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 this process may be
very time-consuming.
Most functions are stochastic and designed so that a small
proportion of less fit solutions are selected. This helps keep the
diversity of the population large, preventing premature
convergence on poor solutions. Popular and well-studied
selection methods include roulette wheel selection and
tournament selection.
General Algorithm for GA  In roulette wheel selection, individuals are given a probability of being
General Algorithm for GA
In roulette wheel selection, individuals are
given a probability of being selected that is
directly proportionate to their fitness.
Two individuals are then chosen randomly
based on these probabilities and produce
offspring.
General Algorithm for GA Roulette Wheel’s Selection Pseudo Code: for all members of population sum +=
General Algorithm for GA
Roulette Wheel’s Selection Pseudo Code:
for all members of population
sum += fitness of this individual
end for
for all members of population
probability = sum of probabilities + (fitness / sum)
sum of probabilities += probability
end for
loop until new population is full
do this twice
number = Random between 0 and 1
for all members of population
if number > probability but less than next probability then
you have been selected
end for
end
create offspring
end loop
General Algorithm for GA Reproduction   The next step is to generate a second generation
General Algorithm for GA
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 and mutation, a new solution is created which
typically shares many of the characteristics of its "parents".
New parents are selected for each child, and the process
continues until a new population of solutions of appropriate
size is generated.
General Algorithm for GA  These processes ultimately result in the next generation population of chromosomes
General Algorithm for GA
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.
Crossover  the most common type is single point crossover. In single point crossover, you choose
Crossover
the most common type is single point crossover. In single
point crossover, you choose a locus at which you swap the
remaining alleles from on parent to the other. This is complex
and is best understood visually.
As you can see, the children take one section of the
chromosome from each parent.
The point at which the chromosome is broken depends on the
randomly selected crossover point.
This particular method is called single point crossover because
only one crossover point exists. Sometimes only child 1 or
child 2 is created, but oftentimes both offspring are created and
put into the new population.
Crossover does not always occur, however. Sometimes, based
on a set probability, no crossover occurs and the parents are
copied directly to the new population. The probability of
crossover occurring is usually 60% to 70%.
Crossover
Crossover
Mutation  After selection and crossover, you now have a new population full of individuals. 
Mutation
After selection and crossover, you now have a new population
full of individuals.
Some are directly copied, and others are produced by
crossover.
In order to ensure that the individuals are not all exactly the
same, you allow for a small chance of mutation.
You loop through all the alleles of all the individuals, and if
that allele is selected for mutation, you can either change it by
a small amount or replace it with a new value. The probability
of mutation is usually between 1 and 2 tenths of a percent.
Mutation is fairly simple. You just change the selected alleles
based on what you feel is necessary and move on. Mutation is,
however, vital to ensuring genetic diversity within the
population.
Mutation
Mutation
General Algorithm for GA Termination   This generational process is repeated until a termination condition
General Algorithm for GA
Termination
This generational process is repeated until a
termination condition has been reached.
Common terminating conditions are:
A solution is found that satisfies minimum criteria
Fixed number of generations reached
Allocated budget (computation time/money) reached
The highest ranking solution's fitness is reaching or has
reached a plateau such that successive iterations no longer
produce better results
Manual inspection
Any Combinations of the above
GA Pseudo-code Choose initial population Evaluate the fitness of each individual in the population Repeat Select
GA Pseudo-code
Choose initial population
Evaluate the fitness of each individual in the population
Repeat
Select best-ranking individuals to reproduce
Breed new generation through crossover and mutation (genetic
operations) and give birth to offspring
Evaluate the individual fitnesses of the offspring
Replace worst ranked part of population with offspring
Until <terminating condition>
Symbolic AI VS. Genetic Algorithms Most symbolic AI systems are very static.   Most of
Symbolic AI VS. Genetic
Algorithms
Most symbolic AI systems are very static.
Most of them can usually only solve one given
specific problem, since their architecture was
designed for whatever that specific problem was in
the first place.
Thus, if the given problem were somehow to be
changed, these systems could have a hard time
adapting to them, since the algorithm that would
originally arrive to the solution may be either
incorrect or less efficient.
Genetic algorithms (or GA) were created to combat
these problems; they are basically algorithms based
on natural biological evolution.
Symbolic AI VS. Genetic Algorithms  The architecture of systems that implement genetic algorithms (or GA)
Symbolic AI VS. Genetic
Algorithms
The architecture of systems that implement genetic algorithms
(or GA) are more able to adapt to a wide range of problems.
A GA functions by generating a large set of possible solutions
to a given problem.
It then evaluates each of those solutions, and decides on a
"fitness level" (you may recall the phrase: "survival of the
fittest") for each solution set.
These solutions then breed new solutions.
The parent solutions that were more "fit" are more likely to
reproduce, while those that were less "fit" are more unlikely to
do so.
In essence, solutions are evolved over time. This way you
evolve your search space scope to a point where you can find
the solution.
Genetic algorithms can be incredibly efficient if programmed
correctly.
Genetic Programming  In programming languages such as LISP, the mathematical notation is not written in
Genetic Programming
In programming languages such as LISP, the mathematical
notation is not written in standard notation, but in prefix
notation. Some examples of this:
+ 2 1
:
2 + 1
* + 2 1 2
:
2 * (2+1)
* + - 2 1 4 9
:
9 * ((2 - 1) + 4)
Notice the difference between the left-hand side to the right?
Apart from the order being different, no parenthesis! The
prefix method makes it a lot easier for programmers and
compilers alike, because order precedence is not an issue.
You can build expression trees out of these strings that then
can be easily evaluated, for example, here are the trees for the
above three expressions.
Genetic Programming
Genetic Programming
Genetic Programming  You can see how expression evaluation is thus a lot easier.  What
Genetic Programming
You can see how expression evaluation is thus a lot
easier.
What this have to do with GAs? If for example you
have numerical data and 'answers', but no expression
to conjoin the data with the answers.
A genetic algorithm can be used to 'evolve' an
expression tree to create a very close fit to the data.
By 'splicing' and 'grafting' the trees and evaluating
the resulting expression with the data and testing it to
the answers, the fitness function can return how close
the expression is.
Genetic Programming  The limitations of genetic programming lie in the huge search space the GAs
Genetic Programming
The limitations of genetic programming lie in
the huge search space the GAs have to search
for - an infinite number of equations.
Therefore, normally before running a GA to
search for an equation, the user tells the
program which operators and numerical ranges
to search under.
Uses of genetic programming can lie in stock
market prediction, advanced mathematics and
military applications .
Evolving Neural Networks  Evolving the architecture of neural network is slightly more complicated, and there
Evolving Neural Networks
Evolving the architecture of neural network is
slightly more complicated, and there have been
several ways of doing it. For small nets, a
simple matrix represents which neuron
connects which, and then this matrix is, in
turn, converted into the necessary 'genes', and
various combinations of these are evolved.
Evolving Neural Networks  Many would think that a learning function could be evolved via genetic
Evolving Neural Networks
Many would think that a learning function could be
evolved via genetic programming. Unfortunately,
genetic programming combined with neural networks
could be incredibly slow, thus impractical.
As with many problems, you have to constrain what
you are attempting to create.
For example, in 1990, David Chalmers attempted to
evolve a function as good as the delta rule.
He did this by creating a general equation based upon
the delta rule with 8 unknowns, which the genetic
algorithm then evolved.
Other Areas  Genetic Algorithms can be applied to virtually any problem that has a large
Other Areas
Genetic Algorithms can be applied to virtually any problem
that has a large search space.
Al Biles uses genetic algorithms to filter out 'good' and 'bad'
riffs for jazz improvisation.
The military uses GAs to evolve equations to differentiate
between different radar returns.
Stock companies use GA-powered programs to predict the
stock market.
Checkboard example  We are given an n by n checkboard in which every field can
Checkboard example
We are given an n by n checkboard in which every field
can have a different colour from a set of four colors.
Goal is to achieve a checkboard in a way that there are no
neighbours with the same color (not diagonal)
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
1
2
3
4
5
6
7
8
9
10
1
2
3
4
5
6
7
8
9
10
Checkboard example Cont’d Chromosomes represent the way the checkboard is colored.  Chromosomes are not represented
Checkboard example Cont’d
Chromosomes represent the way the checkboard is colored.
Chromosomes are not represented by bitstrings but by
bitmatrices
The bits in the bitmatrix can have one of the four values 0,
1, 2 or 3, depending on the color.
Crossing-over involves matrix manipulation instead of
point wise operating.
Crossing-over can be combining the parential matrices in a
horizontal, vertical, triangular or square way.
Mutation remains bitwise changing bits in either one of the
other numbers.
Checkboard example Cont’d • This problem can be seen as a graph with n nodes and
Checkboard example Cont’d
• This problem can be seen as a graph with n nodes
and (n-1) edges, so the fitness f(x) is defined as:
f(x) = 2 · (n-1) ·n
Example f(x) = {MAX(x 2 ): 0 <= x <= 32 }  Encode Solution: Just
Example
f(x) = {MAX(x 2 ): 0 <= x <= 32 }
Encode Solution: Just use 5 bits (1 or 0).
Generate initial population.
A
0
1
1
0
1
B
1
1
0
0
0
C
0
1
0
0
0
D
1
0
0
1
1
Evaluate each solution against objective.
Sol.
String
Fitness
% of Total
A
01101
169
14.4
B
11000
576
49.2
C
01000
64
5.5
D
10011
361
30.9
Example Cont’d Create next generation of solutions  Probability of “being a parent” depends on the
Example Cont’d
Create next generation of solutions
Probability of “being a parent” depends on the fitness.
Ways for parents to create next generation
Reproduction
Use a string again unmodified.
Crossover
Cut and paste portions of one string to another.
Mutation
Randomly flip a bit.
COMBINATION of all of the above.
Checkboard example  We are given an n by n checkboard in which every field can
Checkboard example
We are given an n by n checkboard in which every field
can have a different colour from a set of four colors.
Goal is to achieve a checkboard in a way that there are no
neighbours with the same color (not diagonal)
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
1
2
3
4
5
6
7
8
9
10
1
2
3
4
5
6
7
8
9
10
Checkboard example Cont’d Chromosomes represent the way the checkboard is colored.  Chromosomes are not represented
Checkboard example Cont’d
Chromosomes represent the way the checkboard is colored.
Chromosomes are not represented by bitstrings but by
bitmatrices
The bits in the bitmatrix can have one of the four values 0,
1, 2 or 3, depending on the color.
Crossing-over involves matrix manipulation instead of
point wise operating.
Crossing-over can be combining the parential matrices in a
horizontal, vertical, triangular or square way.
Mutation remains bitwise changing bits in either one of the
other numbers.
Checkboard example Cont’d • This problem can be seen as a graph with n nodes and
Checkboard example Cont’d
• This problem can be seen as a graph with n nodes
and (n-1) edges, so the fitness f(x) is defined as:
f(x) = 2 · (n-1) ·n
Checkboard example Cont’d • Fitnesscurves for different cross-over rules: Lower-Triangular Crossing Over Square Crossing Over 180
Checkboard example Cont’d
• Fitnesscurves for different cross-over rules:
Lower-Triangular Crossing Over
Square Crossing Over
180
180
170
170
160
160
150
150
140
140
130
130
0
100
200
300
400
500
0
200
400
600
800
Horizontal Cutting Crossing Over
Verical Cutting Crossing Over
180
180
170
170
160
160
150
150
140
140
130
130
0
200
400
600
800
0
500
1000
1500
Generations
Generations
Fitness
Fitness
Fuzzy Logic WHERE DID FUZZY LOGIC COME FROM? The concept of Fuzzy Logic (FL) was conceived
Fuzzy Logic
WHERE DID FUZZY LOGIC COME FROM?
The concept of Fuzzy Logic (FL) was conceived by Lotfi Zadeh, a
professor at the University of California at Berkley, and presented not
as a control methodology, but as a way of processing data by allowing
partial set membership rather than crisp set membership or non-
membership. This approach to set theory was not applied to control
systems until the 70's due to insufficient small-computer capability
prior to that time. Professor Zadeh reasoned that people do not require
precise, numerical information input, and yet they are capable of
highly adaptive control. If feedback controllers could be programmed
to accept noisy, imprecise input, they would be much more effective
and perhaps easier to implement. Unfortunately, U.S. manufacturers
have not been so quick to embrace this technology while the
Europeans and Japanese have been aggressively building real
products around it.
Fuzzy Logic WHAT IS FUZZY LOGIC? In this context, FL is a problem-solving control system methodology
Fuzzy Logic
WHAT IS FUZZY LOGIC?
In this context, FL is a problem-solving control system methodology
that lends itself to implementation in systems ranging from simple,
small, embedded micro-controllers to large, networked, multi-channel
PC or workstation-based data acquisition and control systems. It can
be implemented in hardware, software, or a combination of both. FL
provides a simple way to arrive at a definite conclusion based upon
vague, ambiguous, imprecise, noisy, or missing input information.
FL's approach to control problems mimics how a person would make
decisions, only much faster.
.
HOW IS FL DIFFERENT FROM CONVENTIONAL CONTROL METHODS? FL incorporates a simple, rule-based IF X AND
HOW IS FL DIFFERENT FROM CONVENTIONAL
CONTROL METHODS?
FL incorporates a simple, rule-based IF X AND Y THEN Z approach
to a solving control problem rather than attempting to model a system
mathematically. The FL model is empirically-based, relying on an
operator's experience rather than their technical understanding of the
system. For example, rather than dealing with temperature control in
terms such as "SP =500F", "T <1000F", or "210C <TEMP <220C",
terms like "IF (process is too cool) AND (process is getting colder)
THEN (add heat to the process)" or "IF (process is too hot) AND
(process is heating rapidly) THEN (cool the process quickly)" are
used. These terms are imprecise and yet very descriptive of what must
actually happen. Consider what you do in the shower if the
temperature is too cold: you will make the water comfortable very
quickly with little trouble. FL is capable of mimicking this type of
behavior but at very high rate.
HOW DOES FL WORK? FL requires some numerical parameters in order to operate such as what
HOW DOES FL WORK?
FL requires some numerical parameters in order to operate such as
what is considered significant error and significant rate-of-change-of-
error, but exact values of these numbers are usually not critical unless
very responsive performance is required in which case empirical
tuning would determine them. For example, a simple temperature
control system could use a single temperature feedback sensor whose
data is subtracted from the command signal to compute "error" and
then time-differentiated to yield the error slope or rate-of-change-of-
error, hereafter called "error-dot". Error might have units of degs F
and a small error considered to be 2F while a large error is 5F. The
"error-dot" might then have units of degs/min with a small error-dot
being 5F/min and a large one being 15 F/min. These values don't have
to be symmetrical and can be "tweaked" once the system is operating
in order to optimize performance. Generally, FL is so forgiving that
the system will probably work the first time without any tweaking.
Fuzzy Logic FL was conceived as a better method for sorting and handling data but has
Fuzzy Logic
FL was conceived as a better method for sorting and handling data but
has proven to be a excellent choice for many control system
applications since it mimics human control logic. It can be built into
anything from small, hand-held products to large computerized
process control systems. It uses an imprecise but very descriptive
language to deal with input data more like a human operator. It is very
robust and forgiving of operator and data input and often works when
first implemented with little or no tuning.
WHY USE FL? FL offers several unique features that make it a particularly good choice for
WHY USE FL?
FL offers several unique features that make it a particularly good
choice for many control problems.
1) It is inherently robust since it does not require precise, noise-free
inputs and can be programmed to fail safely if a feedback sensor quits
or is destroyed. The output control is a smooth control function
despite a wide range of input variations.
2) Since the FL controller processes user-defined rules governing the
target control system, it can be modified and tweaked easily to
improve or drastically alter system performance. New sensors can
easily be incorporated into the system simply by generating
appropriate governing rules.
3) FL is not limited to a few feedback inputs and one or two control
outputs, nor is it necessary to measure or compute rate-of-change
parameters in order for it to be implemented. Any sensor data that
provides some indication of a system's actions and reactions is
sufficient. This allows the sensors to be inexpensive and imprecise
thus keeping the overall system cost and complexity low.
WHY USE FL? FL offers several unique features that make it a particularly good choice for
WHY USE FL?
FL offers several unique features that make it a particularly good
choice for many control problems.
4) Because of the rule-based operation, any reasonable number of
inputs can be processed (1-8 or more) and numerous outputs (1-4 or
more) generated, although defining the rulebase quickly becomes
complex if too many inputs and outputs are chosen for a single
implementation since rules defining their interrelations must also be
defined. It would be better to break the control system into smaller
chunks and use several smaller FL controllers distributed on the
system, each with more limited responsibilities.
5) FL can control nonlinear systems that would be difficult or
impossible to model mathematically. This opens doors for control
systems that would normally be deemed unfeasible for automation.
HOW IS FL USED? 1) Define the control objectives and criteria: What am I trying to
HOW IS FL USED?
1) Define the control objectives and criteria: What am I trying to
control? What do I have to do to control the system? What kind of
response do I need? What are the possible (probable) system failure
modes?
2) Determine the input and output relationships and choose a
minimum number of variables for input to the FL engine (typically
error and rate-of-change-of-error).
3) Using the rule-based structure of FL, break the control problem
down into a series of IF X AND Y THEN Z rules that define the
desired system output response for given system input conditions. The
number and complexity of rules depends on the number of input
parameters that are to be processed and the number fuzzy variables
associated with each parameter. If possible, use at least one variable
and its time derivative. Although it is possible to use a single,
instantaneous error parameter without knowing its rate of change, this
cripples the system's ability to minimize overshoot for a step inputs.
HOW IS FL USED? 4) Create FL membership functions that define the meaning (values) of Input/Output
HOW IS FL USED?
4) Create FL membership functions that define the meaning (values)
of Input/Output terms used in the rules.
5) Create the necessary pre- and post-processing FL routines if
implementing in S/W, otherwise program the rules into the FL H/W
engine.
6) Test the system, evaluate the results, tune the rules and membership
functions, and retest until satisfactory results are obtained.
Fuzzy Logic LINGUISTIC VARIABLES In 1973, Professor Lotfi Zadeh proposed the concept of linguistic or "fuzzy"
Fuzzy Logic
LINGUISTIC VARIABLES
In 1973, Professor Lotfi Zadeh proposed the concept of linguistic or
"fuzzy" variables. Think of them as linguistic objects or words, rather
than numbers. The sensor input is a noun, e.g. "temperature",
"displacement", "velocity", "flow", "pressure", etc. Since error is just
the difference, it can be thought of the same way. The fuzzy variables
themselves are adjectives that modify the variable (e.g. "large
positive" error, "small positive" error ,"zero" error, "small negative"
error, and "large negative" error). As a minimum, one could simply
have "positive", "zero", and "negative" variables for each of the
parameters. Additional ranges such as "very large" and "very small"
could also be added to extend the responsiveness to exceptional or
very nonlinear conditions, but aren't necessary in a basic system.
Fuzzy Logic THE RULE MATRIX In the last article the concept of linguistic variables was presented.
Fuzzy Logic
THE RULE MATRIX
In the last article the concept of linguistic variables was presented.
The fuzzy parameters of error (command-feedback) and error-dot
(rate-of-change-of-error) were modified by the adjectives "negative",
"zero", and "positive". To picture this, imagine the simplest practical
implementation, a 3-by-3 matrix. The columns represent "negative
error", "zero error", and "positive error" inputs from left to right. The
rows represent "negative", "zero", and "positive" "error-dot" input
from top to bottom. This planar construct is called a rule matrix. It has
two input conditions, "error" and "error-dot", and one output response
conclusion (at the intersection of each row and column). In this case
there are nine possible logical product (AND) output response
conclusions.
Fuzzy Logic THE RULE MATRIX Although not absolutely necessary, rule matrices usually have an odd number
Fuzzy Logic
THE RULE MATRIX
Although not absolutely necessary, rule matrices usually have an odd
number of rows and columns to accommodate a "zero" center row and
column region. This may not be needed as long as the functions on
either side of the center overlap somewhat and continuous dithering
of the output is acceptable since the "zero" regions correspond to "no
change" output responses the lack of this region will cause the system
to continually hunt for "zero". It is also possible to have a different
number of rows than columns. This occurs when numerous degrees of
inputs are needed. The maximum number of possible rules is simply
the product of the number of rows and columns, but definition of all
of these rules may not be necessary since some input conditions may
never occur in practical operation. The primary objective of this
construct is to map out the universe of possible inputs while keeping
the system sufficiently under control.
Fuzzy Logic The first step in implementing FL is to decide exactly what is to be
Fuzzy Logic
The first step in implementing FL is to decide exactly what is to be
controlled and how. For example, suppose we want to design a simple
proportional temperature controller with an electric heating element
and a variable-speed cooling fan. A positive signal output calls for 0-
100 percent heat while a negative signal output calls for 0-100 percent
cooling. Control is achieved through proper balance and control of
these two active devices.
Fuzzy Logic . .
Fuzzy Logic
.
.
Fuzzy Logic Figure 1 - A simple block diagram of the control system.It is necessary to
Fuzzy Logic
Figure 1 - A simple block diagram of the control system.It is
necessary to establish a meaningful system for representing the
linguistic variables in the matrix.
"N" = "negative" error or error-dot input level
"Z" = "zero" error or error-dot input level
"P" = "positive" error or error-dot input level
"H" = "Heat" output response
"-" = "No Change" to current output
"C" = "Cool" output response
Define the minimum number of possible input product combinations
and corresponding output response conclusions using these terms.
For a three-by-three matrix with heating and cooling output
responses, all nine rules will need to be defined. The conclusions to
the rules with the linguistic variables associated with the output
response for each rule are transferred to the matrix.
Fuzzy Logic . .
Fuzzy Logic
.
.
Fuzzy Logic Figure 2 - Typical control system response Figure 2 shows what command and error
Fuzzy Logic
Figure 2 - Typical control system response Figure 2 shows what
command and error look like in a typical control system relative to the
command setpoint as the system hunts for stability. Definitions are
also shown for this example.
DEFINITIONS:
INPUT#1: ("Error", positive (P), zero (Z), negative (N))
INPUT#2: ("Error-dot", positive (P), zero (Z), negative (N))
CONCLUSION: ("Output", Heat (H), No Change (-), Cool (C))
INPUT#1 System Status
Error = Command-Feedback
P=Too cold, Z=Just right, N=Too hot
INPUT#2 System Status
Error-dot = d(Error)/dt
P=Getting hotter Z=Not changing N=Getting colder
OUTPUT Conclusion & System Response
Output H = Call for heating - = Don't change anything C = Call for cooling
Fuzzy Logic SYSTEM OPERATING RULES Linguistic rules describing the control system consist of two parts; an
Fuzzy Logic
SYSTEM OPERATING RULES
Linguistic rules describing the control system consist of two parts;
an antecedent block (between the IF and THEN) and a consequent
block (following THEN). Depending on the system, it may not be
necessary to evaluate every possible input combination (for 5-by-5
& up matrices) since some may rarely or never occur. By making
this type of evaluation, usually done by an experienced operator,
fewer rules can be evaluated, thus simplifying the processing logic
and perhaps even improving the FL system performance.
. .
.
.
Fuzzy Logic Figures 3 & 4 - The rule structure. After transferring the conclusions from the
Fuzzy Logic
Figures 3 & 4 - The rule structure.
After transferring the conclusions from the nine rules to the
matrix there is a noticeable symmetry to the matrix. This suggests
(but doesn't guarantee) a reasonably well-behaved (linear)
system. This implementation may prove to be too simplistic for
some control problems, however it does illustrate the process.
Additional degrees of error and error-dot may be included if the
desired system response calls for this. This will increase the
rulebase size and complexity but may also increase the quality of
the control. Figure 4 shows the rule matrix derived from the
previous rules.
Fuzzy Logic SUMMARY Linguistic variables are used to represent an FL system's operating parameters. The rule
Fuzzy Logic
SUMMARY
Linguistic variables are used to represent an FL system's
operating parameters. The rule matrix is a simple graphical
tool for mapping the FL control system rules. It accommodates
two input variables and expresses their logical product (AND)
as one output response variable. To use, define the system
using plain-English rules based upon the inputs, decide
appropriate output response conclusions, and load these into
the rule matrix.
THANK YOU
THANK YOU