Anda di halaman 1dari 53

NEURO-FUZZY

CONTROL

J. Lilja Plsdttir
Poul Kristian Mhl
Alfonso Martnez del Hoyo Canterla
Soft Computing, 2005
University of Iceland

Table of contents
1. Introduction..................................................................................................... 4
2. Fuzzy logic controller...................................................................................... 4
2.1 PID controller ............................................................................................ 9
2.2 Fuzzy Logic Controller ............................................................................ 11
3. Controlling the Water-tank system using ANFIS .......................................... 22
3.1 Inverse control in water tank system....................................................... 23
3.2 Specialized learning................................................................................ 30
4. Inverse Learning........................................................................................... 35
4.1 Example.................................................................................................. 37
4.2 Multivalued Inverse ................................................................................. 45
4.3 Specialized Learning............................................................................... 46
4.4 Conclusions ............................................................................................ 46
5. ANFIS application - Equalizer....................................................................... 47
6. References ................................................................................................... 53

1. Introduction
Fuzzy control provides a formal methodology for representing, manipulating,
and implementing a humans heuristic knowledge about how to control a
system. Fuzzy control design methodology can be used to construct fuzzy
controllers for challenging real-world applications. In fuzzy control the focus is
on gaining an understanding of how to best control the process, then we load
this information directly into the fuzzy controller.
When we are going to design a fuzzy logic controller we should first understand
the behavior of the plant. For example how it reacts to inputs, what effects does
disturbances have, and what fundamental limitations are present (non-minimum
phase or unstable behaviour). Also we should take into account the
specifications in closed loop. Next an initial control design is performed, for
example with a PID or some other simple controller. If the simple controller
works there is no reason to implement something more complex; a fuzzy
controller will always be computationally more expensive and also it is more
difficult to develop.
Once a fuzzy controller is transformed into an adaptive network, the resulting
ANFIS can take advantage of all the neural network controller design
techniques proposed in the literature.
There are a number of control applications in which fuzzy logic can be useful.
For example we could mimick another working controller: fuzzy control makes
possible to use the heuristic knowledge from a human expert about how to
control a system. An experienced operator can summarize his control as a set
of rules with roughly correct membership functions. Later we could refine this
functions with a trial and error process or with learning algorithms. That will be
the first part of this project; we will be developing fuzzy controllers for a water
tank system.
Also we could apply fuzzy methods to inverse control, for example we could
train ANFIS to invert a plant; also ANFIS can be used for adaptive inverse
control. Finally, other fields of application in control would be specialized
learning, gain scheduling and others.

2. Fuzzy logic controller


The system that we are going to work with is a water tank with height 2 meters,
cross-sectional area A equal to 1m2, out pipe cross-section area of 0.05 m2,
inflow X(t) (maximum 0.5) and outflow a H (t ) (a is a constant that depends for
example of the gravity constant g), with initial conditions of half filled tank.

We are interested in the inflow as the input variable and the height of the water
H(t) as the output. The system is strongly non-linear and can be described by
the following equations:

V
H (t )
=A
= X (t ) a H (t )
t
t
In the simulations we work with a model which computes this equation. The
input is the inflow and the outputs are an overflow flag (that could be used for
example for an on-off controller), the outflow and the water level.

Figure 1: The water tank model.

We could linearize the system around a stable working point. Then we should
decompose the variables as the sum of a steady state component and a
changing component: X(t)=Xo+x(t) and H(t)=Ho+h(t). Using the first order Taylor
polynomial around the steady state for the non-linear function (the square root
of the water height), and noticing that:

X o = a Ho ,
we obtain the transfer function (which is valid only near the working point):

h(t )
=
G ( s) =
x(t )

2 Ho
a
2A Ho
s
1
a

That is a first order model whose gain and time constant change with the
working point.
However, the system to control is not exactly this one. We do not have direct
access to the inflow in the water tank because the inflow is controlled through a
valve. This valve changes its position with velocity proportional to an input,
which will be the control signal of the system. We will work with the following
model for the valve:

Figure 2: The valve model.


The velocity of the valve is integrated to obtain its position. The values are
limited to the interval (0,1) where zero means closed and one means
completely opened. Then the position is multiplied by the maximum inflow to
compute the inflow to the water tank.

Figure 3: The system to control, water tank and valve.


Our objective is to design a control system that allows the tracking of a
reference, for example a square signal:

Figure 4: The reference signal.

Therefore we see that we have to control a system that is strongly non-linear


and we do not work around a stable working point (so we cannot use one
linearized model).
Let us study the step response in open loop:

Figure 5: Model for the step response in open loop.

Figure 6: Step response in open loop.

We see that the output is non-stable: since the control signal is the velocity of
the valve, a positive input means that the valve will finish completely opened
after some time. Then the tank fills with the maximum slope (0.5). However the
output is limited to values in the interval (0,2) so it saturates in 2m (the tank
cannot contain more water after it is full).
Now let us study response of the system in closed loop:

Figure 7: Model for the step response in closed loop.

Figure 8: Step response in closed loop.

We see that somehow the water tank system behaves like a second order
system. We would like less overshoot in the ouput (there is nearly 40%) and a
faster answer, but the rise time (time in which the output achieves 90% of the
final value for the first time) cannot change much since the inflow is limited to
0.5 because of the valve.

2.1 PID controller


We may try to design a PID controller to improve the output signal. This is
difficult because we are facing a system with strong non-linearities. Heuristic
rules like Ziegler-Nichols tuning method or others could be used. We will just try
to find a PID with good results in the working interval. The transfer function of
the controller:
G ( s) = P +

I
Ds
+
,
s (1 / N ) s + 1

where P=2, I=0, D=1, N=100.


The step response of the system controlled by this PID in close loop is:

Figure 9: Model for the step response in closed loop with PID controller.

Figure 10: Step response in closed loop with PID controller.

That is a better result than before since the overshoot is now less than 20% and
we also got a slightly shorter rising time. We try this controller with the reference
signal that we are interested in tracking:

