Final Project Report for Artificial Intelligence Course

Design of a Fuzzy Logic Controller using GA's


       The difference between Science and Fuzzy subjects is that 
                science requires reasoning, while those other subjects 
		merely require scholarship.  --Robert Heinlein     

MOTIVATION OF THIS PROJECT

A control system is an arrangement of physical components designed to alter , to change, or to regulate through a control action ,another physical system so that it exhibits certain desired actions or behaviour. Control systems are of two types : open loop control system , in which the control action is independent of physical system output , and closed loop system (also known as feedback control systems).Example of open-loop control system is a toaster,in which amount of heat is set by a human .Example of a closed loop control system is a room temperature thermometer, which senses a room temperature and activates a heating or cooling unit when a certan temperature threshold is reached.

In a closed loop system a sensor measures a control signal. The physical system under control is called aplant. Certain physical forcing signals (called inputs) are determined by the responses of the systems (called outputs).To obtain satisfactory responses and characteristics for the closed loop control system , it is necessary to connect an additional system ,known as a controller , or a compensator , into the loop

In my project of designing a fuzzy logic controller , the object is to maintain physical variables (position and velocity of an inverted pendulum ) within a certain limit. It will try to follow or track some function . The plant is the simplified version of inverted pendulum . The differential equation describing the system:

           2          2
    m.l.l.d (theta)/dt +(m.l.g) sin(theta)=u(t)
    where
    m=mass of the pole located at the tip point of Inverted Pendulum
    l=length of the pendulum
    theta=deviation angle from vertical in the clockwise direction
    u(t)=torque applied to the pole in the counterclockwise direction
    t=time
    g=gravitational acceleration constant

You can also see the original proposal for this project.

DESIGN PARAMETERS OF A GENERAL FUZZY LOGIC CONTROLLER

  1. Fuzzification Strategies or Fuzzifier.
  2. Knowledge Base : formation of membership function.
  3. Rule Base - formation of fuzzy associative memory
  4. Decision making Logic
  5. Defuzzification Strategies

In the project I have changed the first three parameters mentioned above by means of a simplified version of Genetic Algorithm.I have not made the membership functions of output variable adaptive because then defuzzification would become complicated.The GA will make the rule base and the knowledge base adaptive.

The equation of the membership function shown in the figure :
                               2 b
              y=1/(1+[((x-c)/a) ] )

So it is seen that every membership function can be expressed by three parameters a,b,c.The blank boxes would be filled in by the consequent part of each if-then rule. The table is to be altered by GA according to the performance of the controller.Position and angular velocity are the two inputs and force is the output for the fuzzy logic controller.


PAST WORK

Previously generation of membership function and FAM table was mainly done either iteratively or by trial and error method or by human experts.A task such as this is a natural candidate for GA.Ga will attempt to create membership functions and FAM that will cause the controller to operate optimally.

Recently, work has been done using GA's to do each of these tasks separately.Karr , for example has used a GA to generate membership function for pH control process and Cart-Pole problem. Such work has shown GA's ability to successfully create the individual parts of a FLC , but since membership function and rule sets are co-dependent,using a hand designed rule set with a Ga designed membership function or a hand designed membership function with a GA designed rule set does not use the GA to its full advantage.Thus the use of GA to determine both membership functions and rule base simultaneously for an optimal and near optimal controller is the main objective of this work.


METHODOLOGY

step1: At first two state variables are defined.In my case , they are angular position and angular velocity (degrees and dps).

                       x1=theta
	               x2=d(theta)/dt  

step2: Then two state equations are written.In my case they are:

               dx1/dt=x2;
	       dx2/dt=(g/l)*sin(x1)-(1/m.l.l)u(t)
Here certain assumptions have been made like :
               l=g
               m=180/(3.14.g.g)
Now the matrix Difference equations become ,
               x1(k+1)=[x1(k)+x2(k)]*sampling interval
	       x2(k+1)=[x1(k)+x2(k)-u(k)]*sampling interval
	       k=one sampling instant
	       k+1=next sampling instant

