Matlab GA
Matlab GA
1. Introduction
Genetic algorithms (GAs) are stochastic global search and optimization methods that mimic the metaphor of natural
biological evolution [1]. GAs operate on a population of potential solutions applying the principle of survival of the
fittest to produce successively better approximations to a solution. At each generation of a GA, a new set of
approximations is created by the process of selecting individuals according to their level of fitness in the problem
domain and reproducing them using operators borrowed from natural genetics. This process leads to the evolution of
populations of individuals that are better suited to their environment than the individuals from which they were
created, just as in natural adaptation.
GAs have been shown to be an effective strategy in the off-line design of control systems by a number of
practitioners. For example, Krishnakumar and Goldberg [2] and Bramlette and Cusin [3] have demonstrated how
genetic optimization methods can be used to derive superior controller structures in aerospace applications in less
time (in terms of function evaluations) than traditional methods such as LQR and Powell’s gain set design. Porter and
Mohamed [4] have presented schemes for the genetic design of multivariable flight control systems using
eigenstructure assignment, whilst others have demonstrated how GAs can be used in the selection of controller
structures [5].
1. Department of Automatic Control and Systems Engineering, University of Sheffield, PO Box 600,
Mappin Street, Sheffield, England. S1 4DU
From IEE Colloquium on Applied Control Techniques Using MATLAB, Digest No. 1995/014, 26/01/95
of Baker [10]. In addition, non-linear ranking is also supported in the routine ranking.
Crossover operators: recdis, recint, reclin, recmut, recombin, xovdp, xovdprs, xovmp, xovsh,
xovshrs, xovsp, xovsprs
The crossover routines recombine pairs of individuals with given probability to produce offspring. Single-point,
double-point [12] and shuffle crossover [13] are implemented in the routines xovsp, xovdp and xovsh
respectively. Reduced surrogate [13] crossover is supported with both single-, xovsprs, and double-point,
xovdprs, crossover and with shuffle, xovshrs. A general multi-point crossover routine, xovmp, that supports
uniform crossover [14] is also provided. To support real-valued chromosome representations, discrete, intermediate
and line recombination are supplied in the routines, recdis, recint and reclin respectively [15]. The routine
recmut performs line recombination with mutation features [15]. A high-level entry function to all the crossover
operators supporting multiple subpopulations is provided by the function recombin.
The initialisation complete, the GA now enters the generational loop. First, a fitness vector, FitnV, is determined
using the ranking scheme of Baker [11]. Visualisation and preference articulation can be incorporated into the
generational loop by the addition of extra functions. In this example, the routine plotgraphics displays the
performance of the current best controller allowing the user to asses the state of the search. Individuals are then
selected from the population using the stochastic universal sampling algorithm, sus, with a generation gap, GGAP =
0.9. The 36 (GGAP × NIND) selected individuals are then recombined using single-point crossover, xovsp,
applied with probability XOV = 0.7. Binary mutation, mut, is then applied to the offspring with probability MUTR
= 0.0175, and the objective function values for the new individuals, ObjVSel, calculated. Finally, the new
individuals are re-inserted in the population, using the Toolbox function reins, and the generation counter, gen,
incremented.
The GA terminates after MAXGEN iterations around the generational loop. The current population, its phenotypic
representation and associated cost function values remain in the users workspace and may be analysed directly using
MATLAB commands.
LIND = 15; % Length of individual vars.
NVAR = 2; % No. of decision variables
NIND = 40; % No. of individuals
GGAP = 0.9; % Generation gap
XOV = 0.7; % Crossover rate
MUTR = 0.0175; % Mutation rate
MAXGEN = 30; % No. of generations
% Binary representation scheme
FieldD = [LIND LIND; 1 1; 1000 1000; 1 1; 0 0; 0 0; 0 0];
% Initialise population
Chrom = crtbp(Nind, Lind*NVAR); % Create binary population
ObjV = objfun(bs2rv(Chrom, FieldD)); % Evaluate objective fn.
Gen = 0; % Counter
% Begin generational loop
while Gen < MAXGEN
% Assign fitness values to entire population
FitnV = ranking(ObjV);
% Visualisation
plotgraphics
% Select individuals for breeding
SelCh = select(’sus’, Chrom, FitnV, GGAP);
% Recombine individuals (crossover)
SelCh = recombin(’xovsp’, SelCh, XOV);
% Apply mutation
SelCh = mut(SelCh, MUTR);
% Evaluate offspring, call objective function
ObjVSel = objfun(bs2rv(SelCh, FieldD));
% Reinsert offspring into population
[Chrom ObjV]=reins(Chrom, SelCh, 1, 1, ObjV, ObjVSel);
% Increment counter
Gen = Gen+1;
end
% Convert Chrom to real-values
Phen = bs2rv(Chrom, FieldD);
Figure 1: MATLAB Code for a Simple GA
In future releases we plan to incorporate support for multiobjective optimization. Multi Objective GAs (MOGAs)
evolve a population of solution estimates thereby conferring an immediate benefit over conventional MO methods.
Fonseca and Fleming [17] have demonstrated how, using rank-based selection and niching techniques, it is feasible to
generate populations of non-dominated solution estimates without combining objectives in some way. This is
advantageous because the combination of non-commensurate objectives requires precise understanding of the
interplay between those objectives if the optimization is to be meaningful. The use of rank-based fitness assignment
permits different non-dominated individuals to be sampled at the same rate thereby according the same preference to
all Pareto-optimal solutions. Because MOGAs are susceptible to unstable converged populations, due to the potential
for very different genotypes to result in non-dominated individuals, a particular problem is the production of lethals
when fit members of the population are mated. The search then becomes inefficient and the GA is likely to converge
to some suboptimal solution. In general, a combination of mating restriction, niche formation and redundant coding
may be appropriate.
4. Concluding Remarks
Together with MATLAB and SIMULINK, the GA Toolbox described in this paper presents a familiar and unified
environment for the control engineer to experiment with and apply GAs to tasks in control systems engineering.
Whilst the GA Toolbox was developed with the emphasis on control engineering applications, it should prove equally
as useful in the general field of GAs, particularly given the range of domain-specific toolboxes available for the
MATLAB package.
5. Acknowledgements
The authors gratefully acknowledge the support of this research by a UK SERC grant on “Genetic Algorithms in
Control Systems Engineering” (GR/J17920).
6. References
[1] J. Holland, Adaptation in Natural and Artificial Systems, The University of Michigan Press, Ann Arbor, 1975.
[2] K. Krishnakumar and D. E. Goldberg, “Control System Optimization Using Genetic Algorithms”, Journal of
Guidance, Control and Dynamics, Vol. 15, No. 3, pp. 735-740, 1992.
[3] M. F. Bramlette and R. Cusin , “A Comparative Evaluation of Search Methods Applied to Parametric Design of
Aircraft”, Proc. ICGA 3, pp213-218, 1989.
[4] B. Porter and S. S. Mohamed, “Genetic Design of Multivariable Flight-Control Systems Using Eigenstructure
Assignment”, Proc. IEEE Conf. Aerospace Control Systems, 1993.
[5] A. Varsek, T. Urbacic and B. Filipic, “Genetic Algorithms in Controller Design and Tuning”, IEEE Trans. Sys.
Man and Cyber., Vol. 23, No. 5, pp1330-1339, 1993.
[6] J. J. Grefenstette, “A User’s Guide to GENESIS Version 5.0”, Technical Report, Navy Centre for Applied Research
in Artificial Intelligence, Washington D.C., USA, 1990.
[7] D. Whitley, “The GENITOR algorithm and selection pressure: why rank-based allocations of reproductive trials is
best,” in Proc. ICGA 3, pp. 116-121, 1989.
[8] A. J. Chipperfield, P. J. Fleming and C. M. Fonseca, “Genetic Algorithm Tools for Control Systems Engineering”,
Proc. Adaptive Computing in Engineering Design and Control, Plymouth Engineering Design Centre, 21-22
September, pp. 128-133, 1994.
[9] D. E. Goldberg, Genetic Algorithms in Search, Optimization and Machine Learning, Addison Wesley Publishing
Company, January 1989.
[10] J. E. Baker J, “Adaptive Selection Methods for Genetic Algorithms”, Proc. ICGA 1, pp. 101-111, 1985.
[11] J. E. Baker, “Reducing bias and inefficiency in the selection algorithm”, Proc. ICGA 2, pp. 14-21, 1987.
[12] L. Booker, “Improving search in genetic algorithms,” In Genetic Algorithms and Simulated Annealing, L. Davis
(Ed.), pp 61-73, Morgan Kaufmann Publishers, 1987.
[13] R. A. Caruana, L. A. Eshelman and J. D. Schaffer, “Representation and hidden bias II: Eliminating defining
length bias in genetic search via shuffle crossover”, In Eleventh Int. Joint Conf. on AI, Sridharan N. S. (Ed.), Vol. 1,
pp 750-755, Morgan Kaufmann, 1989.
[14] G. Syswerda, “Uniform crossover in genetic algorithms”, Proc. ICGA 3, pp. 2-9, 1989.
[15] H. Mühlenbein and D. Schlierkamp-Voosen, “Predictive Models for the Breeder Genetic Algorithm”,
Evolutionary Computation, Vol. 1, No. 1, pp. 25-49, 1993.
[16] C. B. Petty, M. R. Leuze. and J. J. Grefenstette, “A Parallel Genetic Algorithm”, Proc. ICGA 2, pp. 155-161,
1987.
[17] C. M. Fonseca and P. J. Fleming, “Genetic Algorithms for Multiple Objective Optimization: Formulation,
Discussion and Generalization”, Proc. ICGA 5, pp. 416-423, 1993.