20
Investigation of the Investigation of the Effect of Neutrality Effect of Neutrality on the Evolution of on the Evolution of Digital Circuits. Digital Circuits. Eoin O’Grady Eoin O’Grady Final year Electronic and Final year Electronic and Computer Engineering Computer Engineering Project. Project.

Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

Embed Size (px)

Citation preview

Page 1: Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

Investigation of the Effect of Investigation of the Effect of Neutrality on the Evolution Neutrality on the Evolution

of Digital Circuits. of Digital Circuits.

Eoin O’GradyEoin O’Grady

Final year Electronic and Final year Electronic and Computer EngineeringComputer Engineering

Project.Project.

Page 2: Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

Project GoalsProject Goals Design and create a Design and create a Genetic AlgorithmGenetic Algorithm capable of capable of

implementing implementing Cartesian Genetic Programming Cartesian Genetic Programming ((evolution of evolution of Digital Logic CircuitsDigital Logic Circuits).).

To study and analyse the concept of To study and analyse the concept of Neutrality Neutrality inin Genetic Genetic AlgorithmsAlgorithms..

To develop an explicit To develop an explicit Neutral Mutation Operator.Neutral Mutation Operator. To implement this To implement this Neutral Mutation OperatorNeutral Mutation Operator with with

Cartesian Genetic ProgrammingCartesian Genetic Programming to evolve complex to evolve complex Digital Logic Circuits. Digital Logic Circuits.

Page 3: Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

Genetic Algorithms and EvolutionGenetic Algorithms and Evolution

Genetic Algorithms are search algorithms based on the mechanics of Genetic Algorithms are search algorithms based on the mechanics of natural selection and natural genetics. natural selection and natural genetics.

They combine survival of the fittest among string structures and with a They combine survival of the fittest among string structures and with a structured yet randomized information exchange to form a search structured yet randomized information exchange to form a search algorithm.algorithm.

In every generation a new set of artificial creatures (strings) is created In every generation a new set of artificial creatures (strings) is created using the parts of the fittest members of the previous generation, with an using the parts of the fittest members of the previous generation, with an occasional new part (mutation) thrown in to ensure the population doesn't occasional new part (mutation) thrown in to ensure the population doesn't become homogenized. become homogenized.

There are four basic operations within Genetic Algorithms they are There are four basic operations within Genetic Algorithms they are evaluation, selection, crossover and mutation.evaluation, selection, crossover and mutation.

Page 4: Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

Genetic Algorithms and EvolutionGenetic Algorithms and Evolution

EvaluationEvaluation When every new population is created each member is evaluated for it’s When every new population is created each member is evaluated for it’s

fitness by testing for some attribute.fitness by testing for some attribute.

SelectionSelection Individuals are selected at random in groups after they are evaluated for Individuals are selected at random in groups after they are evaluated for

their fitness and the individuals with the highest fitness within these groups their fitness and the individuals with the highest fitness within these groups are used to populate the new generation.are used to populate the new generation.

Member[0] fitness=4

1 0 0 1 1 0 0 1

Member[1] fitness=7

1 0 1 1 1 1 1 1

Member[2] fitness=7 Member[7] fitness=5

Member[8] fitness=6 Member[5] fitness=4

Member[2] fitness=7 Member[7] fitness=5

Page 5: Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

Genetic Algorithms and EvolutionGenetic Algorithms and EvolutionCrossoverCrossover

Crossover is used to produce the new members of a population a point is Crossover is used to produce the new members of a population a point is chosen at random on a chromosome where it will be split and joined with chosen at random on a chromosome where it will be split and joined with the other half of another chromosome split at the same point.the other half of another chromosome split at the same point.

MutationMutation Mutation occurs to some of the genes in the new population. A point is Mutation occurs to some of the genes in the new population. A point is

picked at random within a chromosome and the mutation that occurs is picked at random within a chromosome and the mutation that occurs is random.random.

Member[2] fitness=7

1 1 1 1 1 1 0 1

Member[1] fitness=5

0 0 0 1 1 1 1 1

NewMember[0] fitness=8

1 1 1 1 1 1 1 1

NewMember[0] fitness=8

1 1 1 1 1 1 1 1

NewMember[0] fitness=8

1 1 1 1 0 1 1 1

Page 6: Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

Cartesian Genetic ProgrammingCartesian Genetic Programming CGP is an advanced implementation of Genetic algorithms created by CGP is an advanced implementation of Genetic algorithms created by

Julian miller and allows solutions to more complicated problems to be Julian miller and allows solutions to more complicated problems to be evolved (usually digital logical problems).evolved (usually digital logical problems).

