Topic 3 Notes - Fuzzy Logic & Artificial Neural Networks
Topic 3 Notes - Fuzzy Logic & Artificial Neural Networks
Page | 1
FUZZY LOGIC & ARTIFICIAL NEURAL NETWORKS
FLC BLOCK DIAGRAM
➢ The setpoint is added to the sensor feedback.
The Error is negative, Knowledge Database is from the human; Knowledge Database is the user telling
the fuzzy the linguistic terms.
The Fuzzified Linguistic Variables are taken to the Rule Base where the “If-then” sits; For Example, if the
temperature of the process is very low, the valve must open fully (100%), if the fuzzy controller only has
this rule then the temperature of “very cold” is between 0 ℃ and 10 ℃ , the valve will open 100% and
stick to that; when it is above 10 ℃ it would close. It behaves like ON/OFF controller and prevent that
more rules have to be added.
Once the rules trigger the output Defuzzification is added, because the valve cannot handle fuzzified
values; so, they are converted to numerical values or range.
The valve can be closed, medium open, but if the temperature is low, the valve is opened.
The open membership function is triggered, sending the correct value to the valve.
Page | 2
FUZZY LOGIC & ARTIFICIAL NEURAL NETWORKS
STEPS IN DESIGNING FLC
1. Identification of variables − Here, the input, output and state variables of the plant which is under
consideration must be identified.
2. Fuzzy subset configuration − The universe of information is divided into number of fuzzy subsets and
each subset is assigned a linguistic label.
3. Obtaining membership function − Now obtain the membership function for each fuzzy subset that we
get in the above step.
4. Fuzzy rule base configuration − Now formulate the fuzzy rule base by assigning relationship between
fuzzy input and output.
5. Fuzzification − The fuzzification process is initiated in this step.
6. Combining fuzzy outputs − By applying fuzzy approximate reasoning, locate the fuzzy output and merge
them.
7. Defuzzification − Finally, initiate defuzzification process to form a crisp output.
Steam
Heat Exchanger
Set Point
❖ The temperature Transmitter (TT) is the sensor, Heat Exchanger and the valve is the plant.
❖ The output comes from the controller (TC), input to the controller is the sensor (TT) which is negative
feedback.
❖ The set point is also the input to the fuzzy controller which is (TC).
❖ TC gives an output to the valve
❖ In fuzzy logic controller signals are numbers; the input error goes to the fuzzification table.
Page | 3
FUZZY LOGIC & ARTIFICIAL NEURAL NETWORKS
Fuzzy Input Membership Functions
▪ Membership functions are the fuzzified membership function represented by the dotted line.
▪ Crisp variable is the straight vertical line
▪ In fuzzy logic values ranging from 0 and 1 are considered.
For Example: if the temperature ranges from 10 ℃ to 30℃; the temperature reading is taken and converted
to linguistic terms because fuzzy controller does not work with numbers.
From 10℃ to 15 ℃ it is “Very Cold” which is a linguistic term.
From 15℃ to 20℃ it is “Warm”; from 20℃ to 30℃ it is “Very Hot”
Fuzzification is taking a range of temperatures and change them to linguistic terms.
A numerical value of a variable is turned into a fuzzy variable; it is neither 0 nor 1, it is a number in
between.
The crisp variable is 0 and increases to 1, anything below 21℃ is Very Cold and anything above 21 ℃ is
Very Hot.
Page | 4
FUZZY LOGIC & ARTIFICIAL NEURAL NETWORKS
On the example Very Cold lies between 0 and 10, it is subjective.
If the temperature is measured at 3 ℃ since VC and C are overlapping, 3 ℃ can be shown as intersecting
VC at 1 and intersect C at 0.4 a set can be created 3 ℃ [1; 0.4; 0; 0; 0] where 1 is VC, 0.4 is C, 0 is W, 0 is
H, and 0 is VH.
This set of numbers is applied to a set of rules then the outputs are fired then defuzzied to crisp variables.
Fuzzified variables are used to work out at which point these membership functions of the fuzzified
variables are fired or triggered.
Then the set is used in a Rule Base to give an output.
if the set point is 50% the error will go from Negative to Positive; if the setpoint is 50% the error is -50;
if the level is at 100% the error will be +50.
Error is Negative between -100 to 0; it is Zero between -50 and +50; it is Positive between 0 and +100.
The error has a range of 0 and 1.
For Delta E
Delta E is fuzzified between 0 and 1; Delta E is Negative between -100 and 0; -50 to +50 it is Zero;
between 0 to 100 it is Positive.
The rate of change is Negative, then goes to Zero (no change occurred); then it goes to Positive.
2. De-fuzzification
For the Control Valve (U)
Page | 6
FUZZY LOGIC & ARTIFICIAL NEURAL NETWORKS
The fuzzified valve is converted to crisp value.
Between 0 and 50, valve is fully Closed; between 25% and 75% the valve is at Medium; between 50%
and 100% the valve is Open.
3. Rule Base
➢ This is second order response there is no deadtime.
➢ The rules can be extracted from this response.
When the Error is Positive, Delta E is Zero, Output to the valve must fully Open; if the level is below the
setpoint the valve must Open shown by Rule 1.
Rule 2, Error is Zero, Delta E is Negative, this crosses the setpoint (b,f,j) the valve must start Closing.
Rule 3 Error is Negative, Delta E is Zero; the level is above the setpoint, the valve must Close fully.
Rule 4 Error is Zero, Delta E is Positive (d,h,l) valve must fully Open.
Rule 5 Error is Zero, Delta E is Zero, the level is Constant, or the process is at the setpoint; the valve must
at Medium.
40%
U = 85% and the center of gravity of the
shaded shape is given by:
0.375 (𝒂+𝒃𝟐) × 𝒉 (𝟓𝟎+𝟐(𝟒𝟎))×𝟎.𝟕𝟓
𝒙= = =
𝟑(𝒂+𝒃) 𝟑(𝟓𝟎+𝟒𝟎)
𝟎. 𝟑𝟔 × 𝟏𝟎𝟎 = 𝟑𝟔%
50% 36% 𝒉 𝟎.𝟕𝟓
𝒚= = = 𝟎. 𝟑𝟕𝟓
𝟐 𝟐
Page | 8
FUZZY LOGIC & ARTIFICIAL NEURAL NETWORKS
FUZZY LOGIC FOR FUNCTION APPROXIMATION (MODELLING)
Relationship Between Input (X) And Output (Y)
➢ Any system can be approximated by looking at the inputs and outputs.
➢ For Example:
Y = mx + c
The line y does not give accurate approximation; Fuzzy logic is then used; inputs are broken up into
memberships.
A set of rules is developed, its input is at x1; at x1 the output is y2.
If the input is at x2, the output is y1.
Fuzzy logic can be used to find key relationship between inputs (x) and outputs (y) by using linguistic
terms.
Crisp values are fuzzified between 0 and 1 then that is applied to a rule base.
The fuzzified values are turned into crisp values.
Page | 9
FUZZY LOGIC & ARTIFICIAL NEURAL NETWORKS
ALTERNATE CONTROL SCHEMES USING A FUZZY LOGIC
Scheme A: Fuzzy Replaces PID
In this configuration, it is up to the operator to control
the process in the existing (conventional) mode or to
switch the controls over to a fuzzy control strategy.
Often, the conventional loops represent an existing
control scheme that has been controlling installing of
a high-level strategy. The operator must decide which
of the two alternatives is the most likely to produce
the best control performance.
In this configuration, the high-level strategy is used to adjust the tuning parameters of the conventional
control loops. A common problem with linear PID controllers used for control of highly non-linear processes
is that the set of controller parameters produces satisfactory performance only when the process is within
a small operational region. Outside this region, other controller settings are necessary, and these
adjustments may be made automatically by a high-level strategy. This is called Gain Scheduling since such
algorithms were originally used to change controller gains. A gain scheduling controller contains a linear
controller whose parameters are changed as a function of the operating point in a preprogrammed way. It
requires a thorough knowledge of the plant, but it is often a good way to compensate for nonlinearities and
parameter variations. Additional sensor measurements can be used as scheduling variables that govern the
change of the controller parameters often by means of look-up table.
The fuzzy logic controller controls the gains of the PID ( 𝑲𝒄 , 𝑻𝒊 , & 𝑻𝒅 ), the dynamics at these gains are
changes based on the error.
For Example, the tank level would be a set point of gain in certain regions.
The PID controller can be made to operate in a non-linear fashion by altering the gains using fuzzy logic
scheme.
Fuzzy logic is not the controller on this scheme, but PID is the controller, the Fuzzy logic adjusts the
parameters of PID.
The input to the fuzzy logic is Delta E and the output will be 3 outputs which is the adjusting values of
𝑲𝒄 , 𝑻𝒊 , & 𝑻𝒅 .
Page | 10
FUZZY LOGIC & ARTIFICIAL NEURAL NETWORKS
Scheme B: Fuzzy Adds to PID Output.
This scheme can be viewed as a collaboration of linear and nonlinear control actions; the controller may be
a linear PID controller, while the fuzzy controller is a supplementary nonlinear controller. Normally,
conventional control systems using PID controllers can control the process when the operation is steady and
close to normal conditions. However, if sudden changes occur or if the process enters abnormal situations,
then this configuration may be useful to bring the process back to normal operation as fast as possible. This
scheme can also be interpreted as feedforward–feedback control, where a measurable disturbance is
compensated. Generally, this solution requires a good model, but if a mathematical model is difficult or
expensive to obtain, a fuzzy model may be useful.
The output PID controller and fuzzy logic controller are added.
When the PID controller is not operated, it is compensated by the fuzzy logic controller taking over.
Page | 11
FUZZY LOGIC & ARTIFICIAL NEURAL NETWORKS
PART 2 - ARTIFICIAL NEURAL NETWORKS (ANN’s)
➢ Used to identify and/or control non-linear time varying systems.
➢ Applications: Modelling, Prediction, Classification, Decision Making, Anomaly Detection & Control.
Page | 12
FUZZY LOGIC & ARTIFICIAL NEURAL NETWORKS
Black Box/ Empirical
➢ This technique lies upon giving a process input and outputs on the model.
CHARACTERISTICS OF ANN’S
1. Exhibit mapping patterns, i.e. input patterns to associated output patterns
Input Output
➢ When the inputs and outputs are applied to the neural network, the ANN will map out of the patterns of
the system.
2. Learn by example
3. Predict new outcomes from past trends.
4. Robust and fault tolerant
5. Process information in a parallel manner.
6. Ability to generalize
Page | 13
FUZZY LOGIC & ARTIFICIAL NEURAL NETWORKS
Structure of Neural Networks
➢ The McCulloch-Pitts neuron has multiple inputs and a single output. Each of the inputs has an associated
weight. The weight sum of the inputs is passed through a nonlinearity of the output of the neuron as
seen in the previous diagram.
• 𝑿𝒊 are the inputs
• Y is the output of the neurons
• F(z) is the nonlinear activation function in the form of the step function
• 𝑾𝒊 are the strength of the connections.
➢ The inputs are connected to the Perceptron the outputs then go out.
➢ There are 3 layers Input, Hidden Layer and Output Layers.
➢ This is used to model the system in most process applications.
➢ The perceptron is a McCulloch-Pitts neuron model, with Activation Function, Summer; The Output is
weighted then goes to the next layer.
Page | 14
FUZZY LOGIC & ARTIFICIAL NEURAL NETWORKS
Perceptron View
Page | 15
FUZZY LOGIC & ARTIFICIAL NEURAL NETWORKS
DEVELOPING AND BUILDING NEURAL NETWORK
The phases of a neural network life cycle are concept, design, implementation, and maintenance:
• Concept: The first step in implementation of a neural network is to select a neural paradigm. Selection is
based upon the traits of the problem, size of the problem, method of training, and time constraints.
• Design: Specifies initial parameters and conditions for selected neural paradigm. The type and number
of processing elements (neurons), the number of layers, the connectivity of the layers, the transfer
function, and the learning algorithm are design decisions that must be made.
• Implementation: This involves applying the design criteria using customized environment.
• Maintenance: Involves modifying the deployed neural network application because of decreasing
accuracy due to conditions encountered for which the network was not trained.
TRAINING OF ANN’s
Supervised:
➢ Neurons are interconnected together; in supervised scheme the neural network is fed a set of patterns,
and they are compared to what the output needs to be.
Page | 16
FUZZY LOGIC & ARTIFICIAL NEURAL NETWORKS
The Desired Output (D) comes from the process; it is the actual pattern given to the Neural Network.
After feeding the Neural Network the first set of Inputs (X) and the Desired Output/patterns (D).
If it does not give the adequate pattern or the correct signal there will be a large Error generated.
The Error Signal is fed back to the Neural Network; overtime the Weights, Biases of each neuron are
increased such that the Error is reduced and such that the output of the Neural Network (Y) is similar to
the Desired Output (D).
After that the Neural Network has learned or has been successfully trained.
Un-Supervised:
In Unsupervised there is no desired output shown to the Neural Network; the Neural Network learns on
its own.
Input pattern comes in, there is an Output(Y); this is used for classification or pattern recognition.
If a pattern of numbers belonging to one group are fed to the Neural Network, the network will be able
to classify or recognize that.
In Stochastic method, the values of the weights and the biases are altered randomly.
The optimization reduces the error based on the backpropagation or least mean square.
Backpropagation is where in the first iteration there are initial values set up for weights and biases; the
first pass is done then detect the error then the values of the weights and biases are changed.
On the next iteration, weights and biases will converge into a suitable output solution.
Least Mean squares converge is reached over a period of time based on the steepest gradient descent
method, which use the derivative of the error and reduce it.
Page | 17
FUZZY LOGIC & ARTIFICIAL NEURAL NETWORKS
The ANN Training Procedure:
1. Collect suitable number of input and output data - ANN has to be given suitable input/information from
the past.
2. Apply principal component analysis (PCA) – Remove outliers from the collected data.
3. Normalize the data set – Data must fit either between 0 and 1 or -1 and +1.
4. Separate data into “training” and “validation” data sets – There must be a data set for training and data
set for validation if used for process identification.
5. Select ANN architecture and train. Increase or “Prune” network and re-train if unsuccessful
6. Test ANN using validation data set.
Page | 18
FUZZY LOGIC & ARTIFICIAL NEURAL NETWORKS
MODELLING APPLICATION OF A DISTILLATION PROCESS USING ANN’S
Inputs (Feed flowrate, Distillate flowrate, bottoms flowrate, steam flowrate, feed temperature etc.)
these are all fed to neurons of a, there are 4 Hidden Layers.
Output Layer gives off indication of the concentration of bottom product and the top distillate product
concentration.
The Inputs are inferred in order to workout RVP in Bottom and Distillate 95% BP.
The Inferential sensors outputs are compared to the Neural Network outputs.
Results are validated and the sensor is removed since the Neural Network is trained it can estimate the
concentrations.
PLANT IDENTIFICATION
A signal is sent to the Plant, then the signal is added up (if the Plant and System Deadtime is adequately
determined by the Neural Network, the Output (𝒆𝒑 ) will be zero because if the Process Model and the
Plant are the same, the output should be zero.)
If disturbance signal is added to the Output (y), 𝒆𝒑 will not be zero anymore, 𝒆𝒑 will be equal to the
disturbance then it will be added to the Output of the Process Model without the deadtime (𝒚𝒑 ).
Then the PID Controller will use the disturbance to bring the Plant back to the setpoint.
NN Controller reduces error signal from the Robustness Filter which is a normal first order filter.
Robustness Filter makes the system robust and prevents the system from giving too large or too low
values.
NN Controller looks at the error and gives suitable Control Output to the Plant which has non-linear
dynamics.
Non-linear dynamics of the plant can be modelled using NN Plant Model.
Predictive control applied when output goes to the Plant, the NN Plant gives out the Predicted
Output.
Difference between Plant Output and Predicted Output are sent back to the error, then the error is
reduced by the Filter; Error is reduced based on the Predicted Output.
Page | 20
FUZZY LOGIC & ARTIFICIAL NEURAL NETWORKS