10

Figure 11: Response to the reference in closed loop with PID controller.

We notice that there is a higher overshoot in the filling than when tank is
emptied. This is caused by the difference between the inflow and the outflow;
for example for a height of 1.5m the outflow is 0.05 2 g 1.5 = 0.27 whereas the
maximum inflow is always 0.5, then we can see that the slope when the tank is
filling is higher than when it is emptied. The PID controller is linear so there will
be a higher overshoot in the filling, because of the higher slope. This is a
limitation of the linear controllers.

2.2 Fuzzy Logic Controller


We could try a fuzzy logic controller whose input variable will be the error in the
level (desired level minus actual water height) and the output will be the velocity
of the valve. As a first approach we could design a Mamdani system with the
following rules:

If Level is Okay, then Valve is No_change.


If Level is Low, then Valve is Open_fast.
If Level is High, then Valve is Close_fast.

These rules could have been supplied by an expert human. The fuzzy controller
then tries to implement this knowledge of the system.
The membership functions for the input variable Level (which is the error of the
actual level) are chosen Gaussian functions to have a smooth answer. We
should study our application to select the parameters of the functions. The tank
11

starts with 0.5m and the reference will change between 0.5m and 1.5m. Then
when the level is okay the error is zero, and if we suppose that the fuzzy
controller is working fine, the maximum errors will be -1, which means that the
level is too high, and 1, which means that the level is too low.
Then the fuzzy set Okay is centered in zero (no error means the level is okay).
As we saw before we can set 1 as the minimum absolute value of the error that
achieves total membership (MF=1) to the sets High and Low. For lower
values we have a Gaussian and for bigger values we maintain the total
membership.

Figure 12: Membership functions of the input Level: High, Okay and Low.

For the membership functions of the Valve we choose triangular membership


functions; they perform well in the application and simplify the process of
defuzzification. No change is around zero so that the position of the valve does
not change (velocity zero). Open fast and Close fast are around 1 and -1
respectively to achieve a higher changing rate in the valve:

Figure 13: MF of the output Valve: Close fast, No change and Open fast.

12

The Mamdani model will use the product for the AND operator and for the
implication, and the max for the aggregation. The output is defuzzified with the
centroid of area method:

Figure 14: An example of Mamdani fuzzy model.

In our system the inferred output of each rule is a fuzzy set scaled down by the
firing strength via product operator; the desired crisp output (big red bar) is
obtained with the defuzzification:

Figure 15: An example of how the rules are fired in our system.

Also we show the model of the Mamdani system for the simulation:

13

Figure 16: The fuzzy model used in the simulation.

The model of the water tank system with the fuzzy logic controller that we used
for the simulations:

Figure 17: The model of the water tank system used in the simulation.

The performance of this fuzzy logic controller is not good because we obtained
a big oscillation in the output around the desired level:

14

Figure 18: Output level using triangular membership function for the output.
Note: Yellow =reference, Pink=level, Blue=Inflow, Cian=Outflow, Green=Control, Red=Error

Also we could try other membership functions for the output, such as the
generalized bell:

Figure 19: Output level using generalized bell membership function for the output.

15

the Gaussian function:

Figure 20: Output level using Gaussian membership function for the output.

or a composite of two Gaussian curves:

16

Figure 21: Output level using another Gaussian membership function for the output.

We observe that there are no important changes. We could conclude that three
rules are not sufficient since the water level tends to oscillate around the
desired level.
The solution to this problem is to slow down the output when we are close to the
reference. We can achieve this effect by adding two extra rules and an new
input variable that takes in account the changing in the height of the water, that
is the changing rate of the level:

If Level is Okay and Rate is Positive, then Valve is Close_slow.


If Level is Okay and Rate is Negative, then Valve is Open_slow.

With these rules the level is going to reduce the slope when it is close to the
reference so there will be fewer oscillations.
The membership functions for the Rate variable:

17

Figure 22: Membership functions of the input Rate: Negative, None and Positive.

We also have to add the new values to the output membership functions. As a
first approach we could set Close slow and Open slow centered in -0.3 and
0.3 respectively:

Figure 23: Membership functions of the output Valve, first approach.

However we saw that the water tank empties slower than it fills. Therefore we
could use the power of the membership functions to design a controller that
overcome this difficulty: we set smaller values for the Open slow membership
function because we saw that the output had smaller slope when the tank
empties. Then we center the Open slow membership function in 0.3:

18

Figure 24: Membership functions of the output Valve, second approach.

The fuzzy system for this simulation:

Figure 25: The fuzzy model for this simulation.

An example of how the rules are fired:

19

Figure 26: An example of how the rules are fired in our system.

The inputs-output function that the fuzzy logic controller implements:

Figure 27: The function implemented by the controller.

Finally we can simulate the water tank system


reference was as follows:

and the response to the

20

Figure 28: Output level using the fuzzy logic controller with best performance.

We see that there is no oscillation and that we solved the problem of the
difference in the flows. We could try with other membership functions for the
input, for example triangular membership functions, but the results were worse:

Figure 29: Output level using triangular membership functions for the input.

21

3. Controlling the Water-tank system using ANFIS


The idea in this part of the project was to try to automatically develop a FIS to
control the water tank problem. The overall system would be like shown below,
where x_d(n) is the input/desired water level, e(n) is the difference between the
actual level, x(n), and desired level and u(n) is the output of the fuzzy logic
controller.
x(n)

1
In1

x_d(n)

e(n)

u(n)

Fuzzy Logic
Controller

VALVE
Subsystem

x(n)

WATER
TANK

1
Out1

tank 2

0.5
tank max
inflow

Figure 30: Controlling the water tank using fuzzy logic controller