In CGP the individual genes of a genotype (chromosome) consist of more In CGP the individual genes of a genotype (chromosome) consist of more than a single integer value. Typically they have multiple values that than a single integer value. Typically they have multiple values that represent inputs and a single value that represents an operation.represent inputs and a single value that represents an operation.

The GenotypeThe Genotype The genotype is made up of many genes which all together represent a The genotype is made up of many genes which all together represent a

system.system.

A C -3 B 1 0B D 0B D -3 A C 0 D 1 0 1 2 -30 0 0 5 6 -13 4 -1

Genes

Page 7: Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

Cartesian Genetic ProgrammingCartesian Genetic Programming

The Phenotype The Phenotype When the data contained in the genotype is converted to simulate the system When the data contained in the genotype is converted to simulate the system

described within it becomes known as the phenotype and the genes within are known described within it becomes known as the phenotype and the genes within are known as cells.as cells.

A

B

C

D

A C -3 B 1 0B D 0B D -3 A C 0 D 1 0 1 2 -30 0 0 5 6 -13 4 -1

Page 8: Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

Cartesian Genetic ProgrammingCartesian Genetic Programming

Evolving the GenotypeEvolving the Genotype A population of genotype is evolved in exactly the same way as a normal A population of genotype is evolved in exactly the same way as a normal

genetic algorithm with evaluation, selection, crossover and mutation. genetic algorithm with evaluation, selection, crossover and mutation. When evaluating each genotype it must be first mapped to it’s phenotype. When evaluating each genotype it must be first mapped to it’s phenotype. Then all permutations of the inputs are applied and then each cell output is Then all permutations of the inputs are applied and then each cell output is

tested against a truth table of the desired outputs. The most suitable cells tested against a truth table of the desired outputs. The most suitable cells for output are used to define the genotype’s fitness.for output are used to define the genotype’s fitness.

Page 9: Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

NeutralityNeutrality Neutrality is the concept that when trying achieve a better solution of any Neutrality is the concept that when trying achieve a better solution of any

classification that by first pursuing a change in the solution which does not classification that by first pursuing a change in the solution which does not make the solution better that eventually this will help the solution to find a make the solution better that eventually this will help the solution to find a change that will increase it’s fitness.change that will increase it’s fitness.

For any Search Algorithm, in particular Genetic Algorithms, that relies on a For any Search Algorithm, in particular Genetic Algorithms, that relies on a cost function, i.e. calculation of fitness, to determine it’s next area of cost function, i.e. calculation of fitness, to determine it’s next area of search on a fitness landscape there are areas where there will be no local search on a fitness landscape there are areas where there will be no local path along which the search algorithm will find an area of higher fitness. path along which the search algorithm will find an area of higher fitness.

Fitn

ess

Solution Spectrum

Fitn

ess

Solution Spectrum

Page 10: Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

The Fitness LandscapeThe Fitness Landscape The term Fitness Landscape is used when describing any evolutionary The term Fitness Landscape is used when describing any evolutionary

process, be it biological, technological or digital, to describe a landscape process, be it biological, technological or digital, to describe a landscape which is drawn along the spectrum of possible “solutions” for a given which is drawn along the spectrum of possible “solutions” for a given problem. problem.

In GA the landscape is arranged such that each neighbouring solution is In GA the landscape is arranged such that each neighbouring solution is just one mutation different from it’s neighbour and the height of this just one mutation different from it’s neighbour and the height of this landscape corresponds to the suitability i.e. the fitness level for a given landscape corresponds to the suitability i.e. the fitness level for a given solution.solution.

The horizontal distance between two points is an inverse measure of The horizontal distance between two points is an inverse measure of probability of mutationprobability of mutation

Fitness landscape for Sinc(x) where x=5-bit signed binary String

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

1.2

Solution spectrum

Fit

ne

ss

lev

el

Page 11: Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

Neutrality on a Fitness LandscapeNeutrality on a Fitness Landscape Neutrality in the context of fitness landscapes and genetic algorithms Neutrality in the context of fitness landscapes and genetic algorithms

refers to effect of changing a solution’s description or chromosome in some refers to effect of changing a solution’s description or chromosome in some way so that it’s fitness level is unchanged by the change in the way so that it’s fitness level is unchanged by the change in the chromosome.chromosome.

A neutral mutation is the implementation of neutrality on a fitness A neutral mutation is the implementation of neutrality on a fitness landscape. landscape.

