Mixing Fuzzy, Neural and Genetic Algorithms in an ... - Semantic Scholar

3 downloads 0 Views 261KB Size Report
marcello@polimage.polito.it [email protected] fbeatrice, [email protected]. 1 Introduction. 1 In the last years fuzzy logic has gained the inter- est of a ...
Mixing Fuzzy, Neural and Genetic Algorithms in an Integrated Design Environment for Intelligent Controllers M. Chiaberge, G. Di Bene , S. Di Pascoli, B. Lazzerini, A. Maggiore, L.M. Reyneri

Dip. Elettronica Politecnico di Torino C.so Duca degli Abruzzi, 24 10129 Torino - Italy 

[email protected]

1 Introduction

I.S.E. Ingegneria Sistemi Elettronici s.r.l. Via Nuova, 128 56010 Vecchiano (PI) - Italy 

[email protected]

1 In the last years fuzzy logic has gained the interest of a growing part of the scienti c community, due to some interesting properties which characterize it as against other kinds of Arti cial Intelligence paradigms. In our view the most interesting properties of fuzzy logic are: a) its similarity with the human reasoning; b) its implicit robustness, coming from the fact that it directly expresses input/output relationships, with no need for or physical derivation of the rules; c) its relatively small computational complexity, which makes it particularly suitable for real-time applications. The strength of fuzzy logic comes from the fact that it can mix linguistic rules with eld-acquired data and, under given conditions, there are no limits to the kind of control surfaces which can be implemented [1]. This permits a convenient application of fuzzy logic in those control systems where the plant to be controlled shows lack of linearity, and in particular whenever there is a consistent amount of human expertise (often coming from the experience) about the way the system has to be controlled. This expertise can be converted into rules which de ne the optimal control surface for the plant. Once a rst model of a Fuzzy Controller (FC) has been de ned, it is necessary to set its parameters in order to obtain the desired performance. This can be done in several ways, and optimization techniques like Simulated Annealing, Weight Perturbation, or Genetic Algorithms [2, 3] can be used. 1 This work has been partially supported by the EEC MEPI initiative DIM-109, Neural Network Chip for Embedded Real-Time Intelligent Control, and the ASI contracts 249/3-4 Neural Network Architectures for Control of Flexible Arms



Dip. Ingegneria Informazione Universita di Pisa Via Diotisalvi, 2 56126 Pisa - Italy

fbeatrice, [email protected]

Unfortunately, FCs are not so easy to implement in analog hardware, in particular if compared with Arti cial Neural Networks (ANNs). ANNs can be implemented in hardware by means of ad-hoc VLSI devices, with the advantage of obtaining both high computing power and some degree of fault tolerance [10]. On the other hand, ANNs are slow and dicult to train, and their training requires the knowledge of the partial derivatives of the outputs relative to the inputs, which in general are not known. It is shown in this paper (Sect. 5) that FCs and ANNs can be seen as particular cases of Weighted Radial Basis Functions (WRBFs) [4]. By means of the WRBF paradigm it is possible to translate an FC into an ANN and viceversa; the former case applies in general to the hardware implementation of a set of fuzzy rules, while the latter can be used to make evident the inner working of a Neural Network by translating it into a series of linguistic rules. In this paper the concept of Hierarchical Hybrid Fuzzy Controllers (HHFCs) will be introduced. By means of HHFCs, the development of Neuro-Fuzzy controllers for complex plants can be simpli ed, just by dividing the controller into blocks, each of which solves a particular subset of control tasks.

2 Fuzzy Controllers Fuzzy logic provides a feasible solution for controlling complex systems that cannot be analyzed with traditional quantitative techniques. Indeed, the control actions performed by an FC are established by means of a collection of fuzzy control rules which express a qualitative dependence of the control variables Y~ on the state variables X~ . A fuzzy rule xes the actions that must be performed if some conditions for the input variables are

satis ed. Such conditions are expressed in terms of the membership degree of the input variables to the appropriate fuzzy sets. Indeed, the domain of each state variable is roughly \quantized" in such a way that each level corresponds to a fuzzy set. A fuzzy set is characterized by a function, called membership function, which takes values in the interval [0,1]. The form of the adopted fuzzy rules is the following (other de nitions are possible [5]):