step3 : Different individuals of the first generation are formed with the help of C Library function RANDOM().They are represented by binary chromozome. Each individual consists of parameters for the membership function (a,b,c) and consequent part of each rule.Each of the membership function parameters is represented by 4 bits. there are 8 possible consequent parts ( e.g NB,N,Z etc). They are represented by 3 bits. So each chromozome consists of 51 alleles. Each generation has 100 individuals.

step 4: Next, decoding is done for each parameter in the chromozome.In this simplest form of GA I have specified the search space for each parameter. (amax,amin etc).The decoding of membership function parameter is done by:

    Ci=Cmin+{(b/(pow(2.L)-1))*(Cmaxi-Cmini)}
    b=decimal equvalent of a binary number
    Cmax and Cmin define the search range.
    L= length of the string
For rule consequents only b is found out.Each integer represents one consequent in a rule. (e.g 0 represents HNB, 1 represents Nb etc).

step5: The input and output spaces are fuzzified .

step6: Nine rules ,representing control actions are entered into the FAM table

step7:Ten initial combination of values of velocity and position are taken to test the performance of the controller for each individual.

step8 : Now for each individual with each initial value simulation of the control problem is done for 10 iterations.

step9 : Firing strength of each rule is determined.

step10:Defuzzification is done by height method.Each iteration gives one value position and angular velocity.

step11: Initially all the individuals were given a point zero. If after each iteration if the position and velocity is not lying within the specified range (+-2 d or +-5 dps) the point of the individul is deducted by ther sum of squared difference (SSD).So the aim of the ga is to reduce the SSD.

          SSD=sqrt([(mod(theta))-2]**2+[(mod(d(theta)/dt))-5]**2)

step 12: Finally we get the point of each individual . We sort them according to their points. The first 50 individuals are only allowed to reproduce. The best individual is duplicated thrice and inherited to the next generation.

step13 : The rest of the individuals in the next generation are formed by recombinations. I have chosen two individuals randomly.The probablity of recombination is seventy percent.I have filled 70 bits of a 100 bit register by 1. With the help of this register and C library function random(), I have determined whether mating would be possible between two randomly chosen individuals or not.If mating is possible I have randomly chosen the position of recombination .I have done single point recombination. Here parent1 and parent2 produce child1 and child2.

Recombination is done by Monte-Carlo method

step 14:similarly mutation is done.The probablity of mutation is 3%.

step 15:Finally the motion of the pendulum is shown by the graphics Xdraw.


RESULTS

if you want to see how the average fitness improved click here

if you want to see how the minimum fitness improved click here

Here is different angular positions and velocity for INVERTED PENDULUM click here

THE FINAL FAM TABLE IS :

\ P Z N
P HNB HNB HPB
Z HNB HNB NM
N NM NM HPB
  
       angular position horizontal 
       angular velocity vertical


CONCLUTIONS

  1. Now the FLC shows superior performance because it is adaptive in nature and it is able to realize different control laws for each input state.
  2. It is not sensitive to model change that occurs with parameter variation.
  3. It shows good performance when the initial position and velocity are within the specified range (+-2 d or _+5 dps). But its performance is poor when it is outside the range.This is because I have used simplest version of GA.So the performance is not fully satisfactory but encouraging .
  4. The problem of getting an optimal FLC has reduced considerably.
  5. If we use better versions of GA (like CGA or HDGA ) a considerable improved performance can be obtained from the controller
  6. here I could not study the stability of the FLC due to shortage of time. But this is an important point to study because previous FLCs had stability problems. In fact , I guess that this controller also has a poor stability .Because sometimes it is showing wild swings.Sometimes it is moving in small steps and sometimes with large steps.This problem can be reduced by optimizing the stability parameters by GA.It is also seen that the relation between position and velocity is not like an normal pendulum.It is just keeping itself within the specified range.But it can be clearly concluded that I have got a good enough solution , may not be an optimum one .

FOR FUTURE WORK

  1. Real time implementation can be done by a high speed microcontroller (such as INTEL 80C961) or digital signal processor (such as Texas Instruments TMS320C25).(They can incorporate control software. Recently, user-freindly software and hardware tools have been developed for fast development of control codes. For example , Togai Infralogic .INC has developed Fuzzy Expert system development shell (TILLSHELL) ,where fuzzy rules and membership function can be written in user-freindly Fuzzy Program Language (FPL). Dedicated hardware type programmable fuzzy controllers are also available.)
  2. Stability analysis can be done.
  3. Improved GA techniques ( e.g . CGA,HDGA ) can be implemented.
  4. A Neuro-fuzzy controller can be made where a neural network can perform the operation of Sugeno -fuzzy model or a Tsukamoto-fuzzy model and learning would be done by GA's.


