Genetic Algorithm Lecture

81
Shahid Beheshti University of Tehran Presented by: Genetic Algorithm Requirements : …. +98 21 897 882 08 kourosh.eghbalpour Hamid Eghbalpour [email protected] [email protected] https://sbu-ir.academia.edu/HEghbalpour

Transcript of Genetic Algorithm Lecture

Shahid Beheshti University of Tehran

Presented by:

Genetic AlgorithmRequirements : ….

+98 21 897 882 08kourosh.eghbalpour

Hamid Eghbalpour

[email protected]@IEEE.org

https://sbu-ir.academia.edu/HEghbalpour

Charles Darwin 1809 - 1882

"A man who dares to waste an hour of life has not discovered the value of life"

Genetic algorithms are a part of evolutionary computing, which is a rapidly growing area of artificial intelligence.

As you can guess, genetic algorithms are inspired by Darwin's theory of evolution. Simply said, problems are solved by an evolutionary processresulting in a best (fittest) solution (survivor) - in other words, the solution is evolved.

Genetic algorithms

Life on earth has evolved to be as it is through the processes of natural selection, recombination and mutation.

Evolutionary computing was introduced in the 1960s by I. Rechenbergin his work "Evolution strategies" (Evolutions strategy in original). His idea was then developed by other researchers. Genetic Algorithms(GAs) were invented by John Holland and developed by him and his students and colleagues. This lead to Holland's book "Adaption in Natural and Artificial Systems" published in 1975.

In 1992 John Koza has used genetic algorithm to evolve programs to perform certain tasks. He called his method "genetic programming" (GP). LISP programs were used, because programs in this language can expressed in the form of a "parse tree", which is the object the GA works on.

History

Biological Background : The cell

• Every animal cell is a complex of many small “factories” working together

• The center of this all is the cell nucleus• The nucleus contains the genetic information

• Genetic information is stored in the chromosomes• Each chromosome is build of DNA• Chromosomes in humans form pairs• There are 23 pairs• The chromosome is divided in parts: genes• Genes code for properties• The possibilities of the genes for

one property is called: allele• Every gene has an unique position

on the chromosome: locus

Biological Background : Chromosomes

Every organism has a set of rules, describing how that organism is built up from the tiny building blocks of life.These rules are encoded in the genes of an organism, which in turn are connected together into long strings called chromosomes.Each gene represents a specific characteristic of the organism, like eye color or hair color, and has several different settings. For example, the settings for a hair color gene may be blonde or black. These genes and their settings are usually referred to as an organism's genotype. The physical expression of the genotype - the organism itself - is called the phenotype.When two organisms mate they share their genes. The resultant offspring may end up having half the genes from one parent and half from the other. This process is called recombination. Very occasionally a gene may be mutated. Normally this mutated gene will not affect the development of the phenotype but very occasionally it will be expressed in the organism as a completely new characteristic .

Genetic algorithms

What Are Genetic Algorithms?

► A way to employ evolution in the computer

► Search and optimization technique based on variation and selection

Encoding of chromosomes is the first question to ask when starting to solve a problem with GA. Encoding depends on the problem heavily.

This could be as a string of real numbers or, as is more typically the case, a binary bit string.

Binary EncodingBinary encoding is the most common one, mainly because the first research of GA used this type of encoding and because of its relative simplicity. In binary encoding, every chromosome is a string of bits 0 or 1.

Chromosome A 101100101100101011100101Chromosome B 111111100000110000011111

Components of Genetic algorithms : Encoding

1 0 1 1 0 1 0 0 0 1 0 1 1

Size Shape Speed

Chromosome A

1 1 1 0 0 1 1 0 0 0 1 10 1

Size Shape Speed

Chromosome B

x y z

0 1 10 1 0 0 1 1 0 1 0 0 1Chromosome A

1 1 1 1 0 1 0 1 1 1 0 1 0

x y z

0 0Chromosome B

Solutions are coded as “chromosomes”

Components of Genetic algorithms : Encoding

1

Given the digits 0 through 9 and the operators +, -, * and /, find a sequence that will represent a given target number. The operators will be applied sequentially from left to right as you read.

So, given the target number 23, the sequence 6+5*4/2+1 would be one possible solution.If 75.5 is the chosen number then 5/2+9*7-5 would be a possible solution.

First we need to encode a possible solution as a string of bits… a chromosome.So how do we do this? Well, first we need to represent all the different characters available to the solution... that is 0 through 9 and +, -, * and /. This will represent a gene. Each chromosome will be made up of several genes.

Components of Genetic algorithms : Encoding

Four bits are required to represent the range of characters used:

0: 00001: 00012: 00103: 00114: 01005: 01016: 01107: 01118: 10009: 1001+: 1010-: 1011*: 1100/: 1101

The possible genes 1110 & 1111 will remain unused and will be ignored by the algorithm if encountered.

So now you can see that the solution mentioned above for 23, ' 6+5*4/2+1' would be represented by nine genes like so:

0110 1010 0101 1100 0100 1101 0010 1010 00016 + 5 * 4 / 2 + 1

These genes are all strung together to form the chromosome:

011010100101110001001101001010100001

Components of Genetic algorithms : Encoding

A Quick Word about Decoding

Because the algorithm deals with random arrangements of bits it is often going to come across a string of bits like this:

0010001010101110101101110010

Decoded, these bits represent:

0010 0010 1010 1110 1011 0111 00102 2 + n/a - 7 2

Which is meaningless in the context of this problem! Therefore, when decoding, the algorithm will just ignore any genes which don’t conform to the expected pattern of: number -> operator -> number -> operator …and so on. With this in mind the above ‘nonsense’ chromosome is read (and tested) as:

0010 0010 1010 1110 1011 0111 00102 2 + n/a - 7 2

2 + 7

Components of Genetic algorithms : Decoding

0010 1010 0011 1100 0101 1010 01102 + 3 * 5 + 6

Components of Genetic algorithms : Decoding

0:00

001:

00012:

00103:

00114:

01005:

01016:

01107:

0111

=30

1000 1100 0011 1101 0011 1010 00108 * 3 / 3 + 2

=10

0111 1010 0100 1011 0001 1101 0010? ? ? ? ? ? ?

=?

Permutation encoding can be used in ordering problems, such as travelling salesman problem or task ordering problem. In permutation encoding, every chromosome is a string of numbers that represent a position in a sequence.

Chromosome A

1 5 3 2 6 4 7 9 8

Chromosome B

