7
ISSN: 2277-4629 (Online) | ISSN: 2250-1827 (Print) CPMR-IJT Vol. 2, No. 2, December 2012 www.cpmr.org.in CPMR-IJT: International Journal of Technology 27 Design of Fuzzy Logic Controllers with Genetic Algorithms through Artificial Neural Networks for Controls Dr. Deepak Choudhary* Prof. Rakesh Kumar** Dr. Umesh Sehgal*** ABSTRACT This paper focuses on the Genetic Algorithm learning paradigm applied to train the ANNs for balancing the cart-pole balancing system. The studied system is a control problem namely “cart-pole” problem. We will apply the unconventional techniques Artificial Neural Network, Genetic Algorithm and Fuzzy Logic to a classic control problem “cart-pole”. In this paper we have tried to train the Artificial Neural Network (ANN) with using Genetic Algorithms (program is written in MATLAB) which is compared with the output obtained using the Artificial Neural Network Toolbox provided in MATLAB. In proposed approach we have used both ANNs and Genetic Algorithm to get more optimal solution. Here we applied the approach for the Fuzzy logic technique to design a Fuzzy Logic Controllers (FLC) using ANNs and Genetic Algorithm (GA). The Fuzzy rules which are needed to control the problem will be framed with the combination of Artificial Neural Networks and Genetic Algorithm. It has been found that such a searching technique converges intelligently and much faster than conventional learning means. Performance of the presented neural network training using the genetic algorithms is much better and providing more accurate results. Keywords: Artificial Neural Network, Genetic Algorithm, Fuzzy Logic Controllers. I. INTRODUCTION The control of a cart-pole system is widely used as a benchmark problem for testing the efficiency of reinforcement learning algorithms [8]. Artificial Neural Networks can be trained to simulate the execution of the rule base of the Fuzzy Logic Controllers (FLC) using Genetic Algorithms(GA) for determining the solution of the cart-pole problem (program is written in MATLAB).The genetic design approach discussed in this paper offers a convenient and complete way to design a fuzzy controller in the shortest time. We are expecting better solution in terms of number of iterations, performance of the presented neural network training * Associate Professor, ECE Department, Galgotia’s University, UP, India **Director, K.P.Jain Engg. College, Ghaziabad, UP, India ***Asst Prof., CSE Department, Arni University, Himachal Pradesh, India

Design of Fuzzy Logic Controllers with Genetic Algorithms

  • Upload
    cpmr

  • View
    42

  • Download
    0

Embed Size (px)

DESCRIPTION

http://www.cpmr.org.in CPMR-IJT: International Journal of Technology. e-ISSN:2277-4629; p-ISSN:2250-1827.Vol. 2, Issue 2, Dec. 2012.http://cpmr.org.in/CPMR-IJT_vol2_issue2.aspx

Citation preview

Page 1: Design of Fuzzy Logic Controllers with Genetic Algorithms

ISSN: 2277-4629 (Online) | ISSN: 2250-1827 (Print) CPMR-IJT Vol. 2, No. 2, December 2012

www.cpmr.org.in CPMR-IJT: International Journal of Technology 27

Design of Fuzzy Logic Controllers with GeneticAlgorithms through Artificial Neural

Networks for Controls

Dr. Deepak Choudhary* Prof. Rakesh Kumar**

Dr. Umesh Sehgal***

ABSTRACTThis paper focuses on the Genetic Algorithm learningparadigm applied to train the ANNs for balancingthe cart-pole balancing system. The studied systemis a control problem namely “cart-pole” problem.We will apply the unconventional techniquesArtificial Neural Network, Genetic Algorithm andFuzzy Logic to a classic control problem “cart-pole”.In this paper we have tried to train the ArtificialNeural Network (ANN) with using GeneticAlgorithms (program is written in MATLAB) whichis compared with the output obtained using theArtificial Neural Network Toolbox provided inMATLAB. In proposed approach we have used bothANNs and Genetic Algorithm to get more optimalsolution. Here we applied the approach for the Fuzzylogic technique to design a Fuzzy Logic Controllers(FLC) using ANNs and Genetic Algorithm (GA). TheFuzzy rules which are needed to control the problemwill be framed with the combination of ArtificialNeural Networks and Genetic Algorithm. It has been

found that such a searching technique convergesintelligently and much faster than conventionallearning means. Performance of the presentedneural network training using the genetic algorithmsis much better and providing more accurate results.

Keywords: Artificial Neural Network, GeneticAlgorithm, Fuzzy Logic Controllers.

