On the practical usage of genetic algorithms in ecology and evolution

Authors


Correspondence author. E-mail: s.hamblin@unsw.edu.au

Summary

  1. Genetic algorithms are a heuristic global optimisation technique mimicking the action of natural selection to solve hard optimisation problems, which has enjoyed growing usage in evolution and ecology. However, there is little standardisation in how genetic algorithms are implemented in these fields and even less practical advice for those hoping to implement genetic algorithms for their own models. This article aims to demystify genetic algorithms and provide assistance to researchers; basic programming knowledge is important for working with genetic algorithms, but none is required to read this article.
  2. I review the basics of genetic algorithm methodology and provide suggestions on problems that may or may not benefit from genetic algorithm methods. The genetic operators (selection, replacement, mutation, crossover) and their rate parameters (mutation rate, etc.) are a source of potential confusion and to ease their selection, I present recommendations informed by historical usage and best practices, concluding with potential pitfalls.
  3. Good reasons for employing genetic algorithms include: solving optimisation problems beyond the reach of analytical techniques, relaxing model assumptions, evolving behaviour in individual-based models, and simulating co-evolutionary processes. However, genetic algorithms are not always the correct technique to use. Simpler methods may sometimes outperform genetic algorithms, and certain problem features may cause trouble.
  4. Genetic algorithms strike a balance between exploration of the search space and exploitation of good solutions, driven by the choice of genetic operators and rate parameters. I outline a basic set of parameter values and operator choices for genetic algorithm models as a starting point and provide advice on how to modify them to explore the exploitation/exploration trade-off. Finally, I provide general advice on analysis and reporting of these models.
  5. There are a number of potential issues that can surprise unwary users, such as rate parameter values that lead to pathological outcomes; I suggest ways to detect and correct these problems. Also, contrary to popular usage, genetic algorithms can find solutions to game theory problems but cannot guarantee their stability. Finally, while genetic algorithms offer great power and flexibility by drawing inspiration from evolutionary processes, they are (usually) not a faithful model of genetics or evolution.

Introduction

Mathematical modelling in biology, which seeks to describe, explain, or predict phenomena that we see in the natural world, often addresses questions that exceed the reach of the analytical techniques available to us. For instance, even a question as seemingly simple as female preference for mating based on male age can lead to models which are intractable analytically (Beck et al. 2002). This is particularly troublesome when solving problems in evolutionary game theory, when the optimal strategy is a function of not only an individual's choice but also the choices of the other players in the game. Even simple games such as the famous Prisoner's Dilemma hold complexities that have required non-traditional techniques to model (Axelrod 1984, 1997).

To address this gap, researchers have begun to follow the advice of Sumida et al. (1990), who called for the use of genetic algorithms in the study of evolution. First proposed by Holland (1975), genetic algorithms are part of a class of population-based metaheuristics (Blum & Roli 2003) known collectively as evolutionary computation. These algorithms evolve populations of candidate solutions to discrete-valued problems using the tools of natural selection: mutation, crossover, selection, and replacement. Evolutionary computation includes other techniques such as genetic programming (evolving computer programs using natural selection; Koza 1992), but this article focuses on genetic algorithms as they are currently the most popular in biology.