8 5 6 7 2 3 1 4 9Example of chromosomes with permutation encoding

Permutation encoding is useful for ordering problems. For some types of crossover and mutation corrections must be made to leave the chromosome consistent (i.e. have real sequence in it) for some problems.

Example of Problem: Travelling salesman problem (TSP)The problem: There are cities and given distances between them. Travelling salesman has to visit all of them, but he does not want to travel more than necessary. Find a sequence of cities with a minimal travelled distance. Encoding: Chromosome describes the order of cities, in which the salesman will visit them

Components of Genetic algorithms :Permutation Encoding

Direct value encoding can be used in problems where some more complicated values such as real numbers are used. Use of binary encoding for this type of problems would be difficult. In the value encoding, every chromosome is a sequence of some values. Values can be anything connected to the problem, such as (real) numbers, chars or any objects.

Chromosome A

1.2324 5.3243 0.4556 2.3293 2.4545

Chromosome B ABDJEIFJDHDIERJFDLDFLFEGT

Chromosome C (back), (back), (right), (forward), (left)

Example of chromosomes with value encodingValue encoding is a good choice for some special problems. However, for this encoding it is often necessary to develop some new crossover and mutation specific for the problem.

Example of Problem: Finding weights for a neural networkThe problem: A neural network is given with defined architecture. Find weights between neurons in the neural network to get the desired output from the network.Encoding: Real values in chromosomes represent weights in the neural network.

Components of Genetic algorithms :

Value Encoding

Crossover and Mutation

► Crossover: Operate on selected parent chromosomes to create new offspring.

► Mutation: Randomly changes the offspring resulted from crossover to prevent falling of all solutions into a local optimum.

Crossover

1010000000

1011011111

Crossover: single point - random

1011011111

1010000000

Parent1

Parent2

Offspring1

Offspring2

Crossover

parent 1

1 1 0 1 0

1 0 0 0 1

offspring 1 1 1 0 0

1 0 0 1

0

1parent 2

offspring 2

Crossover: two-point - random

Crossover► Assign 'heads' to one parent, 'tails' to the other► Flip a coin for each gene of the first child► Make an inverse copy of the gene for the second child► Inheritance is independent of position

Crossover: Uniform

§ Parent 1: 000000000000000000§ Parent 2: 111111111111111111§ Offspring 1: 010010110001011001§ Offspring 2: 101101001110100110

Single arithmetic crossover• Parents: ⟨x1,…,xn ⟩ and ⟨y1,…,yn⟩• Pick a single gene (k) at random, • child1 is:

• reverse for other child. e.g. with α = 0.8

Crossover