I. INTRODUCTIONThe control of a cart-pole system is widely used as abenchmark problem for testing the efficiency ofreinforcement learning algorithms [8]. Artificial NeuralNetworks can be trained to simulate the execution ofthe rule base of the Fuzzy Logic Controllers (FLC) usingGenetic Algorithms(GA) for determining the solution ofthe cart-pole problem (program is written inMATLAB).The genetic design approach discussed inthis paper offers a convenient and complete way todesign a fuzzy controller in the shortest time. We areexpecting better solution in terms of number of iterations,performance of the presented neural network training

* Associate Professor, ECE Department, Galgotia’s University, UP, India**Director, K.P.Jain Engg. College, Ghaziabad, UP, India***Asst Prof., CSE Department, Arni University, Himachal Pradesh, India

Page 2: Design of Fuzzy Logic Controllers with Genetic Algorithms

ISSN: 2277-4629 (Online) | ISSN: 2250-1827 (Print) CPMR-IJT Vol. 2, No. 2, December 2012

www.cpmr.org.in CPMR-IJT: International Journal of Technology 28

using the genetic algorithms must be much better withmore accurate results. Again in terms of requirement offewer epochs for training the ANN using GA comparingto ANN toolbox provided in MATLAB. We willdescribe two earlier applications of genetic algorithmsto the automatic generation of a fuzzy rule base, andcompare these with the ANN toolbox output to ourapproach. One of the earliest applications of geneticalgorithms to the design of fuzzy systems was developedby Karr (1991), again to solve the cart-pole problem[2].

The production of the fuzzy controller begins withthe definition of the fuzzy sets used to describe eachinput variable. Each of the four input variables arecharacterized by three fuzzysets—NEGATIVE, ZERO,and POSITIVE—yielding 81 possible combinations.The fuzzy system designer then assigns one of sevenchoices for the output to each input combination. Theresulting fuzzy system represents the expert’s “bestguess”. The membership function extrema are thenencoded into a bit string, and a genetic algorithm isapplied to shift the membership functions so as to findlocations which improve performance. The evolvedsystem consistently outperforms the original, beingcapable of recovering from initial positions that fail underthe original rule base.

In second application, Genetic algorithms forautomatic design of fuzzy logic controllers have beendeveloped [9], using sophisticated membership functionsthat intrinsically reflect the nonlinearity encountered inmany engineering applications. But the sophisticationobtained by the machine based automatic design couldnot be reached by manual design which is exclusivelybased on a painstaking trial-and-error process. As thenumber of variables increases the length of the stringencoding the system size increases exponentially, with acorresponding exponential increase in the complexityof the search space. Such a system is unlikely to scalewell for more complex problems.

We are using ANNs and Genetic Algorithm both toget more optimal solution. Here we applied the approachfor the fuzzy logic technique to design a Fuzzy LogicController (FLC) using ANNs and Genetic Algorithm

(GA). The resultant optimal fuzzy logic controller is usedin centring a cart. Artificial Neural Networks can betrained to simulate the execution of the rule base of theFuzzy Logic Controllers (FLC) using Genetic Algorithms.Also the training of artificial neural networks using geneticalgorithms is extended to include a priori controlknowledge of human operators in the form of rule basetable. It is shown that the system can solve moreconcretely a fairly difficult control learning problem. Italso demonstrated the feasibility of the method whenapplied to a cart-pole balancing problem. Theperformance of the GA and ANN Optimized FuzzyLogic controller is compared with that of the conventionalANN toolbox. The MATLAB software forms part ofthe modelling and design tools employed in this paper.Genetic Algorithms (GAs) [3] are heuristicoptimization procedures based on the principles ofnatural evolution. They combine the concepts ofadaptation and survival of the fittest to producesuboptimal solutions for an arbitrary problem

Fig. 1.1: Cart-pole system

This is achieved by means of the repeated applicationof mating and reproduction operators onto a populationrepresenting potential solutions. Neural networks so asfuzzy logic [6] are dealing with important aspects of

Page 3: Design of Fuzzy Logic Controllers with Genetic Algorithms

ISSN: 2277-4629 (Online) | ISSN: 2250-1827 (Print) CPMR-IJT Vol. 2, No. 2, December 2012

www.cpmr.org.in CPMR-IJT: International Journal of Technology 29