I present a simple review of genetic algorithm methodology here and refer the reader to the Further Reading below for more detail. The use of terms in the genetic algorithm literature can vary from author to author, but I follow Luke (2009); it is important to remember that though the terms are borrowed from genetics and evolution, this does not mean that genetic algorithms should be seen as a faithful replica of either genetics or evolution unless this is explicitly modelled, (e.g. Sumida et al. 1990, and Section ‘'Pitfalls''). The main loop of a genetic algorithm is shown in Fig. 1. A population of candidate solutions, usually referred to as individuals, is created. Each individual has a structure referred to as its genotype or genome (or more generally, its representation), which encodes the solution to some optimisation problem. A trivial example is a string of binary numbers of arbitrary length which solves the problem of maximising the number of ‘1's in the string (i.e. maximum fitness is achieved when every position has a 1 in it). A genotype in the form of a vector of fixed length l is a chromosome, though the terms genotype and chromosome are often used interchangeably. Each position in the vector (i.e. each 1 or 0 in Fig. 1) is referred to as a gene or locus (I use locus hereafter). Binary and real-valued vectors are common, as are integer vectors (or vectors of discrete sets of elements, e.g. Hamblin & Hurd 2007).

Once the initial population is created, each individual is assigned a fitness score depending on how well it solves the optimisation problem, such as how many ‘1's are in the string for our trivial example. After fitness has been assessed the genetic operators of selection, crossover, mutation, and replacement are applied to the population, usually but not necessarily in that order. The selection operator is a scheme for translating differential fitness into differential reproduction, either deterministically or stochastically. Some common examples are:

  • Truncation selection. The fittest X% of the population is allowed to reproduce. The individuals that will actually reproduce after truncation are typically chosen uniformly from with the set of allowed individuals, or each individual reproduces an equal number of times (e.g. if p individuals are chosen, each reproduces 1/p times).
  • Roulette-wheel selection (also known as fitness-proportional). Individuals are given a probability of reproducing based on their fitness values, with larger fitness values assigned a higher probability, and then individuals reproduce when a draw from this probability distribution selects them. Note that it is possible for the fittest individuals not to be chosen at all; a variation of roulette-wheel, Stochastic Universal Sampling, ensures that the fittest individuals are chosen at least once.
  • Ranking selection. Where roulette-wheel selection assigns probability based on the raw fitness values, ranking selection first transforms the fitnesses into a rank ordering and assigns fitnesses based on ranking. Linear ranking and exponential ranking are the two most common forms of ranking selection.
  • Tournament selection. This is a non-parametric selection method that selects k individuals from the population at a time and compares their fitnesses; the fittest of the set of k individuals reproduces and then all k individuals are replaced in the population and the process begins again. A binary tournament, where k = 2, is a popular choice in the genetic algorithm literature.

The rate of selection controls the percentage of population that is allowed to reproduce in each generation. For roulette-wheel, ranking, and tournament selection this is often 1 so that all individuals have a chance of reproducing no matter how small, but smaller values are possible as well so that only the top X% are eligible to reproduce. If selection is elitist, some percentage of the fittest individuals will be guaranteed inclusion in the next generation.

If crossover is used, it is performed on the selected parents in order to form new children by swapping parts of each parents chromosome. Again, the language used in the genetic algorithm literature can be confusing; here, crossover does not necessarily imply chromosomal crossover as it might in biology, and though I use it here for consistency with previous work, recombination would be a better and more general term. Crossover operators include uniform (swapping loci between parents with some probability), one-point (a swap point is selected randomly and everything after that point is switched between the two chromosomes), and two-point (two swap points are chosen and everything between them is switched). The crossover in Fig. 1 is an example of two-point crossover, with the swap points in front of and after the shaded boxes. Mutation is then applied to the new children, either by selecting a random locus to change from each chromosome chosen for mutation (per chromosome) or by mutating each locus in every chromosome with some specified probability (per locus). Mutation of binary strings is bit-flipping, where 1s becomes 0s and vice versa, while mutation of integers or reals is usually done by adding or subtracting a small step drawn from a uniform or Gaussian distribution. Mutation of discrete sets is commonly done by selecting a new value from the set of possible alleles.

Figure 1.

Essential aspects of the genetic algorithm program flow with schematic examples to the right; see text for details. Schematic form of replacement not shown.

Replacement is the merging of the new population of children with the parents. In generational genetic algorithms, all parents die at the end of each generation, and selection continues to generate children until the entire population has been replaced. If the genetic algorithm is overlapping, also called steady-state, some percentage (<100%) of the population is killed each generation and replaced with children bred during selection. The amount of the population killed each generation is controlled by the replacement rate. Following replacement the generational loop is complete and the process begins again, using the population of offspring as the new parental population. When the population composition has fixated on a single genotype or a mixture of genotypes that does not change over time, we may consider this to be the solution that the algorithm has converged to. Since solutions are rarely known beforehand, genetic algorithms can be run for a specified number of generations or until some other criterion (e.g. stability in fitness for some period of generations) is met.

An important aspect to the functioning of a genetic algorithm (and any other metaheuristic) is the trade-off between exploration and exploitation (Luke 2009; Blum & Roli (2003) call them diversification and intensification). Exploration refers to (often random) movement around the search space, while exploitation refers to movement along a fitness gradient. Genetic algorithms combine exploration (mutation and crossover) with exploitation (selection/replacement) to test new solutions while increasing the representation of good solutions within the population. I will return to this trade-off when providing advice for model implementation in 'Advice for model implementation'.

Further reading: Luke (2009) is an accessible and practical introduction to using metaheuristics, especially genetic algorithms. Goldberg (1989) and Mitchell (1998) are classic and still-relevant texts on genetic algorithms, and are good starting points to learn more about their theoretical foundations, while Correia (2010) is a more recent review of evolutionary computation specific to biology. Ruxton & Beauchamp (2008) is a nice test of the utility of genetic algorithms on a model from behavioural ecology, with discussions of the consequences of algorithm implementation choices for the results; it makes a good complement for this review. Readers looking for more literature on genetic algorithms will find much overlap with another evolutionary computation technique called Evolution Strategies (Bäck 1996; Luke 2009), and much of what is written for them applies to genetic algorithms as well.

Problem selection for genetic algorithm modelling

Luke 2009 p.7) neatly summarises the best problems for genetic algorithms and other metaheuristics:

Metaheuristics are applied to I know it when I see it problems. They're algorithms used to find answers to problems when you have very little to help you: you don't know what the optimal solution looks like, you don't know how to go about finding it in a principled way, you have very little heuristic information to go on, and brute-force search is out of the question because the space is too large. But if you're given a candidate solution to your problem, you can test it and assess how good it is. That is, you know a good one when you see it.