nkkk xxyxx ..., ,)1( , ..., ,1 ⋅−+⋅ αα

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9

0.3 0.1 0.4 0.5 0.3 0.2 0.6 0.6 0.3

Parent 1:

Parent 2:

Offspring 1:

Offspring 1:

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.6 0.96.064.016.048.08.0)8.01(6.08.0 ≈=+=−+×

0.3 0.1 0.4 0.5 0.3 0.2 0.6 0.8 0.38.076.012.064.06.0)8.01(8.08.0 ≈=+=−+×

• Parents: ⟨x1,…,xn ⟩ and ⟨y1,…,yn⟩• Pick random gene (k) after this point mix values

child1 is:

• reverse for other child. e.g. with α = 0.8

CrossoverSimple arithmetic crossover

nxkxkykxx ⋅−+⋅+⋅−++⋅ )1(ny ..., ,1)1(1 , ..., ,1 αααα

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9

0.3 0.1 0.4 0.5 0.3 0.2 0.6 0.6 0.3

Parent 1:

Parent 2:

Offspring 1:

Offspring 1:

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.6 0.4

6.064.016.048.08.0)8.01(6.08.0 ≈=+=−+×

0.3 0.1 0.4 0.5 0.3 0.2 0.6 0.8 0.8

8.076.012.064.06.0)8.01(8.08.0 ≈=+=−+×

4.042.018.024.09.0)8.01(3.08.0 ≈=+=−+×

8.078.006.072.03.0)8.01(9.08.0 ≈=+=−+×

None - no crossover, offspring is exact copy of parents

Crossover

Mutation

1011011111

1010000000

Offspring1

Offspring2

1011001111

1000000000

Offspring1

Offspring2

With some small probability (the mutation rate) flip each bit in the offspring (typical values between 0.1 and 0.001)

mutated

Original offspring Mutated offspring

Adding Mutation: a small number (for real value encoding) is added to (subtracted from) selected values

(1.29 5.68 2.86 4.11 5.55) => (1.29 5.68 2.73 4.22 5.55)

Mutation

Order changing mutation - two numbers are selected and exchanged (1 2 3 4 5 6 8 9 7) => (1 8 3 4 5 6 2 9 7)

Components of Genetic algorithms : Create initial population (usually random)

1 101100101100101011100101010100110110010110010101110

2 001000101100101011100101010111110110010110000101110

3 001000101100111111100101110111000010010110000101110

4 100000101100101011101111110100110110010000010101110

5 111111111100101011100101011111110110010110010111111

6 001000101100111111111111111000110010010110000101110

7 100000101001100111110010101110111111010011011001001

8 111111111110000000001111101111110100110111111101000

9 000000000000000000000000000000001111111101010101011

10 000000000110011100001010101010100000000000011111111

11 000110110110111100001010101010100000000000011110101

12 111110000110011100001010101010100011111000000000100

Simple example of Genetic optimization

The chosen problem is to minimize the value of a string of 1’s and 0’s as a binary number. While this is a trivial problem, it will serve to illustrate the operation of the algorithm without the obscuring effects of a complicated objective function.

The genetic algorithm performs minimization in the following steps:

1. A random population of chromosomes are generated.2. The fitness function is applied to each chromosome.3. The selection operation is applied favoring the fittest chromosomes.4. The crossover operation is applied on the selected pairs to generate a new population.5. Mutation is applied to some offspring6. Repeat steps 2-5

Components of Genetic algorithms :Selection of parents ( reproduction)

In this step the current population is used to produce a second generation of population that, on the average, have a higher objective function.

Selection replicates the most successful solutions found in a population at a rate proportional to their relative quality.

J chromosome

number

Binary chromosome

Decimal value

Oj = 1/(decimal value)Objective function

Fj =Oj / (Total Oj)Fraction of Total

1 011010 26 0.0385 0.1422 001011 11 0.0909 0.3343 110110 54 0.0185 0.0684 010011 19 0.0526 0.1945 100111 39 0.0256 0.0946 010110 22 0.0455 0.168Total 0.2717 1

Components of Genetic algorithms :Selection of parents ( reproduction)

J chromosome

number

Binary chromosome

Decimal value

Oj = 1/(decimal value)Objective function

Fj =Oj / (Total Oj)Fraction of Total

Round (Fj*6)=Copy number

1 011010 26 0.0385 0.142 1

2 001011 11 0.0909 0.334 2

3 110110 54 0.0185 0.068 04 010011 19 0.0526 0.194 15 100111 39 0.0256 0.094 16 010110 22 0.0455 0.168 1

Total 0.2717 1

0.142, 14%

0.334, 34%

0.068, 7%

0.194, 19%

0.094, 9%

0.168, 17%

001011

011010

110110

010011

100111

010110

In the reproduction phase, each chromosome is copied to the second generation a number of times that is proportional to its fractional objective function Fj.

Selected population

011010

001011

001011

010011

100111

010110 Area is Proportional to fitness value

Recombination decomposes two distinct solutions (chromosomes) and then randomly mixes their parts to form novel solutions (chromosomes) .This process is intended to simulate the exchange of genetic material that occurs during biological reproduction. Here, pairs in the breeding population are mated randomly. For simplicity we will mate adjacent pairs. For each pair, a random integer from 1-6 (1- length of chromosome) is chosen. This indicates how many bits on the right end of each chromosome should be exchanged between the two mated chromosomes.

Components of Genetic algorithms :Crossover (Recombination)

sP1 = 011010

sP2 = 001011

Before crossover:

After crossover:sC1 = 011011

sC2 = 001010

sP3 = 001011

sP4 = 010011

sP5 = 100111

sP6 = 010110

sC3 = 000011

sC4 = 011011sC5 = 100110

sC6 = 010111

Components of Genetic algorithms :Mutation

A surprisingly small role is played by mutation. Biologically, it randomly perturbs thepopulation’s characteristics, thereby preventing evolutionary dead ends. Most mutations are damaging rather than beneficial; therefore, rates must be low to avoid the destruction of species. In the simulation we will assume a mutation rate of on bit per thousand, where a mutation acts to reverse the value of single bit. Since we have only 36 bits in our population, the probability of a mutation is only 0.036; therefore, no bits are reversed in the simulation. By mutation, algorithm explores parts of the space that crossover might miss, and helps prevent premature convergence.

1 1 0 1 1 0 1 1 0 1 0 1 1 1 0 0

1 1 0 1 1 0 1 0 0 1 0 1 1 1 0 0

Before

After

Components of Genetic algorithms :Crossover (Recombination)

J chromosome

number

Binary chromosome

Decimal value

Oj = 1/(decimal value)Objective function

Fj =Oj / (Total Oj)Fraction of Total

1 011011 27 0.037 0.0642 001010 10 0.10 0.1743 000011 3 0.333 0.5784 011011 27 0.037 0.0645 100110 38 0.0263 0.0466 010111 23 0.043 0.075Total 0.576 1

After One Generation

0.064, 6%

0.174, 17%

0.578, 59%

0.064, 6%

0.046, 5%

0.075, 7%

000011

001010

011011

100111

010111 01101

1

Components of Genetic algorithms :Selection of parents ( reproduction)

J chromosome

number

Binary chromosome

Decimal value

Oj = 1/(decimal value)Objective function

Fj =Oj / (Total Oj)Fraction of Total

Round (Fj*6)=Copy number

1 011011 27 0.037 0.064 0

2 001010 10 0.10 0.174 1

3 000011 3 0.333 0.578 4

4 011011 27 0.037 0.064 0

5 100110 38 0.0263 0.046 0

6 010111 23 0.043 0.075 1

Total 0.576 1

In the reproduction phase, each chromosome is copied to the second generation a number of times that is proportional to its fractional objective function Fj.

Selected population

001010000011000011000011000011010111

Area is Proportional to fitness value

Components of Genetic algorithms :Crossover (Recombination)

sP1 = 001010

sP2 = 000011

Before crossover:

After crossover:sC1 = 001011

sC2 = 000010

sP3 = 000011

sP4 = 000011

sP5 = 000011

sP6 = 010111

sC3 = 000011

sC4 = 000011sC5 = 000011

sC6 = 010111

Components of Genetic algorithms :Crossover (Recombination)

J chromosome

number

Binary chromosome

Decimal value

Oj = 1/(decimal value)Objective function

Fj =Oj / (Total Oj)Fraction of Total

1 001011 11 0.091 0.05572 000010 2 0.5 0.3063 000011 3 0.333 0.2044 000011 3 0.333 0.2045 000011 3 0.333 0.2046 010111 23 0.043 0.026Total 1.633 1

After Two Generation

0.0557, 6%

0.306, 31%

0.204, 20%

0.204, 20%

0.204, 20%

0.026, 3%

Components of Genetic algorithms :Selection of parents ( reproduction)

J chromosome

number

Binary chromosome

Decimal value

Oj = 1/(decimal value)Objective function

Fj =Oj / (Total Oj)Fraction of Total

Round (Fj*6)=Copy number

1 001011 11 0.091 0.0557 0

2 000010 2 0.5 0.306 2

3 000011 3 0.333 0.204 1

4 000011 3 0.333 0.204 1

5 000011 3 0.333 0.204 1

6 010111 23 0.043 0.026 0

Total 1.633 1

In the reproduction phase, each chromosome is copied to the second generation a number of times that is proportional to its fractional objective function Fj.

Selected population

000010000010000011000011000011000011

Area is Proportional to fitness value

Components of Genetic algorithms :Crossover (Recombination)

sP1 = 000010

sP2 = 000010

Before crossover:

After crossover:sC1 = 000010

sC2 = 000010

sP3 = 000011

sP4 = 000011

sP5 = 000011

sP6 = 000011

sC3 = 000011

sC4 = 000011sC5 = 000011

sC6 = 000011

Components of Genetic algorithms :Crossover (Recombination)

J chromosome

number

Binary chromosome

Decimal value

Oj = 1/(decimal value)Objective function

Fj =Oj / (Total Oj)Fraction of Total

1 000010 2 0.5 0.2142 000010 2 0.5 0.2143 000011 3 0.333 0.1434 000011 3 0.333 0.1435 000011 3 0.333 0.1436 000011 3 0.333 0.143Total 16 2.332 1

After Three Generation

The Evolutionary Cycle

Create initial random population

Evaluate fitness of each individual

Termination criteria satisfied ?

Select parents according to fitness

Recombine parents to generate offspring

Mutate offspring

Replace population by new offspring

stopyes

no

Example: the MAXONE problemSuppose we want to maximize the number of ones in a string of l binary digits

Is it a trivial problem?It may seem so because we know the answer in advance

► An individual is encoded (naturally) as a string of l binary digits

► The fitness f of a candidate solution to the MAXONE problem is the number of ones in its genetic code

► We start with a population of n random strings. Suppose that l = 10 and n = 6

J chromosome

number

Binary chromosome

Oj = number of onesObjective function

Fj =Oj / (Total Oj)Fraction of Total

1 1111010101 7 0.2062 0111000101 5 0.1473 1110110101 7 0.2064 0100010011 4 0.1185 1110111101 8 0.2356 0100110000 3 0.088Total 34 1

Genetic algorithms : Example (initialization)the MAXONE problem

Genetic algorithms :Selection of parents ( reproduction)

J chromosome

number

Binary chromosome

Oj = 1/(decimal value)Objective function

Fj =Oj / (Total Oj)Fraction of Total

Round (Fj*6)=Copy number

1 1111010101 7 0.206 1

2 0111000101 5 0.147 1

3 1110110101 7 0.206 14 0100010011 4 0.118 15 1110111101 8 0.235 16 0100110000 3 0.088 0

Total 34 1

Selected population

111101010101110001011110110101010001001111101111011110111101

Next we mate strings for crossover. For each couple we decide according to crossover probability (for instance 0.6) whether to actually perform crossover or not.

Suppose that we decide to actually perform crossover only for couples (s1`, s2`) and (s5`, s6`). For each couple, we randomly extract a crossover point, for instance 2 for the first and 5 for the second

Genetic algorithms : Example (crossover1)the MAXONE problem

sP1 = 1111010101

sP3 = 1110110101

sp4 = 0100010011

sP5 = 1110111101

Before crossover:

After crossover:sC1 = 1110110101

sC3 = 1111010101

sC4 = 0100011101

sC5 = 1110110011

Genetic algorithms : Example (crossover 2)the MAXONE problem

Modified population

111011010101110001011111010101010001110111101100111110111101

Before applying mutation: After applying mutation:Modified

population

111010010101110001011111110100010001110111101100011110101111

The final step is to apply random mutation: for each bit that we are to copy to the new population we allow a small probability of error (for instance 0.1)

Genetic algorithms : Example (Mutation)the MAXONE problem

J chromosome

number

Binary chromosome

Oj = number of onesObjective function

Fj =Oj / (Total Oj)Fraction of Total

1 1110100101 6 0.1622 0111000101 5 0.1353 1111110100 7 0.1894 0100011101 5 0.1355 1110110001 6 0.1626 1110101111 8 0.216Total 37 1

In one generation, the total population fitness changed from 34 to 37, thus improved by ~9%

At this point, we go through the same process all over again, until a stopping criterion is met

Genetic algorithms : Example (End)the MAXONE problem

-1 -0.5 0 0.5 1 1.5 2-1

-0.5

0

0.5

1

1.5

2

2.5

3

Genetic algorithms : Optimization of a simple function

The function is defined as:

The problem is to find x from the rang [-1 2] whichMaximizes the function f, i.e., to find x0 such that,

]21[),()( 0 −∈≥ xallforxfxfIt is relatively easy to analyze the function f. The zeros of the first derivative f’ should be determined:

0.1).10sin(.)( += xxxf π

L

L

&

,2,120

120

,2,120

12.10).10tan(

0).10cos(.10).10sin()(

0

−−=+

=

=

=−

=

−==+=

iforix

x

iforix

xxxxxxf

i

i

πππππ The function f reaches its local max for

xi if i is an odd integer and its local min for xi if i is an even integer. The function reaches its max for:

85.20.1)2