Rk : IF (x1 is Ak1 ), . . . (xn is Akn ) THEN Y~ = F k (: : :)

(1)

where Ak1 ; : : : ; Akn are the fuzzy sets which appear in the k-th rule Rk , while F k (: : :) is the control function associated with rule Rk . The function F k (: : :) may be a function of either state variables xi , or the outputs of other control blocks. Given the value of the state variables, the ring strength of each fuzzy rule is

sk = minfA1 (x1 ); A2 (x2 );    ; A (xn )g (2) k

k

k n

where A () is the membership function of the fuzzy set Aki . Finally, the value to be assigned to the output variable is calculated as the weighted average of the values F k with ring strengths sk as weights. Fuzzy controllers are powerful because they allow to express a control strategy in a linguistic way. Indeed, each fuzzy set is represented by a label such as positive, negative, and so on. The crucial point is the de nition of membership functions which appropriately represent such fuzzy sets. An optimization process is usually needed to tune membership functions so that the FC implements the desired transfer function. Moreover, when the number of state variables is high, the number of fuzzy rules is often unmanageable. The hierarchical approach proposed in this paper can be adopted to handle these complex situations. k i

3 Arti cial Neural Networks An ANN consists of many processing elements called neurons joined together by connecting the outputs of a neuron to the inputs of other neurons through weighting elements called synapses [6]. The output of a neuron is computed as the weighted summation of the inputs, passed through a nonlinear activation function:

X yj = F j + xi wij i

!

(3)

where wij and j are the synaptic weights and a threshold [6], respectively. Neurons are often organized into groups called layers. Typically, a neural network undertakes a preliminary learning phase and a successive recall phase. Learning consists in adapting or modifying the synaptic weights wij of the network in response to a training set of sample inputs and the corresponding desired outputs. ANNs present some major advantages. First, adaptation allows ANNs to operate well even if the environment or the system being controlled vary dynamically. Second, ANNs degrade gracefully in presence of faults [6]. As information is distributed throughout the system, the behavior of the network as a whole is only slightly degraded in case some neurons are destroyed, disabled, or their synapses altered. This makes ANNs extremely well-suited to applications where failure of control equipment has catastrophic consequences (for instance, control of nuclear power plants). Several kinds of neural networks can be applied to control problems such as Multi-Layer Perceptrons (MLPs) and Radial Basis Functions (RBFs) [2, 6].

4 Genetic Algorithms A crucial point in the design of a critical control system is the selection of an appropriate optimization algorithm. Genetic Algorithms (GAs) are adaptive methods which may be used to solve search and optimization problems. By mimicking the principles of natural selection, GAs are able to \evolve" solution to real world problems, provided that they have been suitably encoded [3]. GAs are not guaranteed to nd the global optimum solution to a problem, but to nd \acceptably good" solutions in an \acceptably short" time. Where specialized techniques exist for solving particular problems, they are probably better than GAs in both speed and accuracy of the nal results. GAs are suitable in all those applications where no such techniques exist. Furthermore, where existing techniques work well, improvements have been made hybridizing them with a GA. GAs try to evolve a set of (IF ... THEN) rules to deal with some particular situations. The most important use of these techniques has been in the eld of adaptive control. In large or complex systems there may be many control parameters to be adjusted to keep the system running in an optimal way. The tness of a set of rules may be de ned to classify their performance on a real system, or on

Figure 1: Encoding PID parameters for GAs a computer model. In general, the system being evolved is encoded into a long bit string called chromosome. Sites on the chromosome correspond to speci c characteristics of the encoded system and are called genes. Fig. 1 shows a possible encoding of PID controller parameters. The range of variation of each parameter is coded into an 8-bit gene. The result is a 32-bit chromosome. Initially a random set, or population, of these strings is generated. Each string is then evaluated according to a given performance criterion, and assigned a tness score. The strings with the best scores are used in the reproduction phase to produce the next generation. The reproduction of a pair of strings proceeds by copying bits from one i of the two strings until a randomly triggered crossover point, after which bits are copied from the other string. There is also the possibility that a mutation (inversion of the bit) will occur. The cycle of evaluation and reproduction continues for a predetermined number of generations, or until an acceptable performance level is achieved.

5 Weighted Functions

Radial

Basis