Such problems are common when we attempt to model biological systems; models from evolutionary game theory are particularly prone to this issue (Hamblin & Hurd 2007). For example, the Prisoner's Dilemma game has been at the heart of many studies of the evolution of cooperation since it was first formulated in 1952 (Flood 1952; Axelrod & Hamilton 1981), but many of the extensions to the basic game such as allowing multiple interactions (the Iterated Prisoner's Dilemma) are difficult or impossible to solve analytically. Axelrod (1984) was among the first to use genetic algorithms to find solutions to the Iterated Prisoner's Dilemma, an approach that continues to bear fruit. Even simple evolutionary games can harbour unexpected solutions and population dynamics and analysing any game with a realistic set of strategies will quickly create a strategy space that is analytically intractable. For example, using a genetic algorithm Hamblin & Hurd (2009) found that a commonly cited game theory model of signalling used to support the idea of ‘dishonest’ (unreliable) signalling actually had another solution in which individuals never signal at all; this non-communicating strategy has higher payoffs at equilibrium than the previously published ESS solution and throws the stability of signalling populations under this model into question. Tellingly, this model has only a modest 64 pure strategy profiles and yet has proven to be challenging to fully characterise analytically.

More generally, relaxing assumptions in any mathematical model requires introducing additional complexity that may move the model analysis beyond the reach of traditional techniques. Beauchamp & Ruxton (2007) provide a clear example of this while extending previous work on group size effects and anti-predator vigilance. In their paper, Beauchamp & Ruxton identify assumptions related to forager behaviour in the previous work by Lima (1994) and Proctor et al. (2001) and select two in particular to relax. To analyse this new, more complicated model, they leverage a genetic algorithm approach and note that doing so allows them to use mutation to progressively test new strategies against the currently dominant strategy in the population.

Models like the one in Beauchamp & Ruxton (2007) highlight another good use of genetic algorithms in biology: mixing genetic algorithms with individual-based models. Individual-based models (IBMs; also known as agent-based models) are used to model the behaviour of a system at an individual level by specifying simple rules for agents and allowing them to interact. These models allow for complex behaviour to emerge from simple interactions, though this comes at some cost to interpretation and analysis. Their popularity has grown over the last two decades, especially in ecology (e.g. Grimm & Railsback 2005). However, modelling behaviour using IBMs can be limited by the need to fix the behavioural rule that the individual will follow beforehand or even make the behaviour random (as was done in Beauchamp & Ruxton 2007). By making the behavioural rule subject to optimisation by a genetic algorithm, it is possible to explore the parameter space of the behavioural model more effectively. For example, foragers in a social foraging task were assigned one of a set of three learning rules to test performance relative to each other (Beauchamp 2000), but the parameters to these rules were fixed in advance and only a few possible combinations from a massive search space were explored. Hamblin & Giraldeau (2009) extended this analysis by allowing the rule parameters to evolve to optimal values using a genetic algorithm; the conclusions of this analysis extended the previous work and identified one rule that appeared to perform more effectively. More generally, other optimisation and machine learning techniques, such as neural networks, can also benefit from mixing with genetic algorithms (e.g. Huse et al. 1999; Haferlach et al. 2007).

Another area of particular strength for genetic algorithms is in modelling the competitive co-evolution of a biological system (Hillis 1990; Correia 2010). By running two genetic algorithms in parallel, each population can be forced to react to the behaviour or characteristics of the other; Correia (2010) describes this as one population posing a problem and the other population solving it, as in an arms race between predator and prey. Though his focus was not biological, Hillis (1990) used coevolving parasites as a model to solve an optimisation task; more recently, Hamblin et al. (2009) explored the coevolution of social information use among predator and prey in the same fashion.

I have aimed in this section to highlight some areas in which genetic algorithms may prove useful to the study of biological questions, but as with any tool it is important to recognise the limitations of the technique. Not all optimisation problems, easy or hard, are suitable for genetic algorithms. On one hand, problems that are too simple (even if still too complex for analytical treatments) may be, at best, a waste of effort. For instance, maximising a smooth two-dimensional function with a single global optima, such as inline image, using a genetic algorithm may be inefficient when compared to a simple steepest-ascent hill-climbing algorithm ( Fig. 2; Luke 2009). This happens because the algorithm will sometimes make comparatively large leaps across the fitness landscape (especially as a result of crossover) and jump over the peak entirely, though if computational effort is not limiting then this may not be a pressing issue. On the other hand, if the fitness landscape is too ‘jagged’, with multiple sharply peak optima, the genetic algorithm may leap from peak to peak and exhibit difficulty in converging on a single solution. This may be the case if the problem exhibits a high level of epistasis (Davidor 1991; Whitlock et al. 1995). Issues can also arise if the peak is too narrow (the ‘needle in a haystack’ problem); in this case, the genetic algorithm may not be measurably more efficient at finding the solution than a brute-force random search (Bäck 1996, p. 56–7).

Figure 2.

In the function depicted here, a hill-climbing algorithm (left) will trace a minimal trajectory through the problem's search space, while a genetic algorithm may make large jumps that miss the maximum entirely (right). The genetic algorithm is still guaranteed to find the solution (Bäck 1996), but if effort is a factor another technique may be more suitable.