BIBLOGRAPHY

  1. L.A.Zadeh,"Outline of the new approach to the analysis of system and decision parameters " IEEE Transaction System ,man and Cybernatics . vol . 7 . pp. 1-13 ,1973.
  2. E.H.Mamdani and Asillian , " An experiment with linguistic synthesis with a fuzzy logic controller , " pp 28-44 ,1975
  3. R.M.Tong , " A control Engineering review of fuzzy systems ",Automatica,vol 13 pp. 559-669 , 1977.
  4. Y.F.Li and C.C.Lau , " Design of fuzzy algorithm in control system " IEEE Control system Magazine , April 1989 .
  5. L.E.B.Silva , G.E.April and G.Oliver "Real time fuzzy adaptive controller for an asymmetrical four quadrant power controller " IEEE IAS Ann Meeting pp 872-878 ,1987 .
  6. R.M.tong , " An annoted biblography of fuzzy control " Industrial application of Fuzzy Control , M.sugeno ,1985 .
  7. K.l.Tong , R.j.Mullohand , " Comparing fuzzy logic with classical controller design " IEEE trans. on Syst . man. and Cybernatics vol .SMC 17 Nov-Dec 1987.
  8. J.A.Bernard. "Use of a rule based system for Fuzzy Control ", IEEE control System Magazine pp. 3-12 Oct. 1988 .
  9. C.W.Xu , "Analysis of feedforward /feedback control on Fuzzy relational system " Fuzzy Sets and system vol .35 pp. 105-113 1990 .
  10. C.C.Lee , "Fuzzy logic in control system : fuzzy logic Controller Part 1 " , IEEE trans on Syst.man and Cybernatics vol .20 Mar/April 1990 .
  11. Y.Dote , B.K.Bose " Fuzzy CAD for variable structure PID controller " IEEE IECON pp 829-838. 1989
  12. K.Hirota "Fuzzy control and its industrial control in Japan " pp. 826-827 , 1990 .
  13. Y.Dote ,"Fuzzy and Neural network controller " IEEE IECON pp. 1314-1343 , 1990 .
  14. G.C.D.Sousa and B.K.Bose "A Fuzzy set theory control of d.c machine drive "IEEE trans. on ind.appl. vol 30 pp-34-44 Jan-Feb '94.
  15. T.Takagi and M.Sugeno , "Fuzzy midentification of systems and its application to modelling and control " IEEE trans on man.syst and cybernatics '85.
  16. Y.Dote "Neuro-Fuzzy robust controllers for drive saystem " IEEE.trans on Ind.Etc pp229-242 '92
  17. Homaifer,McCormic , "Simultaneous design of mmembership functions and rule sets for Fuzzy controllers using GA's "IEEE trans on Fuzzy systems , vol.3,no.2, MAY '95.
  18. Jang, "Anfis" ,IEEE trans.on syst,man and cyber. vol 23 no .3 May/June '93.
  19. Kim,Zeigler , "Designing of a flc using a multiresolution paradigm ,IEEE trans on Fuzzy systems ,'96
  20. G.J.Goldberg , "Computer implementation of a Genetic Algorithm " (book)
  21. B.K.BOSE , " Expert Systems , Fuzzy logic and Neural Network Application in Power Electronics and motion control " , proc. of IEEE,vol.8 ,no.8 , Aug 1994
  22. T.J.Ross , "Fuzzy logic and its engineering application " (book)
HERE YOU CAN GET 20 HYPERLINKS ON WEBSITES.

File source

  1. here is source code
  2. If you want to see the motion of the inverted pendulum please go to directory /c0/achak .Give two commands make and Xdraw.Then press at Draw.
  3. If you want to see the membership functions please go to subdir: project. Call Gnuplot. Give commands load 'exp.gif' or 'exp1.gif'.They will show the membership functions for angular position and velocity.