Control. In particular, since ANNs and FCs are apparently two independent and uncorrelated methods, each one with its own advantages and drawbacks, it is of the utmost importance to be able to mix the two and therefore obtain the best from each one. In particular, by means of a common paradigm, it is possible to de ne a fuzzy controller using linguistic concepts (human-friendly approach) and still be able to tune its performance using backpropagation and other neural algorithms, without loosing the correspondence with the linguistic description; or, viceversa, to extract a linguistic interpretation from an otherwise obscure neural network. In a WRBF network, each neuron j is associated with a pair of vectors, namely a location center C~ j = fcj1; cj2 ; : : : ; cjN g (as for RBFs) and a weight ~ j = fj ; w1j ; w2j ; : : : ; wNj g (as for MLPs). vector W The output Y~ of the network is a function of the input vector X~ :

! N X 1 j j j j y = F  + N Dn (xi , ci )  wi i=1

(4)

8 < (xi , cji ) for n = 0  j Dn (xi , ci ) = : jxi , cji jn for n > 0

(5)

which is the characteristic of a Weighted Radial Basis Function of order n. F (z ) is one of several possible monotonic activation functions such as, for instance, sigmoidal, exponential, or linear, while the factor Dn (xi , cji ) is a function of the distance between the i-th components of the input vector X~ and the location center C~j , namely:

6 Intelligent Controllers Although the above mentioned paradigms can sometimes be used interchangeably, in general such paradigms are complementary rather than competitive. For this reason, it can be advantageous to use them in combination rather than exclusively. A Hybrid Intelligent Controller (HIC) can be designed by combining one or more of the above mentioned paradigms, in a large variety of possibilities, as shown in Fig. 2 . The designer of an HIC can choose among several paradigms according both to system requirements and to what form of knowledge he has about the plant. Anyway, some general considerations can be drawn to help a designer choose the best paradigm.

Although apparently the FC and ANN methods mentioned in Sects. 2 and 3 are very di erent from each other, they can be uni ed by the WRBF paradigm [4]. Di erent neural paradigms, such as RBF and MLP networks, as well as Linear Controllers (LCs) can be seen as special cases of WRBFs. Also FCs can be approximated by an appropriate WRBF with one neuron per each fuzzy rule, provided that the location centers and the weight vectors are set equal to the center and the standard deviation, respectively, of the membership functions of the an- 6.1 Neuro-Fuzzy Paradigms tecedents, as described in [4]. Several are the advantages of having a uni ed Neural networks theory combined with fuzzy logic paradigm, in particular in the eld of Intelligent can be employed to design intelligent systems that

can exploit the tolerance for imprecision and uncertainty, learn from experience, and adapt to changes in the operating conditions. Although fuzzy logic can encode expert knowledge in a direct and easy way using rules with linguistic labels, it often takes a lot of time to design and tune the membership functions which quantitatively de ne these linguistic labels. Wrong membership functions can lead to poor controller performance and possibly to instability [2, 5]. Learning techniques can be used to design membership functions automatically, thus reducing development time and cost while improving performance. In other cases, plants can easily be linearized in the neighborhood of a few operating points, and for each of them it is possible to develop a simple linear controller. Since the transition from one operational state to the other is not abrupt, a possible solution can be a linear and fuzzy mixed approach, where the fuzzy inference system merges the di erent linear controllers. However, although the neuro-fuzzy approach provides good performance for nonlinear controllers, it Figure 2: Examples of di erent control stratecannot always satisfy all the requirements of a real gies: a) Neuro-Fuzzy; b) o -line neural; c) onplant. Indeed, in some applications the plant has line neural; d) inverse control. a number of well-de ned states, in which the static and dynamic characteristics of the plant may di er. better than the reference. Consider, for instance, the forward and backward steps of autonomous walking machines, or the op Passive Learning Neural Controllers timal trajectory of a manipulator with two largely which learn directly from the plant, by on-line di erent load conditions. In such cases, the chominimization of an appropriate cost function sen control strategy must be integrated with a Fi(often the square sum of errors). This methodnite State Automaton to keep track of the di erent ology does not require a reference controller plant states and vary accordingly some controller and can therefore provide better performance. characteristics (e.g., synaptic weights, fuzzy inferThe main drawback is that it behaves more ence rules). as an adaptive than as a learning controller, since it may su er from over tting around the actual trajectories in the state space [7]. 6.2 Approaches to Hybrid Intelligent Control  Active Learning Neural Controllers, which learn directly from the plant, like pasSeveral approaches to Hybrid Intelligent Control sive learning controllers do. The di erence is have been proposed in literature [7]. Some are that the system tries to learn also from unbrie y described in the following: trained regions in the state space, improving  Neuro-Fuzzy Controllers, which are dethe overall performance also for rapidly varyscribed using a human-like language [7], where ing plant conditions or for unforeseen input the uncertainties intrinsic in most plant modconditions [7]. els are handled by the fuzzy set theory. Once a  Inverse Controllers which learn from the fuzzy controller has been de ned, tested (and plant both the direct and the inverse plant tuned), an ANN can be trained thereafter, uncharacteristics [7]. til the desired accuracy has been reached.  Neural Controllers with o -line training, The behavior of these control structures, simple which are trained \by examples", by copying or hybrid, is generally controlled by means of a set from a reference controller, which is used to of parameters, on which a generic optimization algenerate an appropriate training set. An ANN gorithm can act to increase system performance. can be trained with a given accuracy but obviSeveral optimization algorithms can be used, eiously the resulting controller cannot perform ther o -line or on-line, like gradient descent, which