Advice for model implementation

The use of genetic algorithms, like any other optimisation technique, requires making a series of decisions about implementation that are often left as an exercise to the reader (De Jong 2007). Here, I attempt to cut through the fog of options and provide helpful advice for researchers hoping to use genetic algorithms in their own work. This section benefits from the fact that genetic algorithms can perform robustly under a range of parameters; this does not mean that parameter choices are irrelevant, but rather that it is possible to provide starting points to work from. It should be noted, however, that the unanswered questions about exactly how genetic algorithms work and what problem features may be easy or hard for genetic algorithms make for an active area of research.

To illustrate how genetic algorithms have been used to answer questions in ecology and evolution to date, I performed a representative but non-exhaustive literature search using the ISI Web of Science (Thomson Scientific 2011) for search terms related to genetic algorithms in fields related to ecology and evolution (see Tables 2, 3 and 4). I excluded results from molecular and cell biology and biochemistry in order to focus on evolutionary biology, ecology, and behaviour (ISI Subject Areas: Psychology or Evolutionary Biology or Behavioral Sciences or Zoology or Genetics/Heredity or Neurosciences/Neurology). I examined each result for relevance and to determine if they had sufficient detail on methodology to be included. Finally, I also excluded papers focusing on on the specialised method of GARP (Genetic Algorithm for Rule-Set Production).

The resulting list of 36 papers represent a broad sampling of the usage of genetic algorithms in the literature over the past 22 years and cover a wide variety of topics including cooperation, mate choice, sperm allocation, life history, animal signalling, predation, kin selection, genetics, and biomechanics (see Supplementary Material for references). A summary of some important choices regarding genetic algorithm operators and parameter values from these studies is given in Table 1.

Table 1. Features of historical usage of genetic algorithms in ecology and evoution, including values for selection, replacement, mutation, and crossover
Studies 
  1. see Introduction for terms; RWS = Roulette Wheel Selection, SUS = Stochastic Universal Sampling. The number of studies may not sum to 36 in all tables as some studies did not report one or more of these parameters.

(a) Selection operator 
RWS7
Ranking3
SUS1
Tournament1
Truncation16
(b) Selection rate 
 <0·259
0·25–0.4911
0.5–0.740
0·75–16
(c) Replacement operator 
Generational18
Overlapping16
(d) Replacement rate 
 <0·255
0·25–0·493
0·5–0·741
0·75–122
(e) Mutation rate 
 <0·0011
0·001–0·00912
0·01–0·0913
0·1–19
(f) Crossover rate 
 <0·253
0·25–0·495
0·5–0·743
0·75–111

A researcher wanting to use a genetic algorithm in their work needs to make several implementation decisions, including: whether to use mutation, crossover, or both; what type of selection and replacement to use; and, what rate to apply to each of these operators. Regarding the variation operators, mutation and crossover, all genetic algorithms use mutation as a means of generating variation, but not all genetic algorithms use crossover (10 out of 36 in Table 4 did not). Indeed, there is some discussion in the technical literature on the precise function of crossover and whether it is required (e.g. Spears et al. 1992; Mühlenbein & Schlierkamp-Voosen 1995; Richter 2010). Problems which are difficult for crossover operators to solve are not impossible to find (Poli et al. 2006), but they seem to be rare in practice; because the computational time required to perform mutation and crossover is so small compared to fitness evaluation (which is the largest performance bottleneck), both can be included in a first implementation. Following that, if the solutions generated by the algorithm are insensitive to the presence of the crossover operator, it is possible to drop it from the final runs to reduce the space of rate parameters that must be explored (e.g. Hamblin & Hurd 2007).

The type of mutation used will usually be problem-dependent, and there is little reason to prefer per-locus over per-chromosome or vice-versa (though 78% of the papers in Table 4 use per-locus). However, the same cannot be said for crossover methods. Even though nearly 40% of the reviewed papers use one-point crossover, it is now strongly discouraged in practice due to problems with linkage where good combinations of alleles that are farther apart on the chromosome are more likely to be broken up than if they are close together (Mühlenbein & Schlierkamp-Voosen 1995; Luke 2009; Richter 2010). Instead of one-point crossover it is now recommended to use two-point or uniform crossover, methods which do not suffer from the same issue.

Choosing selection and replacement operators (note that not all authors make a distinction between the two) is somewhat easier. Despite the historical usage in (Table 1a), the consensus recommendation for selection method is k-tournament (Correia 2010). Proportional methods like roulette-wheel and stochastic universal sampling suffer from two problems. First, they can show premature convergence (Correia 2010), which means that the population will lose diversity and (perhaps) converge to a local optima without fully exploring the search space. Secondly, proportional methods suffer from a problem that might be termed fitness compression where fitness values crowd near the maximum value and are selected with almost equal probability as the runs progress. For instance, if the maximum fitness is 9·99 out of a possible 10 and the population is full of members close to this value (9·97, 9·98, etc), proportional methods will select among these individuals with almost equal probability even though they are still not at the maximum (Luke 2009). Tournament selection is non-parametric in that it assumes only an ordinal ranking of fitness values, and is superior to truncation selection (which is also non-parametric) because it can be adjusted by manipulating the tournament size. It is also easy to provide advice on replacement operators: unless there is a preference for generational replacement for reasons of biology, overlapping replacement shows better performance (Syswerda 1991), and allows the previous generation's best solutions to be tested against the newly introduced members.

