neuro fuzzy control2 - university of iceland · 1 neuro-fuzzy control j. lilja pálsdóttir poul...

53
1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University of Iceland

Upload: phamtu

Post on 31-Aug-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

1

NEURO-FUZZY CONTROL

J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University of Iceland

Page 2: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

2

Page 3: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

3

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

Page 4: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

4

1. Introduction Fuzzy control provides a formal methodology for representing, manipulating, and implementing a human’s 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 )(tHa (a is a constant that depends for example of the gravity constant g), with initial conditions of half filled tank.

Page 5: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

5

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:

)()()( tHatXttHA

tV

−=∂

∂=

∂∂

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:

Page 6: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

6

oo HaX = , we obtain the transfer function (which is valid only near the working point):

saHA

aH

txthsG

o

o

⎟⎟⎠

⎞⎜⎜⎝

⎛−

−==

21

2

)()()( ,

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:

Page 7: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

7

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.

Page 8: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

8

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.

Page 9: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

9

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:

1)/1()(

+++=

sNDs

sIPsG ,

where P=2, I=0, D=1, N=100. The step response of the system controlled by this PID in close loop is:

Page 10: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

10

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:

Page 11: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

11

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 27.05.1205.0 =⋅g 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

Page 12: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

12

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.

Page 13: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

13

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:

Page 14: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

14

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:

Page 15: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

15

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.

Page 16: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

16

the Gaussian function:

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

or a composite of two Gaussian curves:

Page 17: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

17

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:

Page 18: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

18

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:

Page 19: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

19

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:

Page 20: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

20

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 and the response to the reference was as follows:

Page 21: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

21

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.

Page 22: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

22

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.

1Out1

0.5

tank maxinflow

WATERTANK

tank 2

VALVE

SubsystemFuzzy Logic

Controller

1In1

x(n)x(n)

e(n) u(n)x_d(n)

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

Page 23: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

23

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.

1Out1

0.5

tank maxinflow

WATERTANK

tank 2

VALVE

SubsystemFuzzy Logic

Controller

1In1

x(n)

u(n)x_d(n)

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.

Page 24: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

24

0 50 100 150 200 2500

0.5

1

1.5

2

2.5Signals to be used for ANFIS training

t / s

wat

er le

vel /

m

Random input signalSystem response

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.

Page 25: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

25

0 50 100 150 200 250-1

-0.5

0

0.5

1

1.5

2

2.5Signals to be used for ANFIS training

t / s

wat

er le

vel /

mRandom input signalSystem response

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.

Page 26: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

26

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.

Page 27: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

27

0 50 100 150 200 250 3000

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8fuzzy controldesired signalno control

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.

Page 28: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

28

0 50 100 150 200 250-1

-0.5

0

0.5

1

1.5

2

2.5Signals to be used for ANFIS training

t / s

wat

er le

vel /

mRandom input signalSystem response

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

Page 29: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

29

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.

0 50 100 150 200 250 3000

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2fuzzy controldesired signalno control

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

Page 30: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

30

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

flowout

1/s

tankvolume

sum

sqrt(2*9.8*u)

sqrt(2gh)

-K-

outletArea

1/area

1/area

1

flowin

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.

Page 31: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

31

0 2 4 6 8 10 12 14 16

x 104

-150

-100

-50

0

50

100

150

200Training data for PID-alike ANFIS controller

sample #

valu

e

3.14 3.141 3.142 3.143 3.144 3.145 3.146 3.147 3.148 3.149 3.15

x 104

-150

-100

-50

0

50Training data for PID-alike ANFIS controller - zoomed

sample #

valu

e

PID inputPID output

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.

Page 32: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

32

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 MF’s for one input, while the second one uses 10 MF’s and still one input. This clearly shows how increasing the number of MF’s 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 MF’s 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 MF’s and inputs is increased. So at this “late” state of the project it was not possible to optimize this further.

Page 33: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

33

0 50 100 150 200 250 300 350 400 450 5000

0.5

1

1.5Example of an PID-alike ANFIS controller

t / s

wat

er le

vel /

m

desired levelactual level

Figure 44: ANFIS controller designed to "copy" PID

0 50 100 150 200 250 300 350 400 450 5000.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8Example of an PID-alike ANFIS controller

t / s

wat

er le

vel /

m

desired levelactual level

Figure 45: ANFIS controller using 10 membership functions

Page 34: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

34

Finally the plot below shows the membership functions before and after the ANFIS training for the 5 MF’s 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.

-1 -0.5 0 0.5 1 1.5

0

0.2

0.4

0.6

0.8

1

input1

Deg

ree

of m

embe

rshi

p

in1mf1 in1mf2 in1mf3 in1mf4 in1mf5

Membership functions before training

-1 -0.5 0 0.5 1 1.5

0

0.2

0.4

0.6

0.8

1

input1

Deg

ree

of m

embe

rshi

p

in1mf1 in1mf2 in1mf3 in1mf4 in1mf5

Membership functions after training

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

Page 35: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

35

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 time-varying plants, the control actions are generated every n time steps while on-line 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

( ) ( ) ( )( )kukk ,1 xfx =+ where ( )1+kx is the state vector at time 1+k , ( )kx is the state vector at time k , and ( )ku is the control signal at time k (for simplicity we assume ( )ku is a scalar). Accordingly the state vector at time 2+k is

( ) ( ) ( )( ) ( ) ( )( ) ( )( )1,,1,12 +=++=+ kukukkukk xffxfx In general

( ) ( )( )UxFx ,knk =+ 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 1−+ nk , which are

( ) ( ) ( )( )Tnkukuku 1,...,1, −++

Page 36: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

36

The updating equation for the state vector x expresses, that the sequence of control inputs U will drive the state vector from ( )kx to ( )nk +x 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 ( )kx and ( )nk +x ,

( ) ( )( )nkk += xxGU , 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, ( )Gdet , 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

( ) ( ) ( )kukk BAxx +=+1 where A and B are nn× and 1×n matrices, respectively. We can repeat this equation to obtain the state at nk +

( ) ( ) WUxAx +=+ knk n where [ ]BABBAW ,,,1−= n 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.

( ) ( )[ ]knk nxAxWU −+= −1 When we cannot solve as easily for the inverse system we can use an adaptive network, or ANFIS, with n2 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 ( ) ( ) ( )( )kukk ;1, +xx . Then we have the training data pairs

( ) ( )( )TTT nkk Uxx ;, + 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.

Page 37: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

37

If the neuro-fuzzy controller aproximates the inverse dynamic of G , then if the state ( )kx and the desired future state ( )nkd +x 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

( ) ( )( )nkk destest += xxGU , After n steps, this control sequence will bring the state ( )kx to the desired future state ( )nkd +x . 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 network error ( ) 2keu does not guarantee minimization of the overall system

error ( ) ( ) 2kkd xx − .

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

Page 38: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

38

( ) ( ) ( )( )

( )kukykukyky tan

11 2 α−

+=+

is controlled using an ANFIS-based inverse-learning control. ( )ky and ( )ku 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 ( ) ( )[ ]1, +kyky 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 ( ) ( ) ( )[ ]kukyky ;1, + and the ANFIS is trained for some chosen number of epochs. The desired trajectory is defined by

⎟⎠⎞

⎜⎝⎛+⎟

⎠⎞

⎜⎝⎛=

502sin2.0

2502sin6.0 kkyd

kππ

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).