y1

x1

FC 21

FC 31

y2

x2 x3

FC 11

y3

x4 x5

FC 12

y4

x6

FC 32

x7 x8 x9

FC 22

FC 13

y5

y6

HHFC

Figure 3: Architecture of a Hybrid Hierarchical Fuzzy Controller requires the derivatives of the performance index and is prone to the local minima problem, or other methods, such as GAs or Simulated Annealing, which can operate without derivatives and are immune to the local minima problem [8].

6.3 A Hierarchical Approach

An HHFC is a kind of HIC where fuzzy logic supplies the framework inside which di erent control strategies can be combined to solve speci c control problems. Fuzzy logic provides a feasible solution for controlling complex systems. However, if the number of state variables is high, the number of rules in a complete rule set is often unmanageable, as it depends exponentially on the number of state variables [9]. Two kinds of problems arise: i) the diculty for the designer to consider all the variables together, and ii) the computational resources needed by the FC. The size of the rule base can be reduced by organizing the FC hierarchically. A simple hierarchical structure was proposed in [9], where a complex fuzzy controller is organized as a \cascade" of traditional fuzzy controllers. The hierarchical organization of HHFC paradigm di ers from the structure proposed in [9], as it allows a more exible combination of FCs (see Fig. 3). Each FC internal to a given HHFC can produce an arbitrary number of outputs; inputs to FCs can be either state variables xi or outputs from other FCs, or both. Outputs from FCs of any hierarchical level can either coincide with control variables yj or they can be inputs to FCs of any successive hierarchical levels. Practically, any topology is allowed. Moreover, we propose to use IF-THEN-ELSE rules with the following form: IF (x1 is A1 ), . . . , (xn is An ) THEN F = f1 ELSE F = f2

IF (x1 is A1 ), . . . , (xn is An ) THEN F = f1 IF not ((x1 is A1 ); : : : ; (xn is An )) THEN F = f2 IF-THEN-ELSE rules increase the expressive power of fuzzy rules, that is, a linguistic strategy can be more easily translated into rules of this kind. Furthermore, IF-THEN-ELSE rules can be used to choose between two di erent control strategies. Combining these rules with the hierarchical approach, an arbitrary number of control strategies can be generated. Indeed, di erent control strategies may sometimes be necessary to solve a complex control problem. In these cases, fuzzy rules with generic functions as consequents must be considered. We have chosen to use fuzzy rules whose consequent is a WRBF, because WRBF paradigm is able to express LCs, several kinds of neural networks (such as MLP, RBF and, of course, WRBF itself), and FCs. A description language for HHFCs has been de ned. Such language considers HHFCs at di erent abstraction levels, and produces a representation of an HHFC which is suited for optimization by genetic algorithms. At the highest level, an HHFC is considered as a black box with inputs and outputs, and is represented as follows: HHFC name(x1 ; x2 ; : : : ; xn ; y1 ; y2 ; : : : ; ym ) (6) where xi and yi are the controller input and output variables, respectively. The internal structure of an HHFC consists of a set of FCs. Each FC is considered from both external and internal points of view. Externally, an FC is characterized by its name, the input variables for the antecedents of the fuzzy rules (fuzzy inputs), and the input variables of the consequents. Multiple outputs can be produced by an FC; for each output (or groups of outputs) a WRBF must be speci ed in the THEN and ELSE branches. From an internal point of view, an FC consists of a set of fuzzy rules. For each fuzzy rule, a collection of fuzzy sets and the parameters of WRBFs must be speci ed. A fuzzy set is represented by the shape and the parameters of its membership function. Therefore, a fuzzy rule is represented by a set of numerical values whose meaning is interpreted according to the FC's external representation. The notation outlined in this section is part of the description language of EL-SIM development environment.