As it can be seen this is similar to what was done in the part, where the FIS was
generated manually by a human expert. But of course it would be desirable to
be able to automatically fine-tune or maybe even automatically design the FIS
from scratch.
The first idea was simply to use ANFIS to train the controller. However it soon
became clear that this was not directly possible. This is because ANFIS both
need the input signal, e(n), and the desired output from the FIS, u(n). But clearly
the desired response u(n) of is unknown in this part. (otherwise we would
actually be back at the human expert generating the FIS)
From the model it can quite easy be seen what an appropriate FIS would be
expected to do. The rules of the FIS would be something similar to the following
3 rules.
1. IF e(n) is positive, then output should be positive. This is equal to say
water level should increase, and thus valve should be opened.
2. IF e(n) is negative, then output should be negative. This is equal to say
water level should decrease, and thus valve should be closed.
3. IF e(n) is close to zero, then output should be zero. This is equal to say
water level is ok, and thus valve should not be changed.
These basic ideas of an appropriate behaviour of the controller could of course
be used to design a not to bad FIS and from this make the tuning using ANFIS.
However this would not change the fact that the desired output of the FIS would

22

be required, and since this is still not known, we were quite stuck using this
approach.

3.1 Inverse control in water tank system


Another idea was then to use inverse control. Here the idea was to train the
ANFIS to do the inverse of the water tank system. Thus the output would of
course be equal to the input and the water level would be as desired. This can
easily be seen from the following model of the system. Note that here the
system is both the valve and the water tank itself.
x(n)

1
In1

x_d(n)

u(n)

Fuzzy Logic
Controller

VALVE
Subsystem

WATER
TANK

Out1

tank 2

0.5
tank max
inflow

Figure 31: Fuzzy logic control with no feedback

This situation is similar to the general equalization problem discussed in the


equalization part of this report.
To make the inverse controller a signal was run through the water tank system.
Thus the ANFIS could be trained with output-input pairs of the system to learn
the system behaviour. The following figure shows the system response to a
uniformly distributed random signal.

23

Signals to be used for ANFIS training


2.5
Random input signal
System response

water level / m

1.5

0.5

50

100

150
t/s

200

250

Figure 32: System response to random signal

This is quite obviously not some data that can be used to train the ANFIS. The
system response simply goes to the maximum possible water level, 2m, in very
short time. And in fact it does not change the look of the response what kind of
input signal is used. This is of course due to the fact that the desired water level
always is a positive number, and thus the system has no chance to decrease
the water level by giving a negative input to the valve.
This very clearly tells us that it is not easy to construct a pure feed-forward
controller to control this system.
The following figure shows the system response if a random signal in the range
1 is used as input.

24

Signals to be used for ANFIS training


2.5

Random input signal


System response

water level / m

1.5

0.5

-0.5

-1

50

100

150
t/s

200

250

Figure 33: System response to a random signal with zero mean

This signal is much more likely to be able to train the ANFIS to fit the system.
However this would of course require the possibility of negative values to the
controller, and thus a closed loop system as in Error! Reference source not
found..
Using this data it was tried to train a Sugeno FIS with the following parameters
(generated using the Matlab function genfis1).

5 input membership functions of type generalized Bell MF.


Linear output.
Weighted average defuzzification.
Linear output function

The following figure shows the training error result when training the ANFIS
over 50 epochs.

25

Figure 34: Training error over 50 epochs

The poor convergence quite clearly indicates that the ANFIS has not been fitted
very well to the data. This is furthermore confirmed by plotting the training-data
vs. the output of the ANFIS with the same data as input.

Figure 35: Training data vs. ANFIS output

This on its own indicated that this ANFIS controller would not be usable in the
system. However it was tried and as expected it did no good. The following
figure shows that it is unable to control a square input signal very well. The plot
also shows the system without any controller and a simple feedback loop, which
performs better than the constructed ANFIS controller.

26

1.8
fuzzy control
desired signal
no control

1.6
1.4
1.2
1
0.8
0.6
0.4
0.2
0

50

100

150

200

250

300

Figure 36: System using the ANFIS controller

At this time we thought that it might be a better idea to use a slower varying
signal, instead of the random signal to train the ANFIS. It was then decided to
use a square input signal instead, which is shown together with the
corresponding system response in the following figure.

27

Signals to be used for ANFIS training


2.5
Random input signal
System response

water level / m

1.5

0.5

-0.5

-1

50

100

150
t/s

200

250

Figure 37: System response to a square input signal

Using this to train an ANFIS similar to the one used previously gave the
following results.

Figure 38: Training error using square training signal

28

Figure 39: Training data vs. ANFIS output (square training data)

Even though the training error is much smaller this time, it was still not a
desirable result, but nevertheless it was fitting the training data somewhat better
than what was the case with the random data. So it was tried to use this
controller in the system.

2
fuzzy control
desired signal
no control

1.8
1.6
1.4
1.2
1
0.8
0.6
0.4
0.2
0

50

100

150

200

250

300

Figure 40: System using the ANFIS controller (square training data)

29

It is very obvious that the controller performance is pretty much the same as
with the random data used as training data.
At this point we gave up trying to implement an ANFIS controller. One of the
reasons why this kind of controller does not work, might be that the system
does not have a singular solution to its inverse. This is due to the square root
element in the water tank part of the system, which can be seen in the following
model of the water tank part of the system.

1
flow
in

1/s
sum

tank
volume

1/area

1/area

sqrt(2*9.8*u)
sqrt(2gh)

-K-

outletArea

1
flow
out

Figure 41: Water tank part of the system

This is one of the limitations using inverse control. Since the ANFIS cannot
know which of the possible solutions to choose, it chooses a mean solution,
which in most cases (and in out case) is of no use.

3.2 Specialized learning


Still we wanted to use the ANFIS in the project, and another approach was to
use the technique called specialized learning.
This method can for example be used to adapt the ANFIS to behave similar to
some known controller. In our case we chose for simplicity to try to make an
ANFIS controller behave similar to a PID controller.
We had already used the PID controller earlier in the project and knew some of
the advantages and disadvantages of this type of controller. One of the
disadvantages is that the PID controller does not control the water level
smoothly to the desired level, but leads to some ripple in the output signal.
In [10] it is mentioned how this kind of PID-like ANFIS controller can perform
very well. In this paper it is mentioned how the ANFIS controller gives almost
same settling time but avoids the overshoot/ripple produced by the PID.
In out system the data the ANFIS was to be trained with was generated with the
PID controller placed in the closed loop water tank system. Then the data was
observed as corresponding data pairs on each side of the PID-controller. The
figure below shows the training data.

