Having discussed some problems and their symbol sets, it is important to now discuss precisely how a candidate is stored, as this will affect the rest of the implementation.
4.2
Linear Representations and Karva
One of the more prominent problems in usingGPis finding an appropriate form or datastructure to encapsulate a candidate solution to a problem.GPcandidates are originally (and intuitively) encoded as pointer tree datastructures. This is not conducive to the use ofGraphical Processing Units (GPUs)for accelerating them, however. While dynamic memory allocation is now supported by the very successfulCompute Unified Device Architecture (CUDA)
API, it is not without overhead due to the use of the global memory bank. Race conditions would also plague the construction and traversal of these trees.
There are generally three different candidate representations, they are tree-based, linear and graph representa- tions [25]. The original tree-based representation devised by Koza involved the use of LISP S-expressions [150]. The newer linear [25] representation is more focussed upon a set of instructions, executed one after the other. Graph
GP[139] is a generalisation of the tree-based representations, which could perhaps be well illustrated as a flow diagram.
A representation named Karva [63] is discussed here. Strictly speaking, it falls under the category of linear representations. It has some advantages over the original tree-based representations and as such it is used later in this chapter. It is a linear representation of expression tree structures which Ferreira used for developing the Gene Expression Programming algorithm [64] which are stored in memory as strings of symbols. Karva is closely related to Read’s linear code [219], which was an early method to linearise expression trees forGP.Intronsare supported by Karva, which is an interesting feature explained in this section along with how operators such as crossover and mutation are applied. It should be noted that the Gene Expression Programming algorithm features many additional operators including replication, mutation, three transposition operators and three recombination operators. These serve to more closely emulate reality and guarantee effective circulation of genetic information [63].
Another advantage behind the Karva language of GEP is its ability to effortlessly handle any-arity functions, variable length, and introns. Expressions based on Karva in GEP are known ask-expressions, and are constituted by a set of symbols (from the functionFand terminalTsets) in a specific order. There are however, some disadvantages concerning the interpretation of these trees (also known as the genotype-phenotype mapping). However, these are necessary in order to support its more salient features.
These Karva-expressions (ork-expressions) are written by Ferreira in the following form [64]:
012345678901234567 Q-+/-abaa+a-bbacda
The function and terminal sets used in thisk-expression are the same as those of Section4.1.1above, except the terminal setTnow contains the arbitrary constantsa,b,candd. The line of digits above the expression is simply
an indexing convenience, and the next line is thegenotypeof the candidate.
The sequence of symbols shown is known as a genotype, meaning that is must first be interpreted before it can be used. The interpretation of this (or genotype-phenotype mapping) is shown in Figure4.5. It is worth noting that neither of the symbolscordappear in the phenotype. The phenotype is constructed simply by placing the first symbol at the root of the tree, and then filling arguments of the tree level by level, left to right by advancing through the sequence, symbol by symbol.
74 4. COMBINATORIAL OPTIMISATION Q - + / - a b a a + a - b b
FIGURE4.5: The abstract syntax tree representing thekarva-expressionQ-+/-abaa+a-bbacda.
Although candidates in this form would be kept at a constant length of symbols in the population, the actual depth and construction of the trees depend on the genotype-phenotype mapping, the sequence head length, position and number of function symbols. The symbol string (sometimes known as thechromosome) must be divided into head and tail sections, which have their lengths governed by the equation of Ferreira [64] shown in Equation4.2. In addition, Karva (and hence GEP) can support candidates with any-arity functions, provided this equation holds.
t=h(nmax−1) + 1 (4.2)
The concept of an intron is one which alludes to the concept of a disabled gene [64]. Candidates may at times have unused symbols in their “genetic code” as indicated by the interpretation ofk-expressions. These may be activated and deactivated depending on the operators used. This means that potentially useful genes (or symbols) are disabled instead of lost in some cases.
In Equation4.2, the variabletis the length of the tail section of thek-expression,his the length of the head section, andnmax is the largest arity possible in the function setF. Only terminal symbols are allowed in the tail section of the candidate. Should there be too many symbols from the function setFin the candidate, and not
enough terminals, a valid tree cannot be constructed. This is the reason why this equation is necessary.
Simple one-point crossover and point-mutation operators are used in this chapter, in the spirit of the original GP and Genetic Algorithm (GA) [107]. For more sophisticated operators, the reader is referred to the work of Ferreira [64]. As noted in Chapters8and9, there is scope for future work in this area. The additional operators provided by Ferreira are important to ensure the circulation of genetic information throughout a population of candidates [63]. Simple one-point crossover can be applied in a very similar fashion to that of the traditional GA. A random site in a chromosome is chosen, and information is swapped about this point with another chromosome. This generates two new candidates. An advantage of having a linear representation such asKarvais that this crossover operator is much simpler to implement than in the usual single-threaded implementation of GP with pointer-trees.
4.2. LINEAR REPRESENTATIONS AND KARVA 75 01234567890123456
*-+*-abaa/abbacda
When this expression is recombined with the followingk-expression, with crossover site at index 5:
01234567890123456 *-++baa/bbabbacda
Then the two candidates generated are shown below:
01234567890123456 *-++babaa/abbacda *-+*-aa/bbabbacda
The phenotypes of these new candidates are shown in Figure4.6. It is notable that the structures in this figure differ greatly, even though the chromosomes are of the same length.
(a) New candidate with genotype *-++babaa/abbacda.
(b) New candidate with genotype *-+*-aa/bbabbacda.
FIGURE 4.6: New candidates generated by the crossover operator from the “parental” genotypes
*-+*-abaa/abbacdaand*-++baa/bbabbacda.
In the traditional representation of solution candidates as pointer tree datastructures, crossover is done by a variety of methods, and most commonly subtree swap/splicing [207,149]. There is considerable additional overhead traversing a pointer tree in memory (especially on GPU) to find a random subtree and reassigning it to another randomly selected node in another tree.
Point mutation is much simpler. Consider the expression*-+*-aa/bbabbacdawhose phenotype is shown in Figure4.6(a). Assume the head length of thisk-expression is8. The symbolaat a random index 7, may be swapped for a random nonterminal or terminal, but any symbols in the tail section can only be swapped for terminals. Suppose the symbol at index 7 is switched for the/symbol, the expression becomes*-+*-a//bbabbacda
Apart from the considerable lengths necessary to ensure a representation which is suitable for parallelisation, it is also necessary to consider the ramifications of parallelising the genetic operators. Though the fitness evaluation
76 4. COMBINATORIAL OPTIMISATION
phase is likely to be far more time consuming, it is useful to consider parallelisation of the search algorithm itself when considering the possibility of large populations. The very common Roulette selection method (fitness- proportionate selection) does not parallelise extremely well, for instance. Most parallel GP algorithms make use of a selection method named “Tournament Selection” [183]. In this scheme, every candidate is compared against another uniform-randomly selected candidate, and the best candidate (by fitness) is chosen as one of a crossover pair. Once this process is complete, two candidates at a time are recombined and then the mutation operator is applied.
In the next section, Karva is used as a representation for GP and further considerations for its use on GPU hardware are made. Following this, Geometric Optimisation is introduced in Section4.5, along with a prominent example of it named the GeometricParticle Swarm Optimiser (PSO)[190,280], and then a new algorithm in the spirit of the geometric unification is proposed based on the Firefly Algorithm in Section4.7. Some simple visualisation techniques for these algorithms are presented in Section4.8.