0 20 40 60 80 100

−0.5

0

0.5

Time

u(k)

0 20 40 60 80 100

−1.5

−1

−0.5

0

0.5

1

1.5

Time

y(k)

−2 −1 0 1 2−2

−1

0

1

2

y(k)

y(k+

1)

Training Data

−10

1−1

01

−0.5

0

0.5

y(k)

Training Data

y(k+1) Figure 47: Collecting training data ( 1=α )

Page 39: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

39

0 5 10 15 20 25 300.005

0.01

0.015

0.02

0.025

0.03

0.035

0.04

Epochs

Roo

t−M

ean−

Squ

ared

Err

or

Error Curves

0 5 10 15 20 25 300.08

0.09

0.1

0.11

0.12

0.13

Epochs

Step Sizes

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

−1 0 10

0.2

0.4

0.6

0.8

1

Initial MFs on y(k)

−1 0 10

0.2

0.4

0.6

0.8

1

Initial MFs on y(k+1)

−1 0 10

0.2

0.4

0.6

0.8

1

Final MFs on y(k)

−1 0 10

0.2

0.4

0.6

0.8

1

Final MFs on y(k+1)

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

−1.5−1

−0.50

0.51

1.5

−1.5−1

−0.50

0.51

1.5

−2

−1.5

−1