18sin(.85.1)85.1(

85.12037

19

=++=

==

ππf

x

Genetic algorithms : Optimization of a simple function

Assume that we wish to construct a genetic algorithm: to maximize the function f.Let discuss the major components of such a genetic algorithm in turn.

Genetic algorithms : Presentation (Encoding)

We use a binary vector as a chromosome to present real values of the variable x.The length of the vector depends on the required precision, which, in this example, is six places after the decimal point.The domain of the variable x has length 3; the precision requirement implies that the range [-1 2] should be divided into at least 3.1,000,000=3,000,000 equal size ranges. This means that 22 bits are required as a binary vector (chromosome):

41943042300000022097152 2221 =<<=The mapping from a binary vector (chromosome) (b21b20....b0) into a real numberX from the range [-1 2] is straightforward and is completed in to steps:•Convert the binary chromosome (b21b20….b0) from the base 2 to base 10:

'

10

21

0202021 2.)( xbbbb

i

ii =

= ∑

=

L

• Find a corresponding real number x :

123.0.1 22

'

−+−= xx

Where -1.0 is the left boundary of the domain and 3 is the length of the domain:

12).10000....10001( 2 −

−+=

imii

iiabdecimalax

Genetic algorithms : Presentation (Encoding)

Chromosome: 1000101110110101000111

2288967)1111010100011000101110( 2' ==x

637197.04194303

3.22889670.1 =+−=x

123.0.1 22

'

−+−= xx

Of course, the chromosomes (0000000000000000000000) and (1111111111111111111111)Represent boundaries of the domain, -1.0 and 2.0

Genetic algorithms : Initial population

The initialization process is very simple:we create a population of chromosomes, where each chromosome is is a binary vector of 22 bits. All 22 bits for each chromosome are initializedRandomly.

Genetic algorithms : Evaluation function

)()( xfveval =Evaluation function eval(*) for binary chromosome v is equivalent to the function f:

As noted earlier, the evaluation plays the role of the environment, rating potential solutionIn terms of their fitness. For example, three chromosomes:

627888.1)0111111100011110000000(958973.0)0000000001000000001110(

637197.0)1111010100011000101110(

33

22

11

==−==

==

xtodcorresponevxtodcorresponev

xtodcorresponev

250650.2)()(078878.0)()(

586345.1)()(

33

22

11

======

xfvevalxfvevalxfveval

Clearly, the chromosome v3 is the best of the three chromosomes, since its evaluation returns the highest value.

Genetic algorithms : Mutation

721638.1)0111111100011110100000(627888.1)0111111100011110000000(

3'

3'

33

==

==

xtodcorresponevxtodcorresponev

Assume that the fifth gene from the v3 chromosome was selected for mutation:

082257.0)()(250650.2)()(

3'

3'

33

−==

==

xfvevalxfveval

This means that this particular mutation resulted in a significant decrease of the value ofthe chromosome v3. If the 10th gene was selected for mutation in chromosome v3, then:

630818.1)0111111100011110000001(627888.1)0111111100011110000000(

3"

3"

33

==

==

xtodcorresponevxtodcorresponev

343555.2)()(250650.2)()(

3"

3"

33

==

==

xfvevalxfveval

Genetic algorithms : Crossover

v2 = 0000001110000000010000

v3 = 1110000000111111000101

Before crossover:

After crossover:v’2 = 0000000000111111000101v’3 = 1110001110000000010000

627888.1)0111111100011110000000(958973.0)0000000001000000001110(

33

22

==−==

xtodcorresponevxtodcorresponev

250650.2)()(078878.0)()(

33

22

====

xfvevalxfveval

666028.1)0000000001001110001110(998113.0)0111111100010000000000(

3'

3'

2'

2'

==

−==

xtodcorresponevxtodcorresponev

459245.2)()(940865.0)()(

3'

3'

2'

2'

==

==

xfvevalxfveval

Note that the second offspring has a better evaluation than both of its parents.

Genetic algorithms : Parameters

For this particular problem we have used the following parameters: Population size: pop_size = 50, probability of crossover Pc =0.25, probability of mutation Pm = 0.01.

Generation number Evaluation function1 1.4419426 2.2500038 2.2502839 2.25028410 2.25036312 2.32807739 2.34425140 2.34508751 2.73893099 2.849246137 2.850217145 2.850227

In table, we provide the generation number for which we noted an improvement in the evaluation function, together with the value of function. The best chromosome after 150 generations was:

850773.1)0100010000011111001101(

max

max

==

xtodcorresponev

Genetic algorithms : Optimization of a two variables function

The function is defined as:

Where

).20sin(.).4sin(.5.21),( 221121 xxxxxxf ππ +++=

8.51.41.123 21 ≤≤≤≤− xandx

Genetic algorithms : Presentation (Encoding)

We use a binary vector as a chromosome to present real values of the variable x.The length of the vector depends on the required precision, which, in this example, is four places after the decimal point.

The domain of the variable x1 has length 15.1; the precision requirement implies that the range [-3 12.1] should be divided into at least 15.1*10000=151000 equal size ranges. This means that 18 bits are required as a binary vector (chromosome):

26214421510002131072 1817 =<<=

The domain of the variable x2 has length 1.7; the precision requirement implies that the range [4.1 5.8] should be divided into at least 1.7*10000=17000 equal size ranges. This means that 15 bits are required as a binary vector (chromosome):

32768217000216384 1514 =<<=

Genetic algorithms : Presentation (Encoding)

The total length of a chromosome (solution vector) is then m = 18 + 15=33 bits; the first 18 bits code x1 and remaining 15 bits (19-33) code x2.Let us consider an example chromosome:

010001001011010000111110010100010

052426.1262143

1.15.703520.312

)0.3(1.12).110100000100010010(0.3 1821 =+−=−−−

+−= decimalx

12).10000....10001( 2 −

−+=

imii

iiabdecimalax

The first 18 bits: 111110010100010 represents:

755330.532767

7.1.319061.4121.48.5).00101111001010(1.4 1522 =+=

−−

+= decimalx

So the chromosome: 010001001011010000111110010100010 corresponds to (x1, x2)= (1.052426,5.755330). The fitness value for this chromosome is:

f(1.052426,5.755330)=20.252640.

The first 18 bits: 010001001011010000 represents

Genetic algorithms : Initial populationTo optimize the function f using a genetic algorithm, we create a population of pop_size = 20 chromosomes. All 33 bits in all chromosomes are initialized randomly.

110100010111110011110011011100101100000011000111111111110001010100101011111010100001110100111010000101000110111111001111010110101111011000110100100011111101100111100110001111101101110000101110111011001011110010100001010100100100110110000000100010001000111110111110000010101000011101101001101000101000000110111110110101100110011111011101000011100110000010000011110100000000111101100010110100000001111011010110001110100011000011000011101101111100110101110010001000011101011111110010101000001010000101011111100001010011010001110110010100000111001101001111000110001101101011101111001000000000100000010101010001100110111001110001001111101001101100001111111001101000

20

19

18

17

16

15

14

13

12

11

10

9

8

7

6

5

4

3

2

1

=

==

==

======

==

==

=====

vvvvvvvvvvvvvvvvvvvv

7768.3876669.13),(),(|7573.49359.7|1101000101111100111100110111001010959.20),(),(|3955.57466.1|1000000110001111111111100010101004141.15),(),(|1582.58430.3|1010111110101000011101001110100006961.13),(),(|5713.43675.3|1010001101111110011110101101011118672.23),(),(|9937.42115.9|0110001101001000111111011001111000602.30),(),(|0545.50889.11|1100011111011011100001011101110118762.19),(),(|1513.53359.1|0010111100101000010101001001001103167.27),(),(|3786.51346.11|1100000001000100010001111101111100116.15),(),(|2394.43561.9|0000101010000111011010011010001014106.23),(),(|9960.41300.3|0000001101111101101011001100111112784.21),(),(|7937.45548.2|0111010000111001100000100000111101277.16),(),(|3814.57954.0|1000000001111011000101101000000019597.17),(),(|7030.49106.4|1110110101100011101000110000110000208.16),(),(|5802.59914.0|0111011011111001101011100100010001004.18),(),(|3919.48117.1|0111010111111100101010000010100003411.25),(),(|7344.42551.1|1010111111000010100110100011101104067.17),(),(|5934.52786.5|0101000001110011010011110001100015263.19),(),(|3903.45166.2|101101011101111001000000000100000

5800.7),(),(|3802.43484.10|0101010100011001101110011100010010196.26),(),(|6522.50844.6|111101001101100001111111001101000

21212120

21212119

21212118

21212117

21212116

21212115

21212114

21212113

21212112

21212111

21212110

2121219

2121218

2121217

2121216

2121215

2121214

2121213

2121212

2121211

FitnessTotalxxfxxevalxxvxxfxxevalxxvxxfxxevalxxvxxfxxevalxxvxxfxxevalxxvxxfxxevalxxvxxfxxevalxxvxxfxxevalxxvxxfxxevalxxvxxfxxevalxxvxxfxxevalxxvxxfxxevalxxvxxfxxevalxxvxxfxxevalxxvxxfxxevalxxvxxfxxevalxxvxxfxxevalxxvxxfxxevalxxvxxfxxevalxxv

xxfxxevalxxv

========−=============================================−===============−=====−=====−==========−============

During the evaluation phase we decode each chromosome and calculate the fitnessFunction values from (x1, x2) values just decoded. We get:

It is clear, that the chromosome v15 is the strongest one, and the chromosome v2the weakest.

Now we constructs a roulette wheel for the selection process. The total fitness of the population is:

The probability of a selection pi and the cumulative probabilities qi for each chromosome vi (i=1,…20) are:

0000.10352.06822.387/6669.13/)(9648.00518.06822.387/0959.20/)(9129.00397.06822.387/4141.15/)(8732.00353.06822.387/6961.13/)(8379.00615.06822.387/8672.23/)(7763.00775.06822.387/0602.30/)(6988.00513.06822.387/8762.19/)(6475.00775.06822.387/3167.27/)(5771.00387.06822.387/0116.15/)(5384.00604.06822.387/4106.23/)(4780.00549.06822.387/2784.21/)(

4231.00416.06822.387/1277.16/)(3815.00463.06822.387/9597.17/)(3352.00413.06822.387/0208.16/)(2939.00467.06822.387/1004.18/)(2472.00654.06822.387/3411.25/)(1819.00449.06822.387/4067.17/)(1370.00504.06822.387/5263.19/)(0866.00195.06822.387/5800.7/)(

0671.00671.06822.387/0196.26/)(

202020

191919

181818

171717

161616

151515

141414

131313

121212

111111

101010

999

888

777

666

555

444

333

222

111

============================================

================================

====

qFvevalpqFvevalpqFvevalpqFvevalpqFvevalpqFvevalpqFvevalpqFvevalpqFvevalpqFvevalpqFvevalpqFvevalpqFvevalpqFvevalpqFvevalpqFvevalpqFvevalpqFvevalpqFvevalpqFvevalp

7768.387)(20

1== ∑

=iivevalF

Now we are ready to spin the roulette wheel 20 times; each time we select a single chromosome for a new population. Let us assume that a (random) sequence of 20 numbers from range [0 1] is:

0000.17802.09648.07671.09129.06446.08732.07656.08379.00054.07763.09834.06988.03681.06475.02772.05771.03890.05384.07039.04780.04247.0

4231.04948.03815.02226.03352.07022.02939.01717.02472.09476.01819.05345.01370.03087.00866.01758.00670.05138.0

2020

1919

1818

1717

1616

1515

1414

1313

1212

1111

1010

99

88

77

66

55

44

33

22

11

======================

==================

qrqrqrqrqrqrqrqrqrqrqrqrqrqrqrqrqrqrqrqr

chromosomevSelectqrq 1111110 5384.05138.04780.0 =<=<=

chromosomevSelectqrq 4423 1819.01758.01370.0 =<=<=

chromosomevSelectqrq 7736 1819.03087.01717.0 =<=<=

chromosomevSelectqrq 1111410 5384.05345.04780.0 =<=<=

chromosomevSelectqrq 1919518 9648.09476.09129.0 =<=<=

chromosomevSelectqrq 4463 1819.01717.01370.0 =<=<=

chromosomevSelectqrq 1515714 7763.07022.06988.0 =<=<=

chromosomevSelectqrq 5584 2472.02226.01819.0 =<=<=

chromosomevSelectqrq 1111910 5384.04948.04780.0 =<=<=

chromosomevSelectqrq 1010109 4780.04247.04231.0 =<=<=

chromosomevSelectqrq 15151114 7763.07039.06988.0 =<=<=

chromosomevSelectqrq 99128 4231.03890.03815.0 =<=<=

chromosomevSelectqrq 66135 2939.02772.02472.0 =<=<=

chromosomevSelectqrq 88147 3815.03681.03352.0 =<=<=

chromosomevSelectqrq 20201519 0000.19834.09648.0 =<=<=

chromosomevSelectqrq 11160 0670.00054.00000.0 =<=<=

chromosomevSelectqrq 15151714 7763.07656.06988.0 =<=<=

chromosomevSelectqrq 13131812 6475.06446.05771.0 =<=<=

chromosomevSelectqrq 15151914 7763.07671.06988.0 =<=<=

chromosomevSelectqrq 16162015 8379.07802.07763.0 =<=<=1620

'1519

'1318

'1517

'116

'2015

'814

'613

'912

'1511

'1010

'119

'58

'157

'46

'195

'114

'73

'42

'111

'

vvvvvvvvvvvvvvvvvvvvvv

vvvvvvvvvvvvvvvvvv

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

11001401031

111112001

20

19

18

17

16

15

14

13

12

11

10

9

8

7

6

5

4

3

2

1

===========

=========

vvvvvvvvvvvvvvvvvvvv

010100000111001101001111110111011110001111101101110000101000110001

11''

2''

=

=

vv

110001111101101110000101110111011010100000111001101001111000110001

11'

2'

=

=

vv

Genetic algorithms : CrossoverNow we are ready to apply the crossover operation to the individuals in the new population (vector v’

I ). The probability of crossover Pc=0.25, so we expect that on average 25% of chromosomes (i.e., 5 out of 20) undergo crossover.We proceed in the following way: Let us assume that a (random) sequence of 20 numbers from range [0 1] is:

8269.03557.02002.03892.05819.07584.06745.01665.08699.00315.07854.0

6068.04012.05198.09172.03490.03115.06255.01519.08230.0

20

19

18

17

16

15

14

13

12

11

10

9

8

7

6

5

4

3

2

1

===========

=========

rrrrrrrrrrrrrrrrrrrr

This mean that the chromosomes v’2, v’

11, v’13 and v’

18 were selected for crossover. For each of these two pairs, we generate a random integer number pos from range [1 32] ( 33 is the total length-number of bits-in chromosome). The number pos indicates the position of the crossing point. The first pair of chromosomes is:

And the generated number pos=9.

011101011111110001000111110111110110000000100010010101000001010000

18''

13''

=

=

vv

110000000100010001000111110111110011101011111110010101000001010000

18'

13'

=

=

vv

Genetic algorithms : CrossoverThe second pair of chromosomes is:

And the generated number pos=9.

011000110100100011111101100111100110001111101101110000101110111011011101011111110001000111110111110110001111101101110000101110111011111101001101100001111111001101000110100010111110011110011011100101111011010110001110100011000011000110000000100010010101000001010000100000000111101100010110100000001010100000111001101001111110111011011101000011100110000010000011110

000000110111110110101100110011111101011111100001010011010001110110110001111101101110000101110111011010100000111001101001111000110001100000011000111111111110001010100000000110111110110101100110011111011101101111100110101110010001000110001111101101110000101000110001000000110111110110101100110011111

20'

19'

18''

17'

16'

15'

14'

13''

12'

11''

10'

9'

8'

7'

6'

5'

4'

3'

2''

1'

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

vvvvvvvvvvvvvvvvvvvv

The current version of the population

Genetic algorithms : MutationThe next operator, mutation, is performed on a bit-by-bit basis. The probability of mutation pm=0.01, so we expect that (on average) 1% of bits would undergo mutation. There are m x pop_size =33 x 20 = 660 bits in the whole population; we expect (on average) 6.6 mutations per generation. Every bit has an equal chance to be mutated, so, for every bit in the population, we generate a random number r from the range [0 1]; if r<0.01, we mutate the bit.This means that we have to generate 660 random numbers. In a sample run, 5 of these numbers were smaller than 0.01; the bit number and the random number are listed below:

Bit position Random number112 0.0002349 0.0099418 0.0088429 0.0054602 0.0028

Bit position Chromosome position

Bit number within chromosome

112 int(112/33) = 4 112-3x33 = 13349 int(349/33) = 11 349-10x33 = 19418 int(418/33) = 13 418-12x33 = 22429 int(429/33) = 13 429-12x33 = 33602 int(602/33) = 19 602-18x33 = 8

011000110100100011111101100111100110001111101101110000101110111011011101011111110001000111110111110110001111101101110000101110111011111101001101100001111111001101000110100010111110011110011011100101111011010110001110100011000011000110000000100010010101000001010000100000000111101100010110100000001010100000111001101001111110111011011101000011100110000010000011110

000000110111110110101100110011111101011111100001010011010001110110110001111101101110000101110111011010100000111001101001111000110001100000011000111111111110001010100000000110111110110101100110011111011101101111100110101110010001000110001111101101110000101000110001000000110111110110101100110011111

20'

19'

18''

17'

16'

15'

14'

13''

12'

11''

10'

9'

8'

7'

6'

5'

4'

3'

2''

1'

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

vvvvvvvvvvvvvvvvvvvv

Genetic algorithms : Mutation

Chromosom

e position

Bit number

within

chromosom

e

4 1311 1913 2213 3319 8

The current version of the population before mutation

The current version of the population after mutation

011000110100100011111101100111100110001111101101110000101110111111011101011111110001000111110111110110001111101101110000101110111011111101001101100001111111001101000110100010111110011110011011100101111011010110001110100011000011000111010000100010010101000001010000100000000111101100010110100000001010100000111001101001011110111011011101000011100110000010000011110

000000110111110110101100110011111101011111100001010011010001110110110001111101101110000101110111011010100000111001101001111000110001100000011000111111111110001010100000000110111110010101100110011111011101101111100110101110010001000110001111101101110000101000110001000000110111110110101100110011111

20'

19'

18''

17'

16'

15'

14'

13''

12'

11''

10'

9'

8'

7'

6'

5'

4'

3'

2''

1'

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

vvvvvvvvvvvvvvvvvvvv

We drop primes for modified chromosomes : the population is listed as new vector vi:

011000110100100011111101100111100110001111101101110000101110111111011101011111110001000111110111110110001111101101110000101110111011111101001101100001111111001101000110100010111110011110011011100101111011010110001110100011000011000111010000100010010101000001010000100000000111101100010110100000001010100000111001101001011110111011011101000011100110000010000011110

000000110111110110101100110011111101011111100001010011010001110110110001111101101110000101110111011010100000111001101001111000110001100000011000111111111110001010100000000110111110010101100110011111011101101111100110101110010001000110001111101101110000101000110001000000110111110110101100110011111

20

19

18

17

16

15

14

13

12

11

10

9

8

7

6

5

4

3

2

1

===========

=========

vvvvvvvvvvvvvvvvvvvv

0497.4478672.23)9937.4,2116.9()(6084.27)0545.5,0595.11()(5911.27)6670.5,1346.11()(0602.30)0545.5,0890.11()(

0196.26)6522.5,0844.6()(6670.13)7573.4,9360.7()(9597.17)7030.4,9106.4()(

6925.22)2099.4,8118.1()(1278.16)3815.5,7954.0()(

3518.33)7434.4,0886.11()(2784.21)7937.4,5549.2()(

4107.23)9961.4,1301.3()(3412.25)7345.4,2552.1()(0602.30)0545.5,0890.11()(

4067.17)5935.5,2787.5()(0959.20)3956.5,7466.1()(

4126.23)9961.4,1282.3()(0208.16)6803.5,9915.0()(

2011.18)0545.5,2790.5()(4107.23)9961.4,1301.3()(

20

19

18

17

16

15

14

13

12

11

10

9

8

7

6

5

4

3

2

1

=========

======

=−======−=

===−===

===−=

===−=

====

Totalfvevalfvevalfvevalfvevalfvevalfvevalfvevalfvevalfvevalfvevalfveval

fvevalfvevalfvevalfvevalfvevalfvevalfvevalfvevalfveval

Now, we are ready to run the selection process again and apply the genetic operator, evaluate the next generation, etc. After 100 generations the population is:

001010101011110000100001110011001001111000001010001010001111011000001010101011110000100001110011001011010101011110000100001110011001001010001010010000101001110011001001010011011010111001011110011010011010101011110000100001110011001011010101011111011011101110111101001110001011010010010001101011000000110001011000010010001101011000011010101011111011011101110111101

001110001011010010010001110011000001110101001010001010001111011000000110001011010010010001101011000001010001010010000100001110011001011010101011111011011101110111101001010101011110000110001110011000011010101011111011011101110111101000010101011110000100011110011001011010101011110011011101110111101

20

19

18

17

16

15

14

13

12

11

10

9

8

7

6

5

4

3

2

1

===========

=========

vvvvvvvvvvvvvvvvvvvv

3728.6259567.32)2424.4,5888.10()(6697.19)4728.4,5181.11()(9567.32)2424.4,5888.10()(9321.32)2425.4,5888.10()(3595.34)2146.4,5888.10()(7468.30)6537.4,6066.10()(9321.32)2425.4,5888.10()(3166.30)0925.5,1246.11()(4561.35)42779.4,6311.9()(

4779.35)4279.4,6237.9()(3166.30)0925.5,1225.11()(3938.34)4279.4,5748.10()(3090.23)4528.4,5181.11()(

4586.35)4279.4,6311.9()(3561.34)2146.4,5888.10()(3166.30)0925.5,1246.11()(9331.31)2442.4,5741.10()(3166.30)0925.5,1246.11()(8697.26)6674.4,5888.10()(

2985.30)0925.5,12.11()(

20

19

18

17

16

15

14

13

12

11

10

9

8

7

6

5

4

3

2

1

===================

========

============

==

Totalfvevalfvevalfvevalfvevalfvevalfvevalfvevalfvevalfvevalfvevalfveval

fvevalfvevalfvevalfvevalfvevalfvevalfvevalfvevalfveval

Hybrid intelligent systems

Evolutionary neural networks

Evolutionary neural networks

n Although neural networks are used for solving a variety of problems, they still have some limitations.

n One of the most common is associated with neural network training. The back-propagation learning algorithm cannot guarantee an optimal solution. In real-world applications, the back-propagation algorithm might converge to a set of sub-optimal weights from which it cannot escape. As a result, the neural network is often unable to find a desirable solution to a problem at hand.

n Another difficulty is related to selecting an optimal topology for the neural network. The “right” network architecture for a particular problem is often chosen by means of heuristics, and designing a neural network topology is still more art than engineering.

n Genetic algorithms are an effective optimisation technique that can guide both weight optimisation and topology selection.

Evolutionary neural networks

y

0.91

3

4

5

6

7

8

x1

x3

x2 2

-0.8

0.4

0.8

-0.7

0.2

-0.20.6

-0.3 0.1

-0.2

0.9

-0.60.1

0.3

0.5

From neuron:To neuron:

1 2 3 4 5 6 7 8

12345678

0 0 0 0 0 0 0 00 0 0 0 0 0 0 00 0 0 0 0 0 0 0

0.9 -0.3 -0.7 0 0 0 0 0 -0.8 0.6 0.3 0 0 0 0 00.1 -0.2 0.2 0 0 0 0 00.4 0.5 0.8 0 0 0 0 00 0 0 -0.6 0.1 -0.2 0.9 0

Chromosome: 0.9 -0.3 -0.7 -0.8 0.6 0.3 0.1 -0.2 0.2 0.4 0.5 0.8 -0.6 0.1 -0.2 0.9

Encoding a set of weights in a chromosome

n The second step is to define a fitness functionfor evaluating the chromosome’s performance. This function must estimate the performance of a given neural network. We can apply here a simple function defined by the sum of squared errors.

n The training set of examples is presented to the network, and the sum of squared errors is calculated. The smaller the sum, the fitter the chromosome. The genetic algorithm attempts to find a set of weights that minimises the sum of squared errors.

Fitness Function

n The third step is to choose the genetic operators – crossover and mutation. A crossover operator takes two parent chromosomes and creates a single child with genetic material from both parents. Each gene in the child’s chromosome is represented by the corresponding gene of the randomly selected parent.

n A mutation operator selects a gene in a chromosome and adds a small random value between −1 and 1 to each weight in this gene.

weight optimisationCrossover & Mutation

Crossover in weight optimisation

3

4

5

y6

x2 2-0.30.9

-0.70.5

-0.8

-0.6

Parent 1

x1 1-0.20.1

0.4

3

4

5

y6

x2 2-0.1-0.5

0.2-0.9

0.6

0.3

Parent 2

x1 1 0.90.3

-0.8

0.1 -0.7 -0.6 0.5 -0.8-0.2 0.9 0.4 -0.3 0.3 0.2 0.3 -0.9 0.60.9 -0.5 -0.8 -0.1

0.1 -0.7 -0.6 0.5 -0.80.9 -0.5 -0.8 0.1

3

4

5

y6

x2 2-0.1-0.5

-0.70.5

-0.8

-0.6

Child

x1 1 0.90.1

-0.8

Mutation in weight optimisation

Original network3

4

5

y6

x2 2-0.30.9

-0.70.5

-0.8

-0.6x1 1-0.20.1

0.4

0.1 -0.7 -0.6 0.5 -0.8-0.2 0.9

3

4

5

y6

x2 20.20.9

-0.70.5

-0.8

-0.6x1 1-0.20.1

-0.1

0.1 -0.7 -0.6 0.5 -0.8-0.2 0.9

Mutated network

0.4 -0.3 -0.1 0.2

Can genetic algorithms help us in selecting the network architecture?

The architecture of the network (i.e. the number of neurons and their interconnections) often determines the success or failure of the application. Usually the network architecture is decided by trial and error; there is a great need for a method of automatically designing the architecture for a particular application. Genetic algorithms may well be suited for this task.

Evolutionary neural networks:optimal topology

n The basic idea behind evolving a suitable network architecture is to conduct a genetic search in a population of possible architectures.

n We must first choose a method of encoding a network’s architecture into a chromosome.

Evolutionary neural networks:optimal topology

Encoding the network architecturen The connection topology of a neural network can

be represented by a square connectivity matrix. n Each entry in the matrix defines the type of

connection from one neuron (column) to another (row), where 0 means no connection and 1 denotes connection for which the weight can be changed through learning.

n To transform the connectivity matrix into a chromosome, we need only to string the rows of the matrix together.

Encoding of the network topology

From neuron:To neuron:

1 2 3 4 5 6123456

0 0 0 0 0 00 0 0 0 0 01 1 0 0 0 01 0 0 0 0 00 1 0 0 0 00 1 1 1 1 0

3

4

5

y6

x2 2

x1 1

Chromosome: 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 1 1 1 0

The cycle of evolving a neural network topologyNeural Network j

Fitness = 117

Neural Network j

Fitness = 117Generation i

Training Data Set 0 0 1.00000.1000 0.0998 0.88690.2000 0.1987 0.75510.3000 0.2955 0.61420.4000 0.3894 0.47200.5000 0.4794 0.33450.6000 0.5646 0.20600.7000 0.6442 0.08920.8000 0.7174 -0.01430.9000 0.7833 -0.10381.0000 0.8415 -0.1794

Child 2

Child 1

CrossoverParent 1

Parent 2

Mutation

Generation (i + 1)