30

Training data for PID-alike ANFIS controller


200
150
100

value

50
0
-50
-100
-150

8
sample #

10

12

14

16
4

x 10
PID input
PID output

Training data for PID-alike ANFIS controller - zoomed


50

value

-50

-100

-150
3.14

3.141

3.142

3.143

3.144

3.145
sample #

3.146

3.147

3.148

3.149

3.15
4

x 10

Figure 42: ANFIS training data from PID controller

As it can be seen, relatively small input to the PID controller results in pretty
huge output values. Furthermore the process is not totally identical for positive
and negative inputs. This is due to the fact that the water tank is able to fill up
water faster than it can reduce the amount of water in the tank.
Altogether this turns out not to be very easy to duplicate for the ANFIS
controller. One reason to this is the very fast and steep transient in the PID
response followed by a non-linear relatively slow response.
It was tried to train the ANFIS using different delayed versions of the input
signal. This was to some degree successful since it helped the ANFIS to make
a better fit. However at no point the ANFIS was able to make a satisfying fit.
One of the most successful fits is shown in the figure below.

31

Figure 43: PID data pairs vs. ANFIS output for the same input

Even though this gave the best fit we were able to obtain, it was not the ANFIS
which resulted in the best actual performance when applied as controller in the
water tank system.
The following figure shows two different ANFIS controllers made. The first one
uses 5 MFs for one input, while the second one uses 10 MFs and still one
input. This clearly shows how increasing the number of MFs can help us fit the
PID controller better, in sense of in average getting closer to the desired water
level. However it on the other hand has more ripple than in the first example.
A system where delayed versions of the input also was used as input to the
ANFIS, gave less ripple, but on the other hand had a tendency to occasionally
turn the valve in the wrong direction, i.e. adding more water when less water
was desired and the other way around.
All in all this pointed to that a compromise has to be made: Enough MFs
together with a correct number of delayed versions of the input.
However the computational time for training the ANFIS increases very fast as
the number of MFs and inputs is increased. So at this late state of the project
it was not possible to optimize this further.

32

Example of an PID-alike ANFIS controller


1.5

water level / m

0.5

desired level
actual level
0

50

100

150

200

250
t/s

300

350

400

450

500

Figure 44: ANFIS controller designed to "copy" PID

Example of an PID-alike ANFIS controller


1.8
desired level
actual level

1.6

1.4

water level / m

1.2

0.8

0.6

0.4

0.2

50

100

150

200

250
t/s

300

350

400

450

500

Figure 45: ANFIS controller using 10 membership functions

33

Finally the plot below shows the membership functions before and after the
ANFIS training for the 5 MFs example. This shows how the membership
functions has been stretched out by the training process, and most important
the first and the last membership function has been moved, so the middle is
actually moved outside the range of the plot. This indicates that the ANFIS has
been trained to treat extreme values in a special way. These actually
correspond to the case when the PID gives a large () output.
Membership functions before training
in1mf1
1

in1mf2

in1mf3

in1mf4

in1mf5

Degree of membership

0.8

0.6

0.4

0.2

0
-1

-0.5

0.5

1.5

input1

Membership functions after training


in1mf1
1

in1mf2

in1mf3

in1mf4

in1mf5

Degree of membership

0.8

0.6

0.4

0.2

0
-1

-0.5

0.5

1.5

input1

Figure 46: Membership functions before and after training

After having worked with ANFIS in this project it is clear that ANFIS is not just a
general purpose tool. It is very good at handling multiple input / multiple output
complex systems which can be hard/impossible to design directly by a human
expert.
However in this water tank control system it actually was easier to generate a
FIS manually using mostly logical sense and a few formulas. The ANFIS system
showed to be hard to use, when not having directly access to the desired output
of the system and when having to be used in a feedback control loop.
In the inverse control case it also was shown that ANFIS has certain limitations
when the system does not have a unique inverse.
Finally the ANFIS was used in a general specialized learning setup. Here the
Sugeno type of ANFIS had problems with imitate the drastic changes of the PID
controller. Nevertheless our simulations showed that the ANFIS most likely has
the possibility to copy the PID controller and in some sense perform better by
producing less overshoot. However to achieve this it would require more time

34

for investigating the optimum number of membership functions and a


appropriate choice of delayed inputs.

4. Inverse Learning
The simplest approach to control, conceptually, is to make an inverse model of
the plant to be controlled. The development of inverse learning for designing
neuro-fuzzy controllers involves two phases. In the learning phase, an on-line or
off-line technique is used to model the inverse dynamics of the plant. The
obtained neuro-fuzzy model , which represents the inverse dynamics of the
plant, is then used to generate control actions in the application phase. These
two phases can proceed simultaneously, hence this design method fits in
perfectly with the classical adaptive control scheme.
For off-line applications, we have to collect a set of training data pairs and then
train the network in the batch mode. For on-line applications to cope with timevarying plants, the control actions are generated every n time steps while online learning occurs at every time step. Alternatively, we can generate the
control sequence at every time step and apply only the first component to the
plant.
The basic idea of inverse control is to derive the plant with a signal from a
controller whose transfer function is the inverse of that of the plant itself. Since
the plant model is generally unknown, it is necessary to adapt or adjust the
parameters of the controller in order to create a true plant inverse.
Assuming that the order of the plant (the number of state variables) is known
and that the plant can be described by
x(k + 1) = f (x(k ), u (k ))

where x(k + 1) is the state vector at time k + 1 , x(k ) is the state vector at time k ,
and u (k ) is the control signal at time k (for simplicity we assume u (k ) is a
scalar). Accordingly the state vector at time k + 2 is
x(k + 2 ) = f (x(k + 1), u (k + 1)) = f (f (x(k ), u (k )), u (k + 1))