7 Development Environment

The development of new control techniques can be This rule is equivalent to the two following rules: signi cantly improved by the availability of e ective

supporting tools for design and simulation. We have assembled an integrated development environment, called EL-SIM, to simulate, test and evaluate a large number of hybrid solutions to control problems. EL-SIM provides the user with a collection of blocks which simulate the di erent parts of a system, such as controllers, plant emulators, optimizers, signal generators, signal analyzers and driver blocks for hardware devices. An EL-SIM block is characterized by its input/output characteristic Y~ = F (X~ ), which is the function computed by the block to produce the output signals, given the input signals. Signals exchanged among blocks can either be scalars, vectors, or matrices of either integer, boolean or real values, or any combination thereof. Blocks may also be parametric. Parameters have been implemented as slowly varying input signals, which can in turn be generated by other blocks, such as learning blocks, or be constant. EL-SIM has been designed to be a development environment for HICs, so it provides blocks implementing the previously described control and optimization strategies. Hybrid control paradigms can be implemented by connecting, in a suitable manner, blocks representing di erent control strategies. The inter-block interface has been expressly designed to allow an easy integration of both built-in and user-de ned blocks. The user develops his own project by selecting and con guring blocks from libraries. Blocks are then connected to each other, and the complete system can be simulated or tested on the real plant. Moreover, after a system or a subsystem has been designed, it can be added to the library to be reused in future applications. The con guration process is driven by an editor which asks the user the parameters required by each element, and the connections among the selected blocks. The consistency of the desired con guration is tested by a connection inspector, which analyses the inter-block connections and warns the user when a problem is found. Moreover, EL-SIM accepts a textual description of HHFCs based on the syntax previously mentioned. Once the structure of a control system has been de ned, it can be simulated by EL-SIM. The simulation process is time-discrete (and not event-driven) as all blocks update their output signals \simultaneously" at regular intervals. EL-SIM provides driver blocks to interface with external devices and real plants, through analog/digital acquisition boards. In particular, driver blocks can be used to introduce the real plant in the optimization loop. In such way, the nal optimization of the controller can be done by acting directly

Figure 4: Photograph of the Adrian robot. on the real plant. Moreover, a software controller can be used as the actual controller. EL-SIM can also be used to teach or optimize a hardware controller. In particular, we have developed a hardware implementation of an Intelligent Controller, oriented to real-time control applications, which consists of an intelligent control board called CINTIA [10]. Control solutions designed and tested by means of EL-SIM can be mapped on the CINTIA chip/board to operate either in conjunction with the development environment or stand-alone. EL-SIM has been written in C/C++ language. Graphics and interfacing with data acquisition boards and external hardware use the c libraries. LabWindows

8 An Application Example An application which we have used to test the effectiveness of our approach is the bidimensional inverted pendulum in polar coordinates, which consists of a pole, with a mass on top, suspended by a spherical joint on a moving base. This is the natural extension of the well-known unidimensional inverted pendulum. We have built a prototype of the system (called Adrian), shown in Fig. 4. The base is provided with two wheels, connected to electrical motors, which can therefore apply a known force to the base. The stability of the base is assured by two low friction pivots. The base can therefore move to and fro, or turn around the vertical axis, but can never slide sideways. It is important to point out that the control of this simple system can be challenging because, when the pendulum tends to fall perpendicularly to the current base heading direction, the base has to