−0.5

0

0.5

1

y(k)

ANFIS Output

y(k+1) Figure 50: The ANFIS output ( 1=α )

Page 40: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

40

0 10 20 30 40 50 60 70 80 90 100−1

0

1

2

Time

Act

ual a

nd D

esire

d y(

k)

desiredactual

0 10 20 30 40 50 60 70 80 90 100−0.02

0

0.02

0.04

Time

Err

or

0 10 20 30 40 50 60 70 80 90 100−1

−0.5

0

Time

u(k)

Figure 51: The results for 1=α

Next we tried using α less then one and began with 8.0=α . 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).

0 20 40 60 80 100

−0.5

0

0.5

Time

u(k)

0 20 40 60 80 100

−1.5

−1

−0.5

0

0.5

1

1.5

Time

y(k)

−2 −1 0 1 2−2

−1

0

1

2

y(k)

y(k+

1)

Training Data

−10

1−1

01

−0.5

0

0.5

y(k)

Training Data

y(k+1) Figure 52: Collecting training data ( 8.0=α )

0 5 10 15 20 25 300.005

0.01

0.015

0.02

0.025

0.03

Epochs

Roo

t−M

ean−

Squ

ared

Err

or

Error Curves

0 5 10 15 20 25 300.07

0.08

0.09

0.1

0.11

0.12

0.13

Epochs

Step Sizes

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

Page 41: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

41

−1 0 10

0.2

0.4

0.6

0.8

1

Initial MFs on y(k)

−1 0 10

0.2

0.4

0.6

0.8

1

Initial MFs on y(k+1)

−1 0 10

0.2

0.4

0.6

0.8

1

Final MFs on y(k)

−1 0 10

0.2

0.4

0.6

0.8

1

Final MFs on y(k+1)

Figure 54: Initial and final membership functions ( 8.0=α )

−1.5−1

−0.50

0.51

1.5

−1.5−1

−0.50

0.51

1.5

−7

−6

−5

−4

−3

−2

−1

0

1

y(k)

ANFIS Output

y(k+1) Figure 55: The ANFIS output ( 8.0=α )

0 10 20 30 40 50 60 70 80 90 100−1

0

1

2

Time

Act

ual a

nd D

esire

d y(

k)

desiredactual

0 10 20 30 40 50 60 70 80 90 100−0.05

0

0.05

0.1

0.15

Time

Err

or

0 10 20 30 40 50 60 70 80 90 100−1

−0.5

0

Time

u(k)

Figure 56: The results for 8.0=α

Next we tried to use 5.0=α . 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).

Page 42: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

42

0 100 200 300

−0.5

0

0.5

Time

u(k)

0 100 200 300

−1

−0.5

0

0.5

1

Time

y(k)

−2 −1 0 1 2−1.5

−1

−0.5

0

0.5

1

1.5

y(k)

y(k+

1)Training Data

−10

1

−1

0

1

−0.5

0

0.5

y(k)

Training Data

y(k+1) Figure 57: Collecting training data ( 5.0=α )

0 5 10 15 20 25 30 35 40 45 500

0.01

0.02

0.03

0.04

0.05

Epochs

Roo

t−M

ean−

Squ

ared

Err

or

Error Curves

0 5 10 15 20 25 30 35 40 45 500.04

0.05

0.06

0.07

0.08

0.09

0.1

Epochs

Step Sizes

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

−1 −0.5 0 0.5 10

0.2

0.4

0.6

0.8

1

Initial MFs on y(k)

−1 −0.5 0 0.5 10

0.2

0.4

0.6

0.8

1

Initial MFs on y(k+1)

−1 −0.5 0 0.5 10

0.2

0.4

0.6

0.8

1

Final MFs on y(k)

−1 −0.5 0 0.5 10

0.2

0.4

0.6

0.8

1

Final MFs on y(k+1)

Figure 59: Initial and final membership functions ( 5.0=α )

Page 43: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

43

−1

−0.5

0

0.5

1

−1

−0.5

0

0.5

1

−20

−15

−10

−5

0

5

y(k)

ANFIS Output