If a genetic algorithm is stuck on a peak which is not the global maximum If a genetic algorithm is stuck on a peak which is not the global maximum of fitness landscape then a neutral mutation (a mutation which is intended of fitness landscape then a neutral mutation (a mutation which is intended to mutate the current solution so that we get another with equal or greater to mutate the current solution so that we get another with equal or greater fitness). fitness).

Fitn

ess

Solution Spectrum

Neutral Mutation

Fitn

ess

Solution Spectrum

Neutral Mutation

Page 12: Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

The N-K ModelThe N-K Model In the N-K model there are N distinct processes (cardinality of a gene) that In the N-K model there are N distinct processes (cardinality of a gene) that

exist in S amount of different states (length of chromosome). Therefore exist in S amount of different states (length of chromosome). Therefore there are S to the power of N possible solutions.there are S to the power of N possible solutions.

In the NK–model each process makes a contribution to the overall In the NK–model each process makes a contribution to the overall performance of the solution that depends on it’s own type and the types of performance of the solution that depends on it’s own type and the types of K other solutions. Therefore K<=N-1. K other solutions. Therefore K<=N-1.

K determines the correlation of the landscape that is when K=0 the K determines the correlation of the landscape that is when K=0 the correlation is high and the fitness landscape has a single smooth sided correlation is high and the fitness landscape has a single smooth sided peak. peak.

As K increases the ruggedness also increases and when K=N-1 the fitness As K increases the ruggedness also increases and when K=N-1 the fitness landscape is at it’s most rugged.landscape is at it’s most rugged.

The correlation coefficient is calculated by (Weinberger, 1990; Fontana et The correlation coefficient is calculated by (Weinberger, 1990; Fontana et al., 1993):al., 1993):

ρ(d)=[1-d/N][1-K/(N-1)]^d ρ(d)=[1-d/N][1-K/(N-1)]^d

and thus for d=1 and large N, K=0 implies ρ(1)≈1 and K=N-1 has ρ(N)=0and thus for d=1 and large N, K=0 implies ρ(1)≈1 and K=N-1 has ρ(N)=0

Page 13: Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

Neutrality using the N-K ModelNeutrality using the N-K Model To investigate further the effect of neutrality on the N-k model we must To investigate further the effect of neutrality on the N-k model we must

now impose a new operator M which will split the fitness landscape into M now impose a new operator M which will split the fitness landscape into M number of layers through which a population will be allowed to freely and number of layers through which a population will be allowed to freely and randomly travelrandomly travel

Page 14: Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

Intrinsic Neutral Mutation in Intrinsic Neutral Mutation in Genetic AlgorithmsGenetic Algorithms

Neutral Mutation occurs ‘naturally’ in Genetic Algorithms. Neutral Mutation occurs ‘naturally’ in Genetic Algorithms. Example:Example:

3,1,0;0,2,-2;1,3,-3;4,1,0;0,2,0;1,8,-2;8,6,-3;4,0,-1;4,8,-1;2,0,-3,1,0;0,2,-2;1,3,-3;4,1,0;0,2,0;1,8,-2;8,6,-3;4,0,-1;4,8,-1;2,0,-3;3; 47.047.0 13;10;12;13;10;12; (From generation 70)(From generation 70)

3,1,0;4,2,-3;1,3,-3;2,1,0;0,2,0;6,8,-3;7,6,-3;1,7,0;4,8,-1;2,0,-3;3,1,0;4,2,-3;1,3,-3;2,1,0;0,2,0;6,8,-3;7,6,-3;1,7,0;4,8,-1;2,0,-3;47.047.0 13;9;12;13;9;12; (From generation 81)(From generation 81)

3,1,0;1,2,-3;1,3,-3;6,1,-3;0,2,0;6,8,-3;8,6,0;10,4,-1;4,8,-1;2,0,-3,1,0;1,2,-3;1,3,-3;6,1,-3;0,2,0;6,8,-3;8,6,0;10,4,-1;4,8,-1;2,0,-3;3; 48.048.0 13;9;11;13;9;11; (From generation 83)(From generation 83)

Possible Mutations

F I t n e s s

Page 15: Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

The effects of intrinsic neutral The effects of intrinsic neutral mutationmutation

Problems arise for intrinsic neutral mutations when a population has Problems arise for intrinsic neutral mutations when a population has converged on a large neutral plateau. converged on a large neutral plateau.

Possible Mutations

Fit

ness

Possible Mutations

Fit

ness

After many generations

Page 16: Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

The effects of Explicit Neutral The effects of Explicit Neutral MutationMutation