In general
x(k + n ) = F(x(k ), U )

where n is the order of the plant, F is a multiple composite function of f , and


U holds the control actions from k to k + n 1 , which are

(u (k ), u (k + 1),..., u (k + n 1))T

35

The updating equation for the state vector x expresses, that the sequence of
control inputs U will drive the state vector from x(k ) to x(k + n ) in n time steps.
If we assume that the inverse of the plant model does exist, then U can be
expressed as a function of x(k ) and x(k + n ) ,
U = G (x(k ), x(k + n ))

and the problem is now to find the inverse model G .


Although the inverse might exist by assumption, it is not always easy to find in
practice, especially if the determinant, det (G ) , is close to zero.
The task of finding the inverse is easy if the system is linear. Then we can write
the state space equation as
x(k + 1) = Ax(k ) + Bu (k )

where A and B are n n and n 1 matrices, respectively. We can repeat this


equation to obtain the state at k + n
x(k + n ) = A n x(k ) + WU

where W = A n 1B,", AB, B is the controllability matrix. If W is nonsingular,


then the system is controllable and this controllability in a linear system is
equivalent to the inverse condition we were trying to solve, i.e.

U = W 1 x(k + n ) A n x(k )

When we cannot solve as easily for the inverse system we can use an adaptive
network, or ANFIS, with 2n inputs and n outputs to approximate G , assuming
that all state variables are available for measurement. The ANFIS is then used
to learn the inverse of the plant by fitting the data pairs (x(k ), x(k + 1); u (k )) . Then
we have the training data pairs

(x(k ) , x(k + n) ; U )
T

Under the assumption of inverse existence and uniqueness, inverse learning


control typically requires two phases:
1. A learning phase used to approximate G with Gest where the the training
data is collected and applied to train an adaptive network.
2. An application phase, which is a process that takes the constructed
control law to generate the appropriate control actions.
Next figure shows the block diagram of the inverse learning control method. The
upper figure shows the training phase and the lower figure shows the
application phase.

36

If the neuro-fuzzy controller aproximates the inverse dynamic of G , then if the


state x(k ) and the desired future state x d (k + n ) is given (we have to know this
desired state for success of the controller), the neuro-fuzzy controller will
generate a sequence of control actions

U est = G est (x(k ), x d (k + n ))


After n steps, this control sequence will bring the state x(k ) to the desired future
state x d (k + n ) .
For the time-varying plants where the parameters can be changed at any time,
the training process should be done on-line. In this way, the control action will
be done in every n time steps and the training process is conducted every n
time steps. Alternatively, the control sequence can be generated at every time
step and use only the first control action to the plant.
The above method seems straightforward and only one learning task is needed
to find the inverse model of the plant. However, it assumes existence of the
inverse plant, which is not valid in general. Moreover, minimization of the
2
network error eu (k ) does not guarantee minimization of the overall system
error x d (k ) x(k ) .
2

4.1 Example
Now we will look at an example that shows that not only must the inverse of the
plant exist, it must also be unique.
Like every text book, we use the problem where the plant

37

y (k + 1) =

y (k )u (k )

1 + y (k )

tan u (k )

is controlled using an ANFIS-based inverse-learning control. y (k ) and u (k ) are


the state and control action, respectively, at time step k . In this example we
assume the dynamics of the plant to be unknown, and we will build an ANFIS
that maps a given input pair [ y (k ), y (k + 1)] to a desired control action.
First we need to collect data pairs for training and inputs u(k), k = 1,,101 are
chosen uniformly distributed random numbers between -1 and 1. The training
data is then stacked in the form of [ y (k ), y (k + 1); u (k )] and the ANFIS is trained
for some chosen number of epochs. The desired trajectory is defined by

2k
2k
y kd = 0.6 sin
+ 0.2 sin

250
50
We began by choosing = 1 and the ANFIS had a total of nine rules and three
membership functions. We used 100 data points for training and 30 epochs.
The more epochs we used the more the membership functions changed during
training (as to be expected). If only one epoch is used then the membership
functions does not change at all. This gave excellent results (Figure 47Figure
48Figure 49Figure 50Figure 51).
1.5
0.5

y(k)

u(k)

0.5
0

0
0.5

0.5

1
1.5
0

20

40

60

80

100

20

40

60

Time

Time

Training Data

Training Data

80

100

y(k+1)

0.5
0

0.5
1
1
0
2
2

1
1

0
y(k)

y(k+1)

y(k)

Figure 47: Collecting training data ( = 1 )

38

Error Curves
RootMeanSquared Error

0.04
0.035
0.03
0.025
0.02
0.015
0.01
0.005

10

15
Epochs

20

25

30

20

25

30

Step Sizes
0.13
0.12
0.11
0.1
0.09
0.08

10

15
Epochs

Figure 48: Error curves (upper) and step sizes (lower) ( = 1 )


Initial MFs on y(k)

Initial MFs on y(k+1)

0.8

0.8

0.6

0.6

0.4

0.4

0.2

0.2

Final MFs on y(k)

0.8

0.8

0.6

0.6

0.4

0.4

0.2

0.2

Final MFs on y(k+1)

Figure 49: Initial and final membership functions ( = 1 )


ANFIS Output

1
0.5
0
0.5
1
1.5
2
1.5
1
0.5
0
0.5
1
1.5
y(k+1)

1.5

0.5

0.5

1.5

y(k)

Figure 50: The ANFIS output ( = 1 )

39

Actual and Desired y(k)

2
desired
actual

1
0
1

10

20

30

40

50
Time

60

70

80

90

100

10

20

30

40

50
Time

60

70

80

90

100

10

20

30

40

50
Time

60

70

80

90

100

0.04

Error

0.02
0
0.02

u(k)

0.5

Figure 51: The results for

=1