knowledge representation, reasoning and learning, butin different approaches with their advantages andweaknesses. Neural networks can learn and classifyinformation from the examples, but it is nearly impossibleto describe knowledge acquired in that way. On theother hand, fuzzy logic which enables approximatereasoning [5] has a structural knowledge representationin the form of fuzzy if-then rules but lacks the adaptabilityto deal with changing external environments.

II. PROBLEM STATEMENTIn this paper we are applying the unconventionaltechniques Artificial Neural Network, Genetic Algorithmand Fuzzy Logic to a classic control problem variouslyreferred to as the “cart-pole”, “broom balancer“,”inverted pendulum”, “stick balancer problem” or“pole balancing” problem. The objective is to controltranslational forces that position a cart at the centre of afinite width track while simultaneously balancing a polehinged on the cart’s top (figure 1.1)[8]. The movementof the cart is restricted to the horizontal axis by a track,and the pole is free to move about the horizontal axis ofthe pivot. The state of the system is defined by four realvalues; the angle of the pole, the angular velocity of thepole, the position of the cart relative to the centre of thetrack and the velocity of the cart. The output of thecontrol system is a forward or backward movement forthe cart as a fixed force. The cart and pole are initiallyplaced at rest at a predetermined position. A simulationsucceeds when sixty seconds of simulated time elapsewithout the cart reaching the end of the track or thepole falling over. For our purposes, we consider a poleangle of 0.26 radians (about 14degrees) the point atwhich the pole “falls over.” Wieland (1991) investigatesthe effect of varying the angle at which a failure occurson the process of evolving a neural network that controlsthe cart-pole system and concludes that increasing thisparameter does not necessarily generate superiorsolutions, and makes training slower [7]. The cart moveseither to the left or right while a pole attached to the cart

is free to fall either in a clockwise or anticlockwisedirection. The objective is to apply horizontal positiveor negative forces to move the cart in order to maintainthe pole in an upright position. The magnitude of theforce F to be applied which depends on the angle è andangular velocity ù is described by fuzzy control rules.The control of a cart-pole system is widely used as abenchmark problem for testing the efficiency ofreinforcement learning algorithms.

III. IMPLEMENTATION ANDSIMULATED DESIGN

Firstly the populations (weight matrix of ANN) areinitialized then we have to convert the weight matrix ofANN to chromosome (string which consists of 49rules).After converting, check the Fuzzy rules andcalculate the fitness value of every individual in thesolution if the best fitness value is found thenreproduction is done by selecting two parents from thepopulation .Then crossover is done between the twoselected parents to generate the children. A two pointcrossover operator is employed in this study. The twopoint Crossover is a genetic operator that selects sub-section from two parent chromosomes and creates anew offspring chromosome. Then the contents of thesub-section from the two parent chromosome areexchanged. By recombining portions of goodindividuals, this process is likely to create even betterindividuals. Then the mutation is done, the bestindividual (the individual with minimum objective value)out of the children generated from the parent is found.The best individual then competes with its parent tosurvive in the next generation [1]. If the best individualis better than its parent, it is accepted as a parent inthe next generation. If the best individual is worse thanits parent then the selection process is inspired andallows a bad move to be selected in the optimizationprocess with a probability.

Page 4: Design of Fuzzy Logic Controllers with Genetic Algorithms

ISSN: 2277-4629 (Online) | ISSN: 2250-1827 (Print) CPMR-IJT Vol. 2, No. 2, December 2012

www.cpmr.org.in CPMR-IJT: International Journal of Technology 30

Fig 1.2: Flowchart of Implementation

Then the chromosome is converted to the weightmatrix of ANN and the new population is used in thenext iterations till the required output found.

A. Fuzzy rule representationTo produce fuzzy rules for a FLC with two inputs angleè & angular velocity ù and single output F. Extension toa higher number of input and output variables isstraightforward. As a first step, divide the domain regionsof è, ù and F into different regions. The number of theregions is application dependent. Let us assume thatwe divide the domain regions for è, ù and F into 7, 7and 7 regions respectively. For each region, we assigna fuzzy membership function. The shape of themembership functions selected is triangular. The linguisticvariables for è, ù and F are NB, NM, NS, ZO, PS,PM and PH respectively.

• NB – Negative Big• NM – Negative Medium• NS – Negative Small• ZO – Zero• PS – Positive Small

• PM – Positive Medium• PB-Positive Big