y(k+1) Figure 60: The ANFIS output ( 5.0=α )

0 50 100 150 200 250 300−1

0

1

2

Time

Act

ual a

nd D

esire

d y(

k)

desiredactual

0 50 100 150 200 250 300−5

0

5

10

Time

Err

or

0 50 100 150 200 250 300−20

−10

0

10

Time

u(k)

Figure 61: The results for 5.0=α

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 1.0=α . 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 100 200 300

−0.5

0

0.5

Time

u(k)

0 100 200 300−0.2

0

0.2

0.4

0.6

0.8

Time

y(k)

−0.5 0 0.5 1−0.3

−0.2

−0.1

0

0.1

0.2

0.3

0.4

y(k)

y(k+

1)

Training Data

−0.20 0.2 0.4 0.6 0.8

−0.20

0.2

−0.5

0

0.5

y(k)

Training Data

y(k+1) Figure 62: Collecting training data ( 1.0=α )

Page 44: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

44

0 5 10 15 20 25 30 35 40 45 500.09

0.1

0.11

0.12

0.13

0.14

0.15

Epochs

Roo

t−M

ean−

Squ

ared

Err

or

Error Curves

0 5 10 15 20 25 30 35 40 45 500.05

0.06

0.07

0.08

0.09

0.1

Epochs

Step Sizes

Figure 63: Error curves (upper) and step sizes (lower) ( 1.0=α )

−0.2 0 0.2 0.4 0.6 0.80

0.2

0.4

0.6

0.8

1

Initial MFs on y(k)

−0.2 −0.1 0 0.1 0.2 0.30

0.2

0.4

0.6

0.8

1

Initial MFs on y(k+1)

−0.2 0 0.2 0.4 0.6 0.80

0.2

0.4

0.6

0.8

1

Final MFs on y(k)

−0.2 −0.1 0 0.1 0.2 0.30

0.2

0.4

0.6

0.8

1

Final MFs on y(k+1)

Figure 64: Initial and final membership functions ( 1.0=α )

−0.20

0.20.4

0.60.8

−0.2

−0.1

0

0.1

0.2

0.3

−15

−10

−5

0

5

10

15

20

25

30

y(k)

ANFIS Output

y(k+1) Figure 65: The ANFIS output( 1.0=α )

Page 45: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

45

0 50 100 150 200 250 300−1

0

1

2

Time

Act

ual a

nd D

esire

d y(

k)

desiredactual

0 50 100 150 200 250 300−100

−50

0

50

Time

Err

or

0 50 100 150 200 250 300−1000

0

1000

2000

3000

Time

u(k)

Figure 66: The results for 1.0=α

We also plotted the result from all the tested α values on the same graph for comparison.

0 50 100 150 200 250 300−1

−0.5

0

0.5

1

1.5

2desired outputα=0.1α=0.5α=0.8α=1

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

( ) ( ) ( )( )

( )kukykukyky tan

11 2 α−

+=+

as

( ) ( ) ( ) ( )kukukbky tan11−=+

α

Page 46: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

46

where

( ) ( )( )21

1ky

kykb+

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

( )( )

( )( )( )22

2

1

1

ky

kykdykdb

+

+−=α

is zero, i.e. when ( ) 1±=ky . Therefore we know that ( )kb has a maximum in

α21 . We can verify that ( ) 1=kb is the limit between single and multiple valued

inverses of ( )1+ky as a function of ( )ku , and therefore we have a unique inverse if α is bigger than 0.5. The verification implies the calculation of the inverse of ( )kb .

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 plant’s 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 plant’s 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.

Page 47: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

47

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, ( )ts , from one place to another via a communication channel. So, ideally we would receive the same signal, ( )ts , 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 ( ) ( ) ( )[ ]1,..., mtxtxt −=x , 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 ( ) 1±=ts as:

( ){ }12 =∈=+ tsRP x

( ){ }12 −=∈=− tsRP x The task of the equalizer is to decide whether an observation ( )tx represents a noise corrupted version of an element in either +P or −P , and therefore determine the input signal ( )ts . 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.

Page 48: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

48

−3 −2 −1 0 1 2 3−3

−2

−1

0

1

2

3

x(t−

1)

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

−3 −2 −1 0 1 2 3−3

−2

−1

0

1

2

3

x(t)

x(t−

1)

