Here is a ten-slide introduction to CGP - Cartesian Genetic ...
Here is a ten-slide introduction to CGP - Cartesian Genetic ...
Here is a ten-slide introduction to CGP - Cartesian Genetic ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
cgp evolved picture<strong>Cartesian</strong> <strong>Genetic</strong>Programmingin a nutshellJulian F. MillerDept of Electronicshttp://www.elec.york.ac.ukUniversity of York, UKHome sitehttp://www.cartesiangp.co.ukcgp evolved picture1What <strong>is</strong> <strong>CGP</strong>? <strong>CGP</strong> <strong>is</strong> a form of au<strong>to</strong>matic computer program evolution (which itself <strong>is</strong> generallyknown as genetic programming). <strong>CGP</strong> was developed from work on the evolution of digital circuits, by Miller andThomson 1997. First actual mention of the term <strong>Cartesian</strong> <strong>Genetic</strong> Programmingappeared at the GECCO conference in 1999. The genotype <strong>is</strong> a l<strong>is</strong>t of integers (and possibly parameters) that represent theprogram primitives and how they are connected <strong>to</strong>gether• <strong>CGP</strong> represents programs as graphs in which there are explicit non-coding genes• <strong>CGP</strong> allows program <strong>to</strong> be evolved with more than one output The genes are• Addresses in data (connection genes)• Addresses in a look up table of functions (function genes)• Additional parameters (possibly) <strong>CGP</strong> easily encodes computer programs, electronic circuits, neural networks,mathematical equations and other computational structures. It allows a form of Darwinian evolution <strong>to</strong> evolve solutions <strong>to</strong> problemsau<strong>to</strong>matically and efficiently. In a sense it <strong>is</strong> an invention machine and can findunusual and efficient solutions <strong>to</strong> many problems in many fields of science.2
<strong>CGP</strong> General formnodec columnsm outputsr rowsn inputsLevels-backNote: Nodes in the same column are not allowed <strong>to</strong> be connected <strong>to</strong> each other3<strong>CGP</strong> genotypefunction genesOutput genesf 0 C 0 0 … C 0 a … f (c+1)r C (c+1)r 0 … C (c+1)r a O 1 ,…O mConnection genesUsually, all functions have as many inputs as the maximum functionarityUnused connections are ignored<strong>CGP</strong> has three parameters: number of columns, number of rows andlevels-back. These control the layout and connectivity of nodes4
ExampleFunction look-uptableFunctiongene(address)0ActionAdd1Subtract2Multiply3Divide(protected)Genotype0 0 1 1 0 0 1 3 1 2 0 1 0 4 4 2 5 4 2 5 7 35So what does the genotype represent?6
The <strong>CGP</strong> genotype-phenotype mapWhen you decode a <strong>CGP</strong> genotype many nodesand their genes can be ignored because they arenot referenced in the path from inputs <strong>to</strong>outputsThese genes can be altered and make nodifference <strong>to</strong> the phenotype, they are noncodingClearly there <strong>is</strong> a many-<strong>to</strong>-one genotype <strong>to</strong>phenotype map7Decoding <strong>CGP</strong> chromosomes requires 4 simplesteps// L = MaxGraph.Length// I = Number of program inputs// N = Number of program outputsbool ToEvaluate[L]double NodeOutput[L+I]// identify initial nodes that need <strong>to</strong> be evaluatedp = 0do2ToEvaluate[OutputGene[p]] = truep = p + 1while (p < N)// work out which nodes are usedp = L-1doif (ToEvaluate[p])x = Node[p].Connection1y = Node[p].Connection2ToEvaluate[x] = trueToEvaluate[y] = trueendifp = p - 1while ( p >= 0)1// load input data valuesp = 0doNodeOutput[p] = InputData[p]p = p + 1while (p < I)//Execute graphp = 0doif (ToEvaluate[p])x = Node[p].Connection1y = Node[p].Connection2z = NodeFunction[p].FunctionNodeOutput[p+I] = ComputeNode(NodeOutput[x], NodeOutput[y],z)endifp = p + 1while (p < L)384
Point mutationMost <strong>CGP</strong> implementations only use mutation.Carrying out mutation <strong>is</strong> very simple. It cons<strong>is</strong>ts of the following steps.The genes must be chosen <strong>to</strong> be valid alleles//Decide how many genes <strong>to</strong> change:num_mutationswhile (mutation_counter < num_mutations){get gene <strong>to</strong> changeif (gene <strong>is</strong> a function gene)change gene <strong>to</strong> randomly chosen new valid functionelse if (gene <strong>is</strong> a connection gene)change gene <strong>to</strong> a randomly chosen new valid connectionelsechange gene <strong>to</strong> a new valid output connection}9Genotypes are evolved with anEvolutionary Strategy<strong>CGP</strong> of<strong>ten</strong> uses a variant of a simple algorithm called(1 + 4) Evolutionary Strategy• However, an offspring <strong>is</strong> always chosen if it <strong>is</strong> equally as fi<strong>to</strong>r has better fitness than the parent (most important)10