Previous work shows some clear preferences for mutation, crossover, and selection/replacement rates, as summarised in Table 1. The curse of the biologically-inspired language of genetic algorithms may rear its head here; unless the genetic algorithm is being used to directly simulate the underlying biology, the choice of mutation or crossover rates do not map onto ‘realistic’ values from molecular evolution. Any rate parameter value that solves the underlying optimisation problem is acceptable, but it is useful to ask what values are recommended to enhance the performance of the algorithm. For mutation rate, an often cited value that makes for a good starting point is 1/l, where l is the length of the genome (Mühlenbein & Schlierkamp-Voosen 1995; Luke 2009; Richter 2010). Recombination rates are less commonly given though 0·5 is a reasonable initial choice.

Selection and replacement rates should also be chosen with an eye towards the exploitation or exploration trade-off. Lower values for each rate (e.g. 30% or less) will have the effect of enhancing exploration by (hopefully) slowing the march towards convergence, while higher values will have the opposite result. If the problem's fitness landscape is ‘easy’, then increasing exploitation (higher selection and replacement rates) will ensure that the genetic algorithm converges faster, but if the landscape is ‘hard’ then the algorithm will most likely miss the best solution. I am aware of no comprehensive empirical treatment of this question that would provide a single good answer as to what rates will be best. However, experience has led me to believe that unless the problem is so computationally expensive that run length is a serious concern, selecting lower rates for replacement and selection to allow more exploration and compensating by increasing run length makes for the best balance.

Using sensible rate parameter values as described in this review is likely to lead to adequate performance (c.f. Ruxton & Beauchamp (2008) for a specific example of the effect that changing mutation rates can have). However, if the researcher suspects that rate parameter values are causing difficulty in finding a solution, one possible solution is to use adaptive parameter values (Srinivas & Patnaik 1994; Luke 2009). Note that the term ‘adaptive’ here has a specific technical meaning, namely that the parameter values change over time to enhance the effectiveness or efficiency of the genetic algorithm (De Jong 2007). For example, in terms of mutation rate this usually entails increasing or reducing mutation over the length of a run according to some rule such as: if population mean fitness is increasing too fast, increase the mutation rate, or decrease it if mean fitness is increasing too slowly. However, a full discussion of this is beyond this review, and the interested reader is referred to De Jong (2007), Luke (2009), and Chapter 11 of Richter (2010) for more.

Finally, examining the papers selected for this review shows a computational trade-off between run length and population size: having both a large population size and long runs can lead to each run requiring too long to complete (Fig. 3). Selecting population size, if not constrained by the biological problem the researcher has chosen (e.g. modelling the behaviour of a species that forages in small groups), will depend on how helpful a diverse initial population is. If the search space is especially large or difficult, a larger population can help by providing more variation in initial solutions (greater exploration), which amounts to a highly parallel search. Whatever population size is selected, a small number of runs that go as long as computationally feasible should be conducted to ensure that the solutions found by the genetic algorithm are not due to a lack of search time. This is also important because most problems of interest to researchers in biology will not have known solutions, and so there is no way of knowing if the ‘correct’ solution has been found by the end of the run or if the algorithm has become stuck on a local optimum. This problem cannot be entirely eliminated, but allowing for longer runs and performing multiple repetitions under the same parameters is the easiest way to minimise it. The interested reader is also directed to the discussion of this issue in Ruxton & Beauchamp (2008), where they demonstrate this trade-off in operation in their model and arrive at the same conclusion.

Figure 3.

The trade-off between run length and population size. Computational limitations may constrain this relationship and force researchers to focus on longer runs or larger populations.