rotate before being able to e ectively control the pendulum. The pendulum is suspended on the base using a joystick, which provides position information to the controller, in the form of two angular coordinates, x and y , and their derivatives, _x , _y , respectively. The controller consists of a neural preprocessor, which converts the raw data from the plant, namely angles x and y , into the data needed by the subsequent HHFC, which then generates control information in the form of force and torque to be applied to the base. A Hybrid Intelligent Controller for the force is developed through a hierarchical approach based upon heuristic reasoning. At the bottom level, we will distinguish between two cases: i) the pendulum falls ahead or behind; ii) the pendulum falls to the left or the right, with respect to the current base heading. This two cases can be distinguished from the value of the azimuth angle between the projection of the pendulum on the ground and the current base heading direction. In the rst case, which can be considered less critical, pole balancing is possible by applying to the base a force in the same direction as the falling pendulum. This is achieved by means of a PseudoPID controller: PPID = Kc() + Kp (; _x ) + Kd(; _x )_x (7) which is a PID with the bias (Kc ), proportional (Kp ) and derivative (Kd) coecients which depend on the input variables  and _x generated by the neural preprocessor. This Pseudo-PID controller is implemented by an FC: Z (; _x ) := f IF ( is positive), (_x is positive) THEN Z = PID1 (; _x ) IF ( is positive), (_x is negative) THEN Z = PID2 (; _x ) (8) IF ( is negative), (_x is positive) THEN Z = PID3 (; _x ) IF ( is negative), (_x is negative) THEN Z = PID4 (; _x )

g

where PIDn are traditional PIDs and di er for the parameters, while positive and negative are sigmoidal membership functions. At the same time, it is also possible to add a force which tends to reduce the base speed (which is a secondary goal of the control action). Therefore, the total force FT applied to the base can be written as: FT = Z (; _x) , Fb ( )v (9) in which v denotes the scalar base speed and Fb ( )v is the additional force.

Instead, when the pendulum falls in a direction almost orthogonal to the current base heading (\severe" case), the applied force sign is reversed while the speed correction force is not applied. This control action tends to rotate the pendulum closer to the current heading direction, where it can be then better controlled. These two opposite control strategies are combined together by the top level FC, based on :

F (; ;_ ; v) := f IF ( is zero) THEN F = Z (; _x) + KA  v ELSE F = ,KZ  Z (; _x )

g

where Z is given by (8), while KA and KZ are suitable constants. A similar hybrid controller evaluates the control torque M ( ; _ ). Finally, the force F and the torque M are combined to obtain the individual forces to be applied to the wheels. The overall controller behavior depends on the values of several parameters, which have been optimized with both simulated annealing and other optimization algorithms.

References

[1] L. Wang, J.M. Mendel, \Fuzzy Basis Functions, Universal Approximation, and Orthogonal LeastSquares Learning", Trans. on Neural Networks, Vol. 3, No. 5, Sept. 1992, pp. 807-814. [2] P.D. Wasserman, \Advanced Methods in Neural Computing", Van Nostrand Reinhold, New York, 1993. [3] L. Davis, \Handbook of Genetic Algorithms", Van Nostrand Reinhold, new York, 1991. [4] L.M. Reyneri, \Weighted Radial Basis Functions for Improved Pattern Recognition and Signal Processing", Neural Processing Letters, Vol. 2, No. 3, May 1995, pp. 2-6. [5] L. Wang, \Adaptive Fuzzy Systems and Control", Prentice Hall, Englewood Cli s, New Jersey, 1994. [6] S. Haykin, \Neural Networks: A Comprehensive Foundation", Mc Millan College Publishing Company, New York, 1994. [7] D.A. White and D.A. Sofge, \Handbook of Intelligent Control", Van Nostrand Reinhold, New York, 1992. [8] M. Chiaberge, J.J. Merelo, L.M. Reyneri, A. Prieto, L. Zocca, \A Comparison of Neural Networks, Linear Controllers, Genetic Algorithms and Simulated Annealing for Real Time Control", in Proc. of ESANN 94, European Symposium on Arti cial Neural Networks, Brussels (B), April, 1994.

[9] G.V. Raju, J. Zhou, R.A. Kisner, \Hierarchical Fuzzy Control", in Int'l Journal on Control, Taylor & Francis Ltd, Vol. 54, No. 5, 1991, pp. 1201-1216. [10] L.M. Reyneri, M. Chiaberge, \CINTIA: A NeuroFuzzy Real Time Controller for Low Power Embedded Systems", in IEEE MICRO, June 1995, pp. 40-47.