Next we tried using less then one and began with = 0.8 . We used 3
generalized bell membership functions, 100 data points for training and 30
epochs. We clearly see that the quality deteriorates, but it still gives very good
results (figures Figure 52Figure 53Figure 54Figure 55 and Figure 56).
1.5
1

0.5
y(k)

u(k)

0.5
0

0
0.5

0.5

1
1.5
0

20

40

60

80

100

20

40

60

Time

Time

Training Data

Training Data

80

100

1
y(k+1)

0.5
0

0.5
1
1
0
2
2

0
y(k)

y(k+1)

y(k)

Figure 52: Collecting training data ( = 0.8 )

Error Curves
RootMeanSquared Error

0.03
0.025
0.02
0.015
0.01
0.005

10

15
Epochs

20

25

30

20

25

30

Step Sizes
0.13
0.12
0.11
0.1
0.09
0.08
0.07

10

15
Epochs

Figure 53: Error curves (upper) and step sizes (lower) ( = 0.8 )

40

Initial MFs on y(k)

Initial MFs on y(k+1)

0.8

0.8

0.6

0.6

0.4

0.4

0.2

0.2

Final MFs on y(k)

Final MFs on y(k+1)

0.8

0.8

0.6

0.6

0.4

0.4

0.2

0.2

Figure 54: Initial and final membership functions ( = 0.8 )

ANFIS Output

1
0
1
2
3
4
5
6
7
1.5
1

1.5

0.5

0.5
0

0.5

0.5

1.5

1.5

y(k+1)

y(k)

Actual and Desired y(k)

Figure 55: The ANFIS output ( = 0.8 )


2
desired
actual

1
0
1

10

20

30

40

50
Time

60

70

80

90

100

10

20

30

40

50
Time

60

70

80

90

100

10

20

30

40

50
Time

60

70

80

90

100

0.15

Error

0.1
0.05
0
0.05

u(k)

0.5

Figure 56: The results for

= 0 .8

Next we tried to use = 0.5 . We clearly see that the quality deteriorates more
than before. There is always a question, however, if training is inadequate. We
therefore tried to increase the size of the training data set from 100 to 300, and
then from 300 to 1000 data points, used 5 membership functions instead of 3,
and increased the number of epochs from 30 to 50. The results were still not
good (Figure 57Figure 58Figure 59Figure 60Figure 61).

41

1
0.5
y(k)

u(k)

0.5

0
0.5

0.5

1
0

100

200

300

100

200

Time

Time

Training Data

Training Data

300

1.5
1
0.5

y(k+1)

0.5

0.5
0.5
1

0
1.5
2

0
y(k)

0
1

y(k+1)

y(k)

Figure 57: Collecting training data ( = 0.5 )


Error Curves
RootMeanSquared Error

0.05
0.04
0.03
0.02
0.01
0

10

15

20

25
Epochs

30

35

40

45

50

30

35

40

45

50

Step Sizes
0.1
0.09
0.08
0.07
0.06
0.05
0.04

10

15

20

25
Epochs

Figure 58: Error curves (upper) and step sizes (lower) ( = 0.5 )

Initial MFs on y(k)

Initial MFs on y(k+1)

0.8

0.8

0.6

0.6

0.4

0.4

0.2

0.2

0.5

0.5

Final MFs on y(k)

1
0.8

0.6

0.6

0.4

0.4

0.2

0.2
1

0.5

0.5

0.5

Final MFs on y(k+1)

0.8

0.5

0.5

0.5

Figure 59: Initial and final membership functions ( = 0.5 )

42

ANFIS Output

10

15

20
1
0.5

1
0.5

0
0

0.5

0.5
1

y(k+1)

y(k)

Actual and Desired y(k)

Figure 60: The ANFIS output ( = 0.5 )

2
desired
actual

1
0
1

50

100

150
Time

200

250

300

50

100

150
Time

200

250

300

50

100

150
Time

200

250

300

Error

10
5
0
5
10

u(k)

0
10
20

Figure 61: The results for = 0.5

When we further decreased the value of we got really bad results and no
matter how we tried to use more exhaustive learning. And to show one extreme
case, we tried using = 0.1 . We tried 300 and 1000 data points for training,
used 5 Generalized bell membership functions and 50 and 100 epochs. The
result was really bad (as to be expected) (Figure 62Figure 63Figure 64,Figure
65Figure 66).
0.8
0.6

y(k)

u(k)

0.5

0.4
0.2

0.5

0
0.2
0

100

200

300

100

200

Time

Time

Training Data

Training Data

300

0.4
0.3

y(k+1)

0.2

0.5

0.1

0.5

0.1
0.2

0.2
0.3
0.5

0
0

0.5

y(k+1)

0.2

0
0.2

0.4
0.2
y(k)

0.6

0.8

y(k)

Figure 62: Collecting training data ( = 0.1 )

43

Error Curves
RootMeanSquared Error

0.15
0.14
0.13
0.12
0.11
0.1
0.09

10

15

20

25
Epochs

30

35

40

45

50

30

35

40

45

50

Step Sizes
0.1
0.09
0.08
0.07
0.06
0.05

10

15

20

25
Epochs

Figure 63: Error curves (upper) and step sizes (lower) ( = 0.1 )
Initial MFs on y(k)

Initial MFs on y(k+1)

0.8

0.8

0.6

0.6

0.4

0.4

0.2
0
0.2

0.2
0

0.2

0.4

0.6

0
0.2

0.8

Final MFs on y(k)

0.1

0.2

0.3

0.2

0.3

Final MFs on y(k+1)

0.8

0.8

0.6

0.6

0.4

0.4

0.2
0
0.2

0.1

0.2
0

0.2

0.4

0.6

0
0.2

0.8

0.1

0.1

Figure 64: Initial and final membership functions ( = 0.1 )

ANFIS Output

30
25
20
15
10
5
0
5
10
15
0.3
0.2
0.8

0.1

0.6
0

0.4
0.2

0.1
0.2
y(k+1)

0
0.2
y(k)