Analysis and presentation of genetic algorithm results is a large topic, and one specific to the problem being modelled, but some general advice is still possible. Plots of mean population fitness (and its variance) and the fitness of the best individual over time can be important for both diagnostic and reporting purposes; populations that reach a single solution (close to zero variance) within a few generations are a clear sign of premature convergence, likely stemming from a problem in the balance of exploration and exploitation (selection too strong, too little mutation/crossover, population size too small, etc). To help guard against such problems it is important that a sensitivity analysis (varying the model parameters to see if the results obtained change) be conducted and reported. In my own experience I have found the genetic algorithm results to be robust to even large changes in the parameter values, but this will almost certainly be problem-dependent and should always be checked. It is equally important to report the parameter values and model details when writing up the results of a simulation study using a genetic algorithm as these details form a core part of the methodology of the paper and must be available to other researchers. Finally, if a researcher writes their own genetic algorithm implementation, the source code should be released so that other researchers can replicate the results. This can be done in a multitude of ways, such as making the code available as supplemental material to the paper or submitting the code and run data together to websites like Data Dryad (http://datadryad.org; see also Whitlock 2011).

Pitfalls

Many of the problems that arise when using a genetic algorithm can be traced to an imbalance between exploration and exploration. For example, a bias for exploitation can be seen in a plot of population diversity when there is a sharp decline early in the run. When this is the case, increasing the mutation rate and crossover rates may help. If the problem is especially severe, adaptive mutation and crossover rates may help (Srinivas & Patnaik 1994; Luke 2009). Crossover may also be hindering the genetic algorithm from finding solutions if it breaks up good combinations as they arise, and so testing runs without crossover or finding other ways to maintain linkage disequilibrium may help (Arbilly et al. 2011). In the other direction, if the algorithm is showing persistent problem with convergence (i.e. too much exploration) then it is common to try a higher selection rate or elitism as a fix; recall that elitism involves guaranteeing inclusion of some percentage of the fittest individuals passage into the next generation unchanged. Diagnostic plots of the population composition (e.g. frequency of each chromosome) and fitness variance over time may also be useful. Some per-generation fluctuation in population composition is to be expected due to mutation but if the population structure is still changing significantly at the end of a run and the variance in fitness is large (suggesting that newly arising individuals have high relative fitness, even if only temporarily), the algorithm may be having difficulty converging or need more time to arrive at the solution. Of course, this could also be due to the nature of the solution, such as game theory models like Rock-Paper-Scissors that show cyclic dynamics (Hofbauer & Sigmund 1998).

It is common to use genetic algorithms to solve evolutionary game theory problems (characterised by their frequency-dependence) and search for strategies that are evolutionarily stable (ESSs; Maynard & Smith 1982). This is a valid and important application of genetic algorithms, but some go further and imply or claim that the solutions discovered by their algorithm must be evolutionarily stable. For example, Beauchamp & Ruxton 2007 p. 1200) write that “after several generations, the solution that emerges and persists in the face of further mutations should therefore be stabile evolutionarily”. This is not necessarily true, unless it can be proven that a population fixated on the proposed ESS solution has been exposed to every other potential strategy (chromosome) by mutation and/or crossover (this follows directly from the definition of an ESS in Maynard & Smith (1982), which makes stability contingent on comparison to ‘all possible mutants’). The probability of a putative ESS being exposed to every possible invader will decline quickly as the strategy space increases in size, and an exhaustive test of a potential solution can quickly escape our reach, computationally; an example of this problem is described in the discussion of Hamblin & Hurd (2007), where adding even a single complication to the signalling model used in that study can change the number of (pure) strategies to test from hundreds to millions or tens of millions. The issue can be addressed in part by doing many replicate runs of the genetic algorithm, but there is no way to definitively eliminate it for any but the simplest models (which can usually be solved analytically). On the other hand, it is known that ESSs may be stable but not accessible (the population may not be able to evolve to the ESS: Eshel 1983; Nowak 1990) and so there is also no guarantee that the algorithm will be able to find a particular ESS by evolving to it. Finally, if there exists more than one stable strategy for a particular game, there is no way to determine if the algorithm has identified (or will be able to identify) all of the solutions.

For these reasons, if it is possible to provide an analytical or numerical proof of the stability of the potential solution(s) indicated by the genetic algorithm (see Hamblin & Hurd (2007) and Beauchamp (2000) respectively for examples), this is to be preferred. If that is not feasible, then another method that may help is to perform new runs of the genetic algorithm using a population ‘seeded’ at some percentage with the potential solution (e.g. a population composed of 30% of the solution under testing), and allowing the GA to explore as much of the strategy space as possible (it may be useful to inject random strategies into the population at regular intervals to increase diversity). This will test the stability of the potential solution by exposing it to as many possible invaders as possible, and should be repeated as many times as is computationally feasible to increase coverage of the strategy space. It should be recognised, though, that unless it can be demonstrated that every potential invader is tested, it will still not be possible to absolutely guarantee that the solution is evolutionarily stable. This does not render genetic algorithms useless for frequency-dependent problems, as they may be the only feasible way to address such complex models and their results can provide valuable insight into the population dynamics and potential solutions of these models. But it should inspire caution in the claims made about the algorithm's outcomes: they must be considered potential solutions until somehow proven otherwise.

As mentioned in the Introduction, genetic algorithms may be inspired by biological evolution but they are generally not faithful replications of that process. However, if desired, it is possible to use genetic algorithms as explicit models of genetic evolution to answer questions in molecular or population genetics; examples include Judson & Haydon (1999) and Wiles et al. (2005). For instance, Judson & Haydon (1999) uses a genetic algorithm to study the evolution of the universal genetic code (the translation of genes into proteins) by natural selection. Doing so introduces additional complexity because even treating a genetic algorithm as a minimal model of the genetics and the selection process (as in Axelrod 1997; Collins et al. 2006) requires special attention to the representation and parameterisation of the genetic algorithm to ensure biological realism. Therefore my recommendation is that unless the researcher wishes to model an explicitly realistic genetic and selection model, the genetic algorithm should treated as an optimisation technique only. This does not mean that all information about the evolution of the population must be ignored, because the algorithm's population dynamics can still inspire meaningful hypotheses for further investigations in empirical work. For example, if the algorithm identifies two solutions to an evolutionary game but preferentially fixates on one solution over another, this is cause to investigate further theoretically and empirically (Hamblin & Hurd 2007).