There are 49 fuzzy rules and the fuzzy rule base canbe formed as a 7x7 table with cells to hold thecorresponding actions (outputs). A fuzzy rule is requiredfor every possible condition that could exist in the physicalsystem. The rules are commonly called production rules,and are of the form: If Error is NB and Change-in-erroris NB Then output is NB If Error is NM and Change-in-error is NB Then output is NM If Error is NS andChange-in-error is NB Then output is PS If Error isZO and Change-in-error is NB Then output is NB IfError is PS and Change-in-error is NB Then output isZO. Although all possible conditions in the physicalsystem seem imposing at first, the incorporation of fuzzyterms into the rules makes their development mucheasier.

B. Chromosome representationNow encode the input and output regions into stringsconsisting of numbers from 0 to 6. The numbers 0 to 6denote each of the possible value (NB, NM, NS, ZO,PS, PM and PB ) that a variable can take.

A coded string of a fuzzy rule may look like:0 0 2 0 0 0 0 1 2 0 1 5 4 5 6 1 3 2 2 4 6 0 1 2 3 4 5 63 4 6 4 4 2 4 5 3 1 5 6 5 2 6 6 6 6 4 4 6

This string is called a chromosome. Each completestring consists of 49 fuzzy rules and has the same inputconditions but different output control signal assignedto it. Therefore, we need only to encode the outputsignal of the fuzzy rule strings into a complete string. Acomplete string may then be reduced to matrix form:

Page 5: Design of Fuzzy Logic Controllers with Genetic Algorithms

ISSN: 2277-4629 (Online) | ISSN: 2250-1827 (Print) CPMR-IJT Vol. 2, No. 2, December 2012

www.cpmr.org.in CPMR-IJT: International Journal of Technology 31

GA initializes randomly a population of completestrings. Each of these strings is then decoded into fuzzyrules and evaluated by a FLC. Each string’s fitness isdefined as the error between the state of the systemand the target set. GA procedures, selection andcrossover then proceed according to the fitness valuesproduced by the FLC for each string.

C. Neural Network ArchitectureDepending upon the dimensions of the input and thetarget vectors, suitable feed forward neural networkarchitecture is selected. Appropriate transfer functionsfor the hidden and output neuron layers are selectedaccording to the problem at hand. The input trainingvector, target vector, error goal and maximumgenerations are also set according to the problem athand.

The standard network architecture for learning theproblem contain 2 input neurons, 49 neurons in thehidden layer and one output neurons shown in the figurebelow.

Fig 1.3: ArchitectureGenetic Algorithm is a general heuristic that can be

used to train an Artificial Neural Network (ANN) i.e.evolve the weights of an ANN.

IV. RESULTSThe fuzzy rule-set focuses 7x7 possible control actionscorresponding to values in input error and change_ in_error and therefore 49 bits are used in a string to form

the look-up table, where a single bit represents eachcontrol action. This is illustrated in Figure 1.4 look-uptable for control actions. The figure 1.4[4] maps twoinputs to a single output as shown in the above figure,for Error =0 and Change_ in_ error=0 the output=0,similarly for Error =0 and Change_ in_ error=2 theoutput=2

The ANN is trained using EvolutionaryAlgorithm for FLC problem. The architectureused is 2-49-1 i.e. two inputs, 49 hidden neuronsand one output neuron.

The ANN was trained for the input and target valuesas shown in the Table 1.1

Fig 1.4: Fuzzy rule-set

Page 6: Design of Fuzzy Logic Controllers with Genetic Algorithms

ISSN: 2277-4629 (Online) | ISSN: 2250-1827 (Print) CPMR-IJT Vol. 2, No. 2, December 2012

www.cpmr.org.in CPMR-IJT: International Journal of Technology 32

V. DISCUSSION OF RESULTSGAs has been proven to be an extremely efficient androbust searching tool for complicated and poorlyunderstood processes. It is also shown in the literaturethat such a searching technique converges intelligentlyand much faster than conventional learning means.Performance of the presented neural network trainingusing the genetic algorithms is better. The proposedmethod in this implementation has the followingadvantages:

Fig 1.5Training errors of ANNs for

FLC Problem using GA

1. The artificial neural network is trained with fuzzyrules rather than standard real features values.

2. The weights of the neural network has beenallocated as same as in artificial neural networksystem i.e. they are real in nature.

In this paper, we are trying to train the ArtificialNeural network with using Genetic Algorithms (programis written in MATLAB) which is compared with theoutput obtained using the Artificial Neural NetworkToolbox provided in MATLAB. Table 1.1 shows thecomparison of the two outputs. First two columns showthe inputs to the ANNs, 3rd column shows the outputobtained from the ANNs trained using GAs and the 4th