Nonminimum Phase Channel − H(z)=0.5+z−1

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):

−20

2−2

0

2

−1

0

1

x(t)

Optimal Decision Surface

x(t−1)−2

02

−2

0

2

−1

0

1

x(t)

Threshold = 0

x(t−1)

−20

2−2

0

2

−1

0

1

x(t)

Decision Surface after Thresholding

x(t−1)−2 0 2

−3

−2

−1

0

1

2

3

x(t)

x(t−

1)

Optimal Decision Boundary

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 ( )ts (we use a Bernoulli sequence of ±1) into the non minimal phase impulse response function defined by

( ) 15.0 −+= zzH

Page 49: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

49

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

100 200 300 400 500−3

−2

−1

0

1

2

3Original Signals

100 200 300 400 500−3

−2

−1

0

1

2

3Ideally Received Signals (Noise Free)

100 200 300 400 500−3

−2

−1

0

1

2

3Noise

100 200 300 400 500−3

−2

−1

0

1

2

3Actually Received Signals (SNR = 20)

Figure 70: Training data set - SNR = 20

100 200 300 400 500−3

−2

−1

0

1

2

3Original Signals

100 200 300 400 500−3

−2

−1

0

1

2

3Ideally Received Signals (Noise Free)

100 200 300 400 500−3

−2

−1

0

1

2

3Noise

100 200 300 400 500−3

−2

−1

0

1

2

3Actually Received Signals (SNR = 3)

Figure 71: Training data set - SNR ≈ 3

FiguresFigure 72Figure 73 show the distribution and density for the above training data.

−1 0 1

−1

0

1

Training Data Distribution

x(t)

x(t−

1)

−20

2−2

0

2

0

0.5

1

x(t)

Training Data Density

x(t−1)−2 0 2

−3

−2

−1

0

1

2

3

x(t)

x(t−

1)

Density Contours

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

Page 50: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

50

−2 0 2

−2

0

2

Training Data Distribution

x(t)

x(t−

1)

−20

2−2

0

2

0

0.5

1

x(t)

Training Data Density

x(t−1)−2 0 2

−3

−2

−1

0

1

2

3

x(t)

x(t−

1)

Density Contours

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.

−10

1−1

0

1

−1

0

1

x(t)

ANFIS Surface: 4 Rules

x(t−1)−1

01−1

0

1

−1

0

1

x(t)

Threshold = 0

x(t−1)

−10

1−1

0

1

−1

0

1

x(t)

Decision Surface after Thresholding

x(t−1)−1 0 1

−1.5

−1

−0.5

0

0.5

1

1.5

x(t)

x(t−

1)

Decision Boundary

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

−20

2−2

0

2

−1

0

1

x(t)

ANFIS Surface: 4 Rules

x(t−1) −20

2−2

0

2

−1

0

1

x(t)

Threshold = 0

x(t−1)

−20

2−2

0

2

−1

0

1

x(t)

Decision Surface after Thresholding

x(t−1)−2 0 2

−3

−2

−1

0

1

2

3

x(t)

x(t−

1)

Decision Boundary

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

Page 51: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

51

−10

1−1

0

1

−1

0

1

x(t)

ANFIS Surface: 9 Rules

x(t−1)−1

01−1

0

1

−1

0

1

x(t)

Threshold = 0

x(t−1)

−10

1−1

0

1

−1

0

1

x(t)

Decision Surface after Thresholding

x(t−1)−1 0 1

−1.5

−1

−0.5

0

0.5

1

1.5

x(t)

x(t−

1)

Decision Boundary

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

−20

2−2

0

2

−1

0

1

x(t)

ANFIS Surface: 9 Rules

x(t−1) −20

2−2

0

2

−1

0

1

x(t)

Threshold = 0

x(t−1)

−20

2−2

0

2

−1

0

1

x(t)

Decision Surface after Thresholding

x(t−1)−2 0 2

−3

−2

−1

0

1

2

3

x(t)

x(t−

1)

Decision Boundary

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)

Page 52: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

52

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.

Page 53: neuro fuzzy control2 - University of Iceland · 1 NEURO-FUZZY CONTROL J. Lilja Pálsdóttir Poul Kristian Möhl Alfonso Martínez del Hoyo Canterla Soft Computing, 2005 University

53

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 Boiler-

Turbine 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.