system. But the power of biological evolution isnot in how the genotype is represented, but inhow it is used. (Kratz, 2009) describes that theDNA is used by first dividing it into sectionscalled genes which encode proteins. Proteins aresequences of molecules called amino acids, thesequence of which is determined from the gene.Once a protein is produced it folds up into a threedimensional structure, the shape of which willgive it a function such as breaking or joiningmolecules. All the different proteins producedwhen working together make cells do what theydo and this gives rise to the phenotype.So it can be said that the power of chemistry isheld inside this chromosome representation. Dif-ferent DNA instances give rise to different chem-ical results rather than encoding the phenotypedirectly in the DNA, as is the case with tradition-al genetic algorithms. This is what makes biolog-ical evolution so versatile. The question iswhether we can place the power of the Turingmachine, rather than of chemistry, inside a ge-neric genetic algorithm. That way it can be usedand reused for a wide variety of problems, ratherthan having to redesign the encoding and geneticoperators for different problems.There are, of course, several indirect encod-ings developed which use a process to convertthe chromosome into a candidate solution ratherthan encoding the candidate solution itself in thechromosome. Such examples include the follow-ing: (i) Developmental Genetic Programming(Banzhaf & Keller, The Evolution of GeneticCode in Genetic Programming, 1999) which usesan arbitrary sequence of symbols found in ma-thematical equations as a chromosome and re-pairs these sequences into legal expressions, (ii)Gene Expression Programming (Ferreira, 2001)which encodes a tree of nodes into a linearlystructured chromosome to be converted to a treesuch that any chromosome is guaranteed to havea prefix that encodes a valid tree, and (iii)Grammatical Encoding (Mitchelle, 1998, p. 74)where a context free grammar is evolved, out of which a single string is produced which encodeshow the neurons of an artificial neural network are to be interconnected.However the only indirect encoding foundwhich was meant to be used as a general solutionrather than being problem oriented was that de-scribed in (Guillaumier, 2002) where problemsare described as DBMS tables which need rela-tionships between the tables; the genetic algo-rithm will then evolve the relationships. Thissystem is very natural to use for solving relation-ship problems such as time table schedulingwhere a relationship between time slots and les-sons has to be found. However, it becomes lessnatural to use for other problems such as numeri-cal ones.This paper describes a way to create a genericgenetic algorithm which is both reusable for dif-ferent problems and easy to use by a program-mer.
Specification and Analysis
One way to create a generic genetic algorithm isto make one which can evolve any value of anytype (strings, integers, floats, arrays of strings,etc). The user would then only have to supply afitness function which, apart from acting as anormal fitness function, also penalizes a candi-date solution for being of an undesired type andfor being an illegal value (such as an array whichisn’t a permutation). The problem, of course, isthe massive search space created as well as theincreased complexity of the fitness function.Instead, a way to guide the genetic algorithmto create only candidate solutions of a desiredtype is used. The genetic algorithm used is asimple binary chromosome encoding, irrespec-tive of the problem being solved. Therefore thegenetic algorithm needs never be altered and isgeneric. What’s new is that apart from the fitnessfunction, the user also supplies a phenotypebuilding function, or builder function.This function takes as a parameter a reader ob- ject which encapsulates the binary chromosomeand provides methods to read the sequence of bits as primitive data type values such as integ-ers, strings and floats. In other words, each me-thod reads a part of the binary chromosome andconverts the binary number read to the appropri-ate type. For example reading a single bit to re-turn a Boolean value or reading several bits toreturn an integer. This is analogous to the way afile reader works, which reads a file byte by byte,converting the bytes into data of the desiredtypes.The user writes the phenotype builder functionsuch that its parameter, the reader object, is usedto obtain inputs for the function. Based on theseinputs, the function is to output a candidate solu-tion. The function is written such that only can-didate solutions of the desired type and only le-gal values are returned. For example, if a feedforward artificial neural network is to beevolved, a phenotype building function could bewritten which reads as many floats as there are