Figure 65: The ANFIS output( = 0.1 )

44

Actual and Desired y(k)

2
desired
actual

1
0
1

50

100

150
Time

200

250

300

50

100

150
Time

200

250

300

50

100

150
Time

200

250

300

50

Error

0
50
100
3000

u(k)

2000
1000
0
1000

Figure 66: The results for = 0.1

We also plotted the result from all the tested values on the same graph for
comparison.
2
desired output
=0.1
=0.5
=0.8
=1

1.5

0.5

0.5

50

100

150

200

250

300

Figure 67: Comparison of results for different values of

When looking at the different figures representing the same nonlinear plant but
with different values of , we first noted the distribution of the training points.
For lower valued we got the training data points closer together, i.e. they
were not uniformly distributed. For close to or equal to one we got more
uniformly distributed training points - and that is of course how we want it to be.

4.2 Multivalued Inverse


We now show that the above example does not have unique inverse and we
begin rewriting
y (k + 1) =

y (k )u (k )

1 + y (k )

tan u (k )

as

y (k + 1) = b(k )u (k ) tan u (k )

45

where
b(k ) =

y (k )

1 + y (k )2

is constant for a given current state. The maximum of b(k ) occurs when

db(k )
1 + y (k )
=
dy (k ) 1 + y (k )2

is zero, i.e. when y (k ) = 1 . Therefore we know that b(k ) has a maximum in


1
. We can verify that b(k ) = 1 is the limit between single and multiple valued
2
inverses of y (k + 1) as a function of u (k ) , and therefore we have a unique
inverse if is bigger than 0.5. The verification implies the calculation of the
inverse of b(k ) .

4.3 Specialized Learning


Specialized learning is an alternative method that tries to minimize the system
error directly by backpropagating error signals through the plant block. In order
to backpropagate error signals through the plant we need to find a model
representing the behaviour of the plant. In fact, in order to apply
backpropagation learning, all we need to know is the Jacobian matrix of the
plant, where the element at row i and column j is equal to the derivative of the
plants ith output with respect to its jth input.
if the Jacobian matrix is not easy to find, we can try on-line estimation of the
matrix from the changes of the plants inputs and outputs during two
consecutive time instants.
Specialized learning is often used in cases where we do not know if the system
has an inverse. We will not cover this topic here.

4.4 Conclusions
We can train an ANFIS to approximate a certain nonlinear function. Because
there is no local extremity in a fuzzy logic system, the convergence to the
inverse solution is always guaranteed. Also the fuzzy controller has profit it
computational aspects. But when the function being approximated has strong
nonlinearity or has many inputs, lots of fuzzy rules are needed and large
memory size may be required.

46

We looked at an example and saw that is was not only recessary for the plant to
have an inverse, but it also needed to have a unique one.

5. ANFIS application - Equalizer


The channel equalizing problem arises frequently in dispersive digital
communication channels, and proposes a way of using ANFIS to tackle this
specific classification problem in signal processing. ANFIS uses an efficient
least-squares method and therefore requires little training time to perform the
task.
In digital communication we want to transmit a sequence of binary signals, s (t ) ,
from one place to another via a communication channel. So, ideally we would
receive the same signal, s (t ) , at the end of the channel with a slight time delay.
However, in real life we always have some complications:
a) Communication channels are never perfect; cross coupling, interference,
and attenuation tend to disperse and weaken signals during
transmission.
b) Noise is everywhere and is easily added to the transmitted signals.
The task of the channel equalizer is to estimate the input signals using the
information contained in the observations x(t ) = [x(t ),..., x(t m1)] , where m is the
order of the equalizer.
Where there is no noise, we can define two possible output vectors that can be
produced from sequences of channel inputs containing s (t ) = 1 as:

{
}
= {x R s (t ) = 1}

P+ = x R 2 s(t ) = 1
P

The task of the equalizer is to decide whether an observation x(t ) represents a


noise corrupted version of an element in either P+ or P , and therefore
determine the input signal s (t ) .
Often, linear transversal equalizer is used for this purpose. For the linear
transversal equalizer to estimate the input signal correctly P+ and P has to be
linearly separable. For that to work, we must have the roots of the channel
transfer function lying strictly inside the unit circle on the complex plane, i.e. the
transfer function has to be minimal phased. Figure 68 shows a linear decision
boundary for a minimal phased channel (above) and a non minimum phased
system that cannot use linear function to separate between the two signals.

47

Minimum Phase Channel H(z)=1.0+0.8z +0.5z


3
2

x(t1)

1
0
1
2
3
3

Nonminimum Phase Channel H(z)=0.5+z


3
2

x(t1)

1
0
1
2
3
3

0
x(t)

Figure 68: Channel outputs

For nonlinear, non minimum phased channel we have to estimate the


correlation matrix (which is not an easy task) and then we can plot the optimal
decision boundary (Figure 69):
Optimal Decision Surface

Threshold = 0

2
0

x(t1) 2

0
2
0
2

x(t1) 2

0
2

x(t)

Decision Surface after Thresholding

x(t)

Optimal Decision Boundary


3
2

1
0

1
x(t1)

1
2

0
1

0
2
x(t1) 2

2
0
2

x(t)

0
x(t)

Figure 69: Optimum decision surface by estimation of the correlation matrix

Nonlinear distortion over a communication channel is now a significant factor


hindering further increase in the attainable data rate in high-speed data
transmission. Because the received signal over a nonlinear channel is a
nonlinear function of the past values of the transmitted symbols, and the
nonlinear distortion varies with time and from place to place, effective equalizers
for nonlinear channels should be nonlinear and adaptive. Therefore we shall
use ANFIS. Since ANFIS estimates the decision boundary by sample data
directly, we do not need any assumptions about the nature of the channel
characteristics or the noise signal.
As usual we begin with collecting training data and this is done by feeding a
sequence of binary random signals s (t ) (we use a Bernoulli sequence of 1)
into the non minimal phase impulse response function defined by

H ( z ) = 0.5 + z 1

48