Finally, two practical issues deserve mention. The first is a reminder that when applying genetic algorithms to frequency-dependent problems, population mean fitness may decline as the population approaches the optimal solution. For instance, a population playing Dove in the Hawk-Dove game will have the highest fitness but will be quickly invaded by Hawks and the population mean fitness will go down (Maynard & Smith 1982). The second issue is that genetic algorithms, especially when mixed with individual-based models, can be complicated pieces of software. In addition to releasing source code, it may be helpful to test the algorithm on simpler problems with known solutions to verify its operation if that is possible. For instance, genetic algorithms meant to solve evolutionary games could be tested on Hawk-Dove and similar games; algorithms solving other optimisation problems could be tested on simple functions first (examples in Luke (2009), section 11.2 and Bäck (1996), chapter 3). Conversely, mixing simulations such as individual-based models with genetic algorithms for optimisation is become more common (multiple examples of this are in Tables 2-4), to the point where the genetic algorithm is sometimes included implicitly in the model without discussion. However, any model optimising with a genetic algorithm can be significantly affected by the implementation of that algorithm, and so it remains important to be explicit about the algorithm's details in the description of the methodology.

Table 2. Population size, run lengths, and representations
ReferencesPop. SizeRun lengthRepresentation
  1. inline imageExperiment 1.

  2. inline imageReal-valued version.

  3. NU = not used, NR = not reported, NA = not applicable, ? = could not determine from methods.

Sumida et al. (1990)inline image36100Integer
Crowley et al. (1996)201000Integer/Discrete
Barta et al. (1997)50200Reals/Binary
Bouskila et al. (1998)12010000Integer
Sherratt & Roberts (1998)90500Binary
Huse et al. (1999)20001000Reals
Judson & Haydon (1999)200150–2000Discrete
Bond & Kamil (2002)200100Binary
Niv et al. (2002)inline image100500Reals
Reinhold et al. (2002)100500Reals
Strand et al. (2002)2000500Reals/Binary
Beauchamp & Ruxton (2005)20500Discrete
Wiles et al. (2005)10002000Discrete
Collins et al. (2006)2506000Binary
Engqvist & Reinhold (2006)100100Reals
Hancock et al. (2006)Variable100000Reals
Heinz & Strand (2006)1600200–350Reals
Beauchamp & Ruxton (2007)6–201000Reals
Hamblin & Hurd (2007)100500Discrete
Engqvist & Reinhold (2007)70500Reals
Thibert-Plante & Charbonneau (2007)100 inline image Binary
Beauchamp (2008)2–751000Reals
Ruxton & Beauchamp (2008)inline image10001000Reals
Colman & Browning (2009)202000Binary
Hamblin & Hurd (2009)100500Binary
Hamblin et al. (2009)10/1000500Reals/Integer
Hamblin & Giraldeau (2009)10–1000500Reals/Discrete
Mitchell (2009)12000/400–12001000Reals
Arbilly et al. (2010)3003000Discrete
Yamauchi & Hashimoto (2010)200NRBinary
Cressler et al. (2010)8001000Reals
Acerbi & Nunn (2011)100100Binary
Burrow et al. (2011)200200Reals
Tang et al. (2011)500100Reals
Wild (2011)10010000Reals
Zhu et al. (2011)1000400Reals
Table 3. Variation operators (mutation and crossover) and their parameters in historical usage
ReferencesMutation ratePerCrossoverRate
  1. NU = not used, NR = not reported, NA = not applicable, ? = could not determine from methods.

  2. inline image 0·005 change of entire chromosome being reinitialised each generation.

  3. inline imageCrossover not used in main results; see Appendix 3 of the reference.

  4. inline imageNot reported in paper.

  5. inline imageMutation rate decreased over time from 0·3.

  6. inline imageMutation rate decreased over time from 0·05.