column shows the output obtained from the ANNtoolbox provided in MATLAB. The two outputs arecomparable and training of ANNs usung GA is muchfaster as compared to that using the toolbox. Theparameters used for traing the ANNs using the GA aremax_ epoch=10000; err _goal=0.019; epochs =1990generations=5 Mutation probability = 0.01.

Whereas the parameters for training ANNs usingtoolbox are max _epoch=10000; err _ goal=0.0199;epochs =6243. Fig 1.5 shows the decrease in errorwith epochs. The error becomes equal to the error goalin 1990 epochs.

VI. CONCLUSIONGenetic algorithms for training of Artificial NeuralNetworks for fuzzy logic controllers have beendeveloped in this work, using sophisticated membershipfunctions that intrinsically reflect the nonlinearityencountered in many engineering applications. Utilisingthese sophisticated membership functions, the controllaws can be implemented in a simple scheme. Thesophistication obtained by the machine based designcould not be reached by manual design which isexclusively based on a painstaking trial-and-errorprocess. The genetic design approach discussed in thisdissertation offers a convenient and complete way todesign a fuzzy controller in the shortest time.

Fuzzy systems are used to automated design of fuzzylogic controllers; by strengthening fuzzy logic controllers

Page 7: Design of Fuzzy Logic Controllers with Genetic Algorithms

ISSN: 2277-4629 (Online) | ISSN: 2250-1827 (Print) CPMR-IJT Vol. 2, No. 2, December 2012

www.cpmr.org.in CPMR-IJT: International Journal of Technology 33

with genetic algorithms the implementation of optimalfuzzy logic rules and high-performance membershipfunctions will be easier and faster. The resultant optimalfuzzy logic controller is used in cantering a cart.

In this paper we have applied the unconventionaltechniques Artificial Neural Network, Genetic Algorithmand Fuzzy Logic to a classic control problem variouslyreferred to as the “cart-pole”, “inverted pendulum”, or“pole balancing” problem, we found the followingsuperior observations in terms of number of iterations,performance of the presented neural network trainingusing the genetic algorithms is much better and providingmore accurate results. Again we require fewer epochsfort-raining the ANN using GA as compared to ANNtoolbox provided in MATLAB.

VII. REFERENCES

[1] A. P. Wieland, “Evolving Controls for UnstableSystems,” In S.Touretzky et. al. (ed.),Connectionist Models: Proceedings of the 1990Summer School. San Mateo, CA: MorganKaufmann Publishers, Inc., pp. 91-102, 1991.

[2] C. L. Karr, “Design of a Cart-Pole BalancingFuzzy Logic Controller Using a GeneticAlgorithm,” Proceedings of the SPIE Conferenceon the Applications of Artificial Intelligence.Bellingham, WA: SPIE—The InternationalSociety for Optical Engineering, pp. 26-36,1991.

[3] J. H. Holland, “Adaptation in Natural andArtificial Systems,”University of Michigan Press,Ann Arbor, Michigan 1975.

[4] Kim Chwee Ng and Yun Li ,”Design ofSophisticated Fuzzy Logic Controllers UsingGenetic Algorithms,” IEEE World Congress onComputational Intelligence(In Proc. 3rd IEEE Int.Conf. On Fuzzy Systems, Orlando, FL, June,1994, vol.3, pp. 1708-1712.)

[5] L A Zadeh, “The concept of a linguistic variableand its application to approximate reasoning,”Parts 1, 2 & 3, Information Sciences, 1975

[6] L. A. Zadeh, “Fuzzy sets,” Information andControl, vol. 8, pp. 338-353, 1965.

[7] Mark G. Cooper & Jacques J. Vidal, “GeneticDesign of Fuzzy Controllers,” University ofCalifornia, Los Angeles 3531 Boelter Hall LosAngeles, California 90024.

[8] Razvan V. Florian, “Correct equations for thedynamics of the cart-pole system,” Center forCognitive and Neural Studies (Coneural) Str.Saturn 24, 400504 Cluj-Napoca, Romania. July11, 2005; updated February 10, 2007

[9] Sheroz Khan, Salami Femi Abdulazeez, LawalWahab Adetunji, AHM Zahirul Alam, MomohJimoh E. Salami, Shihab Ahmed Hameed, AishaHasan Abdalla and Mohd Rafiqul Islam, “Designand Implementation of an Optimal Fuzzy LogicController Using Genetic Algorithm,” Journal ofComputer Science 4 (10), pp. 799-806, 2008.