And we made these training data set which has SNR = 20 and SNR = 3,
respectively.
Original Signals

Ideally Received Signals (Noise Free)

100

200

300

400

500

100

Noise
3

100

200

200

300

400

500

Actually Received Signals (SNR = 20)

300

400

500

100

200

300

400

500

Figure 70: Training data set - SNR = 20

Original Signals

Ideally Received Signals (Noise Free)

100

200

300

400

500

100

Noise
3

2
100

200

300

400

500

Actually Received Signals (SNR = 3)

200

300

400

500

100

200

300

400

500

Figure 71: Training data set - SNR 3

FiguresFigure 72Figure 73 show the distribution and density for the above
training data.
Training Data Density
Training Data Distribution

Density Contours
3

0.5

x(t1)

x(t1)

1
0
0
2
1

0
1

0
x(t)

2
x(t1)

0
1

0
x(t)

x(t)

Figure 72: Training data distribution and density - SNR =20.

49

Training Data Density


Training Data Distribution

Density Contours
3

1
2

0.5

x(t1)

x(t1)

1
0

2
2

0
2

0
x(t)

0
1

2
x(t1)

0
x(t)

x(t)

Figure 73: Training data distribution and density - SNR 3.

Obviously, we can more easily distinguise between the tops in the density
function when we have higher SNR ratio. There is, of course, easier to separate
the two signals if the strength of the signal compared to the noise is high.
Since the noise is Gaussian around vectors in P+ and P , we can identify the
peaks of the density functions and define the confidence region of the ANFIS
equalizer as the internal area surrounded by the contour at height 0.05. We now
look at decision boundaries generated by the ANFIS with four and nine rules,
respectively (100 epochs, generalized bell mf). Figures Figure 74 to Figure 77
show the results.

ANFIS Surface: 4 Rules

Threshold = 0

1
1

1
0

0
1

x(t1)

0
x(t)

x(t1)

Decision Surface after Thresholding

0
x(t)

Decision Boundary
1.5

1
1

0.5

x(t1)

1
1

0
0.5

0
x(t1)

1
1

0
x(t)

1.5
1

0
x(t)

Figure 74: ANFIS equalizer using two membership function per variable (SNR = 20)
ANFIS Surface: 4 Rules

Threshold = 0

2
0

0
2

x(t1)

2
x(t1)

x(t)

Decision Surface after Thresholding

0
x(t)

Decision Boundary
3

x(t1)

1
2

0
2
x(t1)

0
1

0
x(t)

3
2

x(t)

Figure 75: ANFIS equalizer using two membership function per variable (SNR 3)

50

ANFIS Surface: 9 Rules

Threshold = 0

1
1

1
0

0
1

x(t1)

0
x(t)

x(t1)

Decision Surface after Thresholding

0
x(t)

Decision Boundary
1.5

1
1

0.5

x(t1)

1
1

0
0.5

0
x(t1)

1
1

0
x(t)

1.5
1

0
x(t)

Figure 76: ANFIS equalizer using three membership function per variable (SNR = 20)

ANFIS Surface: 9 Rules

Threshold = 0

2
0

0
2

x(t1)

2
x(t1)

x(t)

Decision Surface after Thresholding

0
x(t)

Decision Boundary
3

x(t1)

1
2

0
2
x(t1)

0
1

0
x(t)

3
2

x(t)

Figure 77: ANFIS equalizer using three membership function per variable (SNR 3)

Next we combined the decision boundary and confidence region in figures


Figure 78Figure 79:

Figure 78: Decision boundary and confidence region (SNR = 20)

51

Figure 79: Decision boundary and confidence region (SNR 3)

We also tried to use Gaussian instead of the generalized bell membership


functions but it gave very similar results.
We see that there is a slight difference in the decision boundary when working
with four or nine rules, respectively (i.e. 2 or 3 membership functions). One
should think that the performance should be improved by allowing the ANFIS to
have more degree of freedom (i.e. more rules) to match the training data, but
that is not the case here. The reason is that some input vectors fall outside the
ANFIS confidence region and therefore wrong predictions are made by the nine
rule ANFIS equalizer.
From the above example we see that the ANFIS equalizer actually performs quite
well without all knowledge of the channel. But when working outside the confidence
region we run into problems. Therefore we should never take the ANFIS results to
literally - understanding the data is always crucial.

52

6. References
1. J.-S. R. Jang, C.-T. Sun, E. Mizutani. Neuro-Fuzzy and Soft Computing.
Prentice Hall, 1997.
2. Jyh-Shing, Roger Jang and Chuen-Tsai Sun. Neuro-Fuzzy Modeling and
Control. IEEE , 1995.
3. Marwan Bikdash, Maria Walden, and Eddie L. Branch. Multi-Valuedness
Destroys Data Contiguity for Inverse-Learning Control. NASA
Autonomous Control Engineering Center, 1999.
4. Sang-Moon Ryu, Dong-Jo Park and Seok-Yong Oh. Inverse Mapping
Using FLS and its Application to Control. IEEE, 1995.
5. Jan Jantzen. Neural and Neurofuzzy Control. Technical University of
Danmark. Tech. report no 99-H 999, 2003.
6. Chin_teng Lin and Chia-Feng Juang. An Adaptive Neural Fuzzy Filter
and its Applications. IEEE, 1996.
7. Colin F.N. Cowan. Communications Equalization Using Non-Linear
Adaptive Networks. IEEE, 1991.
8. Li-Xin Wang. Fuzzy Adaptive Filters, with Application to Nonlinear
Channel Equalization. IEEE, 1993.
9. Bihua Lin, Pu Han, Dongfeng Wang, Qigang Gun. Control of BoilerTurbine Unit Based on Adaptive Neuro-Fuzzy Inference System. IEEE,
2003.
10. S. Ushakumari. Adaptive Neuro-Fuzzy Controller for Improved
Performance of a Permanent Magnet Brushless DC Motor. IEEE, 2001.

53

Anda mungkin juga menyukai