Sumida et al. (1990)0·01L1-pt0·5
Crowley et al. (1996)0·005–0·01LUniformNR
Barta et al. (1997)0·05L?0·5
Bouskila et al. (1998)0·001LUniform0·5
Sherratt & Roberts (1998)0·01L1-pt1
Huse et al. (1999)0·1L1-pt0·5
Judson & Haydon (1999)0·05LUniform1
Bond & Kamil (2002)0·003LUniformVariable
Niv et al. (2002)0·16–0·04LUniform0·25
Reinhold et al. (2002)10% of pop.NA?1
Strand et al. (2002)0·001/0·1C1-pt0·6
Beauchamp & Ruxton (2005)0·005LNUNU
Wiles et al. (2005)0·001L1-pt1
Collins et al. (2006)NRNRNRNR
Engqvist & Reinhold (2006)10% of pop.NACopy0·2
Hancock et al. (2006)1inline imageNANUNU
Heinz & Strand (2006)0·2CBlending1
Beauchamp & Ruxton (2007)0·01CNUNU
Hamblin & Hurd (2007)0·001–0·005LUniforminline image0·2
Engqvist & Reinhold (2007)0·05CCopy0·75
Thibert-Plante & Charbonneau (2007)0·016L1-pt0·7
Beauchamp (2008)0·005LNUNU
Ruxton & Beauchamp (2008)1NANUNU
Colman & Browning (2009)0·01CUniform1
Hamblin & Hurd (2009)0·001–0·01LNUNU
Hamblin et al. (2009)0·01LUniforminline image0·5
Hamblin & Giraldeau (2009)0·002LUniform0·5
Mitchell (2009)0·2LNUNU
Arbilly et al. (2010)0·003LNUNU
Yamauchi & Hashimoto (2010)0·00025L1-pt1
Cressler et al. (2010)0·01L?1
Acerbi & Nunn (2011)0·05LNUNU
Burrow et al. (2011)1CNUNU
Tang et al. (2011)Variableinline image?1-pt1
Wild (2011)1L1-pt1
Zhu et al. (2011)Variableinline imageLUniform1
Table 4. Selection and replacement operators and rates
ReferencesSelectionRateReplacementRate
  1. NU = not used, NR = not reported, NA = not applicable, ? = could not determine from methods.

  2. aModel-based reproduction.

  3. bComparison was made of RWS and Tournament selection.

  4. cContinual birth-death process.

  5. dAbove-average fitness values reproduce.

Sumida et al. (1990)Truncation0·66Overlapping0·33
Crowley et al. (1996)RankingNRGenerational1
Barta et al. (1997)NR0·8Overlapping0·2
Bouskila et al. (1998)RWSNRGenerational1
Sherratt & Roberts (1998)Truncation0·33Overlapping0·66
Huse et al. (1999)?0·1Generational1
Judson & Haydon (1999)Truncation0·1Generational1
Bond & Kamil (2002)RankingNRGenerational1
Niv et al. (2002)Truncation0·5Generational1
Reinhold et al. (2002)Truncation0·5Generational1
Strand et al. (2002)Variableinline imageNAOverlappingNA
Beauchamp & Ruxton (2005)Truncation0·5Generational1
Wiles et al. (2005)RWS/Tournamentinline image1Generational1
Collins et al. (2006)NRNRNRNR
Engqvist & Reinhold (2006)Truncation0·5Overlapping0·5
Hancock et al. (2006)Variableinline imageNAOverlappingNA
Heinz & Strand (2006)Variableinline imageNAGenerational1
Beauchamp & Ruxton (2007)Truncation0·5Overlapping0·5
Hamblin & Hurd (2007)RWS0·2Overlapping0·05
Engqvist & Reinhold (2007)Truncation0·5Generational1
Thibert-Plante & Charbonneau (2007)Truncation0·2Overlapping0·99
Beauchamp (2008)Truncation0·5Overlapping0·5
Ruxton & Beauchamp (2008)Variable inline imageNAOverlappingNA
Colman & Browning (2009)RWS1Generational1
Hamblin & Hurd (2009)RWS0·2Overlapping0·05
Hamblin et al. (2009)RWS0·15Overlapping0·15
Hamblin & Giraldeau (2009)RWS0·1Overlapping0·1
Mitchell (2009)Truncation0·5Generational1
Arbilly et al. (2010)Truncation0·5Generational1
Yamauchi & Hashimoto (2010)RWS1Generational1
Cressler et al. (2010)SUS1Generational1
Acerbi & Nunn (2011)Truncation0·2Overlapping0·8
Burrow et al. (2011)Truncation0·02Generational1
Tang et al. (2011)Truncation0·5Overlapping0·9
Wild (2011)TruncationVariableinline imageOverlapping1
Zhu et al. (2011)Ranking1Generational1

Conclusion

Along with a a basic introduction to genetic algorithms, this review has attempted to shed light on some of the methodological difficulties involved in using genetic algorithms to solve hard optimisation problems in biology, while at the same time providing sensible starting points for researchers hoping to use genetic algorithms in their own work (compare with Ruxton & Beauchamp (2008), which demonstrates some of the issues in action). The caveats mentioned throughout the paper should be remembered: genetic algorithms aren't a computational panacea, they don't guarantee evolutionary stability, and they aren't a faithful replica of evolutionary processes unless explicitly modelled as such. Yet if used properly, genetic algorithms can be a powerful part of a biologist's toolkit, and one of the best ways to find possible solutions to problems that outstrip our ability to address them analytically (including and especially frequency-dependent models).

Acknowledgements

I thank Mark Tanaka and Zach Aandahl for comments on an draft of this work, and the comments of two anonymous reviewers for improving the manuscript. This research was supported by an ARC Discovery grant to Mark Tanaka and others.

Ancillary