For the scenario that a population has evolved on a peak:For the scenario that a population has evolved on a peak:

Possible Mutations

Fit

ness

Page 17: Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

The effects of Explicit Neutral The effects of Explicit Neutral MutationMutation

For the scenario that a population has converged on a plateau:For the scenario that a population has converged on a plateau:

Possible Mutations

Fit

ne

ss

Possible Mutations

Fit

ne

ss

Possible Mutations

Fit

ne

ss

Possible Mutations

Fit

ne

ss

After several neutral mutations

Page 18: Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

Neutral Mutation on a Known Neutral Mutation on a Known Fitness LandscapeFitness Landscape

In order to properly develop and implement a neutral mutation operator for In order to properly develop and implement a neutral mutation operator for use on a fitness landscape that was complex, extremely rugged, incredibly use on a fitness landscape that was complex, extremely rugged, incredibly large and above all unknown, it was necessary to first develop a method of large and above all unknown, it was necessary to first develop a method of implementing it on a landscape that was known.implementing it on a landscape that was known.

A GA was programmed to find the global maximum for the mathematical A GA was programmed to find the global maximum for the mathematical function Sinc(x+y).function Sinc(x+y).

Page 19: Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

Neutral Mutation on a Known Neutral Mutation on a Known Fitness LandscapeFitness Landscape

The GA used a Neutral Mutation Operator which kicked in whenever the The GA used a Neutral Mutation Operator which kicked in whenever the population was converged on a peak/plateau.population was converged on a peak/plateau.

The gene structure took the form of binary values with a total chromosome The gene structure took the form of binary values with a total chromosome length of 18, 9 genes each for x and y.length of 18, 9 genes each for x and y.

One gene was for the sign of the integer four made up the values greater One gene was for the sign of the integer four made up the values greater than zero and four were values less than zero (i.e. down to 2-4 which gave than zero and four were values less than zero (i.e. down to 2-4 which gave a total range of -15.9375 to 15.9375). a total range of -15.9375 to 15.9375).

These integer values were then used to calculate the fitness by the These integer values were then used to calculate the fitness by the equation:equation:

Fitness=Fitness=Sin(√(x^2 +y^2)Sin(√(x^2 +y^2)

√ √(x^2 +y^2)(x^2 +y^2)

Page 20: Investigation of the Effect of Neutrality on the Evolution of Digital Circuits. Eoin O’Grady Final year Electronic and Computer Engineering Project

Project MilestonesProject Milestones 1.1. Research Genetic Algorithms and Cartesian Genetic Programming Research Genetic Algorithms and Cartesian Genetic Programming

particularly the work of Julian Miller.particularly the work of Julian Miller. 2.2. Start working with basic GA software (in the form of Java classes) Start working with basic GA software (in the form of Java classes)

and set conditions to solve basic one max GA once classes are and set conditions to solve basic one max GA once classes are compiled and evolve successfullycompiled and evolve successfully

3.3. Design and implement a CGP simulator which when passed a Design and implement a CGP simulator which when passed a genetic genetic algorithm will synthesis a basic logic operator circuit and produce algorithm will synthesis a basic logic operator circuit and produce

outputs for each genotype.outputs for each genotype. 4.4. Create a suitable method for displaying a CGP Genotype as a Create a suitable method for displaying a CGP Genotype as a

basic basic logic circuit (the CGP grid with Cells).logic circuit (the CGP grid with Cells). 5.5. Use this simulator with the Genetic Algorithm software to evolve a Use this simulator with the Genetic Algorithm software to evolve a

2-2- bit adder and other simple circuits.bit adder and other simple circuits. 6.6. Research Neutrality and then experiment with different methods Research Neutrality and then experiment with different methods

to to design and implement a neutral mutation operator.design and implement a neutral mutation operator. 7.7. Evolve a more complicated circuit such as a 3-bit multiplier using Evolve a more complicated circuit such as a 3-bit multiplier using

the the neutral mutation operator with the GA software and CGP neutral mutation operator with the GA software and CGP simulator.simulator.

8.8. Using JBits (a Java API) design a new evolvable circuit to Using JBits (a Java API) design a new evolvable circuit to instantiate instantiate the CGP model of a basic logical circuit on an FPGA.the CGP model of a basic logical circuit on an FPGA.

9.9. Design fault injection method and determine methods to handle Design fault injection method and determine methods to handle these faults i.e. To be able to pull the outputs from different nodes these faults i.e. To be able to pull the outputs from different nodes on the FPGA board in order to get an output of similar fitness.on the FPGA board in order to get an output of similar fitness.