47
Lecture 9 Lecture 9 Evolutionary Computation: Evolutionary Computation: Genetic algorithms Genetic algorithms Genetic algorithms Genetic algorithms Introduction, or can evolution be Introduction, or can evolution be intelligent? intelligent? intelligent? intelligent? Simulation Simulation of natural evolution of natural evolution Genetic algorithms Genetic algorithms Case Case study: maintenance scheduling with study: maintenance scheduling with Case Case study: maintenance scheduling with study: maintenance scheduling with genetic algorithms genetic algorithms S mmar S mmar 11/14/2010 Intelligent Systems and Soft Computing 1 Summary Summary

Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Lecture 9Lecture 9Evolutionary Computation:Evolutionary Computation:Genetic algorithmsGenetic algorithmsGenetic algorithmsGenetic algorithms Introduction, or can evolution be Introduction, or can evolution be

intelligent?intelligent?intelligent?intelligent? SimulationSimulation of natural evolutionof natural evolutionGenetic algorithmsGenetic algorithmsCaseCase study: maintenance scheduling withstudy: maintenance scheduling withCaseCase study: maintenance scheduling with study: maintenance scheduling with

genetic algorithmsgenetic algorithms S mmarS mmar

11/14/2010 Intelligent Systems and Soft Computing 1

SummarySummary

Page 2: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

CanCan evolutionevolution bebe intelligent?intelligent? Intelligence can be defined as the capability of a Intelligence can be defined as the capability of a

system to adapt its behavior to eversystem to adapt its behavior to ever--changing changing environment. According to Alan Turing, the form environment. According to Alan Turing, the form or appearance of a system is irrelevant to its or appearance of a system is irrelevant to its intelligence. intelligence.

Evolutionary computation simulates evolution on a Evolutionary computation simulates evolution on a computer. The result of such a simulation is a computer. The result of such a simulation is a series of optimization algorithms, usually based on series of optimization algorithms, usually based on

i l f l O i i ii l f l O i i i i i li i la simple set of rules. Optimizationa simple set of rules. Optimization iteratively iteratively improves the quality of solutions until an optimal, improves the quality of solutions until an optimal,

t l t f ibl l ti i f dt l t f ibl l ti i f d

11/14/2010 Intelligent Systems and Soft Computing 2

or at least feasible, solution is found.or at least feasible, solution is found.

Page 3: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

The behavior of an individual organism is an The behavior of an individual organism is an inductive inference about some yet unknowninductive inference about some yet unknowninductive inference about some yet unknown inductive inference about some yet unknown aspects of its environment. If, over successive aspects of its environment. If, over successive generations the organism survives we can saygenerations the organism survives we can saygenerations, the organism survives, we can say generations, the organism survives, we can say that this organism is capable of learning to predict that this organism is capable of learning to predict changes in its environment.changes in its environment.changes in its environment.changes in its environment.

The evolutionary approach is based on The evolutionary approach is based on computational models of natural selection andcomputational models of natural selection andcomputational models of natural selection and computational models of natural selection and genetics. We call them genetics. We call them evolutionary evolutionary computationcomputation, an umbrella term that combines, an umbrella term that combinescomputationcomputation, an umbrella term that combines , an umbrella term that combines genetic algorithmsgenetic algorithms, , evolution strategies evolution strategies and and genetic programminggenetic programming..

11/14/2010 Intelligent Systems and Soft Computing 3

g p g gg p g g

Page 4: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Simulation of natural evolutionSimulation of natural evolution On 1 July 1858, On 1 July 1858, Charles Darwin Charles Darwin presented his presented his

theory of evolution before the Linnean Society oftheory of evolution before the Linnean Society oftheory of evolution before the Linnean Society of theory of evolution before the Linnean Society of London. This day marks the beginning of a London. This day marks the beginning of a revolution in biology.revolution in biology.gygy

Darwin’s classical Darwin’s classical theory of evolutiontheory of evolution, together , together with Weismann’swith Weismann’s theory of natural selectiontheory of natural selection andandwith Weismann s with Weismann s theory of natural selection theory of natural selection and and Mendel’s concept of Mendel’s concept of geneticsgenetics, now represent the , now represent the neoneo--Darwinian paradigm.Darwinian paradigm.p gp g

11/14/2010 Intelligent Systems and Soft Computing 4

Page 5: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

NeoNeo--Darwinism Darwinism is based on processes of is based on processes of ppreproduction, mutation, competition and selection. reproduction, mutation, competition and selection. The power to reproduce appears to be an essential The power to reproduce appears to be an essential property of life. The power to mutate is also property of life. The power to mutate is also guaranteed in any living organism that reproduces guaranteed in any living organism that reproduces itself in a continuously changing environment. itself in a continuously changing environment. Processes of competition and selection normally Processes of competition and selection normally

k l i h l ld h dik l i h l ld h ditake place in the natural world, where expanding take place in the natural world, where expanding populations of different species are limited by a populations of different species are limited by a finite spacefinite spacefinite space.finite space.

11/14/2010 Intelligent Systems and Soft Computing 5

Page 6: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Evolution can be seen as a process leading to the Evolution can be seen as a process leading to the p gp gmaintenance of a population’s ability to survive maintenance of a population’s ability to survive and reproduce in a specific environment. This and reproduce in a specific environment. This ability is called ability is called evolutionary fitnessevolutionary fitness..

Evolutionary fitness can also be viewed as a Evolutionary fitness can also be viewed as a yymeasure of the organism’s ability to anticipate measure of the organism’s ability to anticipate changes in its environment.changes in its environment.

The fitness, or the quantitative measure of the The fitness, or the quantitative measure of the ability to predict environmental changes and ability to predict environmental changes and y p gy p grespond adequately, can be considered as the respond adequately, can be considered as the quality that is optimizedquality that is optimized in natural life.in natural life.

11/14/2010 Intelligent Systems and Soft Computing 6

Page 7: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

How is a population with increasing How is a population with increasing fi d?fi d? Let us consider a population of rabbits. Some Let us consider a population of rabbits. Some

bbi f h h d hbbi f h h d h

fitness generated?fitness generated?

rabbits are faster than others, and we may say that rabbits are faster than others, and we may say that these rabbits possess superior fitness, because they these rabbits possess superior fitness, because they have a greater chance of avoiding foxes survivinghave a greater chance of avoiding foxes survivinghave a greater chance of avoiding foxes, surviving have a greater chance of avoiding foxes, surviving and then breeding.and then breeding.

If two parents have superior fitness there is a goodIf two parents have superior fitness there is a good If two parents have superior fitness, there is a good If two parents have superior fitness, there is a good chance that a combination of their genes will chance that a combination of their genes will produce an offspring with even higher fitness. produce an offspring with even higher fitness. p oduce o sp g w eve g e ess.p oduce o sp g w eve g e ess.Over time the entire population of rabbits becomes Over time the entire population of rabbits becomes faster to meet their environmental challenges in the faster to meet their environmental challenges in the

11/14/2010 Intelligent Systems and Soft Computing 7

face of foxes.face of foxes.

Page 8: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Simulation of natural evolutionSimulation of natural evolution All methods of evolutionary computation simulate All methods of evolutionary computation simulate

natural evolution by creating a population ofnatural evolution by creating a population ofnatural evolution by creating a population of natural evolution by creating a population of individuals, evaluating their fitness, generating a individuals, evaluating their fitness, generating a new population through genetic operations, and new population through genetic operations, and p p g g p ,p p g g p ,repeating this process a number of times.repeating this process a number of times.

We will start withWe will start with Genetic AlgorithmsGenetic Algorithms (GAs) as(GAs) asWe will start with We will start with Genetic Algorithms Genetic Algorithms (GAs) as (GAs) as most of the other evolutionary algorithms can be most of the other evolutionary algorithms can be viewed as variations of genetic algorithms.viewed as variations of genetic algorithms.g gg g

11/14/2010 Intelligent Systems and Soft Computing 8

Page 9: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Genetic AlgorithmsGenetic Algorithms In the early 1970s, John Holland introduced the In the early 1970s, John Holland introduced the

concept of genetic algorithms.concept of genetic algorithms. His aim was to make computers do what nature His aim was to make computers do what nature

does. Holland was concerned with algorithms does. Holland was concerned with algorithms that manipulate strings of binary digits.that manipulate strings of binary digits.

Each artificial “chromosomes” consists of a Each artificial “chromosomes” consists of a number of “genes”, and each gene is represented number of “genes”, and each gene is represented by 0 or 1:by 0 or 1:

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

11/14/2010 Intelligent Systems and Soft Computing 9

Page 10: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Nature has an ability to adapt and learn without Nature has an ability to adapt and learn without being told what to do In other words naturebeing told what to do In other words naturebeing told what to do. In other words, nature being told what to do. In other words, nature finds good chromosomes blindly. GAs do the finds good chromosomes blindly. GAs do the same Two mechanisms link a GA to the problemsame Two mechanisms link a GA to the problemsame. Two mechanisms link a GA to the problem same. Two mechanisms link a GA to the problem it is solving: it is solving: encoding encoding and and evaluationevaluation..

The GA uses a measure of fitness of individualThe GA uses a measure of fitness of individual The GA uses a measure of fitness of individual The GA uses a measure of fitness of individual chromosomes to carry out reproduction. As chromosomes to carry out reproduction. As reproduction takes place, the crossover operatorreproduction takes place, the crossover operatorreproduction takes place, the crossover operator reproduction takes place, the crossover operator exchanges parts of two single chromosomes, and exchanges parts of two single chromosomes, and the mutation operator changes the gene value in the mutation operator changes the gene value in p g gp g gsome randomly chosen location of the some randomly chosen location of the chromosome.chromosome.

11/14/2010 Intelligent Systems and Soft Computing 10

Page 11: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Basic genetic algorithmsBasic genetic algorithmsStep 1Step 1: : Represent the problem variable domain as Represent the problem variable domain as

a chromosome of a fixed length, choose the size a chromosome of a fixed length, choose the size g ,g ,of a chromosome population of a chromosome population NN, the crossover , the crossover probability probability ppcc and the mutation probability and the mutation probability ppmm..

Step 2Step 2: : Define a fitness function to measure the Define a fitness function to measure the performance or fitness of an individualperformance or fitness of an individualperformance, or fitness, of an individual performance, or fitness, of an individual chromosome in the problem domain. The fitness chromosome in the problem domain. The fitness function establishes the basis for selecting function establishes the basis for selecting ggchromosomes that will be mated during chromosomes that will be mated during reproduction. reproduction.

11/14/2010 Intelligent Systems and Soft Computing 11

Page 12: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Step 3Step 3: : Randomly generate an initial population of Randomly generate an initial population of chromosomes of sizechromosomes of size NN::chromosomes of size chromosomes of size NN: : xx11, , xx22 , . . . , , . . . , xxNN

Step 4Step 4: : Calculate the fitness of each individual Calculate the fitness of each individual chromosome: chromosome: ff (( )) ff (( )) ff (( ))f f ((xx11), ), f f ((xx22), . . . , ), . . . , f f ((xxNN))

Step 5Step 5: : Select a pair of chromosomes for mating Select a pair of chromosomes for mating pp p gp gfrom the current population. Parent from the current population. Parent chromosomes are selected with a probability chromosomes are selected with a probability related to their fitness.related to their fitness.

11/14/2010 Intelligent Systems and Soft Computing 12

Page 13: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Step 6Step 6:: Create a pair of offspring chromosomes by Create a pair of offspring chromosomes by applying the genetic operatorsapplying the genetic operators crossovercrossover andandapplying the genetic operators applying the genetic operators crossovercrossover and and mutationmutation..

Step 7Step 7:: Place the created offspring chromosomesPlace the created offspring chromosomesStep 7Step 7:: Place the created offspring chromosomes Place the created offspring chromosomes in the new population.in the new population.

St 8St 8 R tR t S 5S 5 til th i f thtil th i f thStep 8Step 8:: RepeatRepeat Step 5 Step 5 until the size of the new until the size of the new chromosome population becomes equal to the chromosome population becomes equal to the size of the initial populationsize of the initial population NNsize of the initial population, size of the initial population, NN..

Step 9Step 9:: Replace the initial (parent) chromosome Replace the initial (parent) chromosome population with the new (offspring) populationpopulation with the new (offspring) populationpopulation with the new (offspring) population.population with the new (offspring) population.

Step 10Step 10:: Go to Go to Step 4Step 4, and repeat the process until , and repeat the process until th t i ti it i i ti fi dth t i ti it i i ti fi d

11/14/2010 Intelligent Systems and Soft Computing 13

the termination criterion is satisfied.the termination criterion is satisfied.

Page 14: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Genetic algorithmsGenetic algorithms GA represents an iterative process. Each iteration is GA represents an iterative process. Each iteration is

called a called a generationgeneration. A typical number of generations . A typical number of generations for a simple GA can range from 50 to o er 500 Thefor a simple GA can range from 50 to o er 500 Thefor a simple GA can range from 50 to over 500. The for a simple GA can range from 50 to over 500. The entire setentire set of generations is called a of generations is called a runrun..

Because GAs use a stochastic search method theBecause GAs use a stochastic search method the Because GAs use a stochastic search method, the Because GAs use a stochastic search method, the fitness of a population may remain stable for a fitness of a population may remain stable for a number of generations before a superior chromosome number of generations before a superior chromosome

A common practice is to terminate a GA after a A common practice is to terminate a GA after a

g pg pappears.appears.

specified number of generations and then examine specified number of generations and then examine the best chromosomes in the population. If no the best chromosomes in the population. If no

ti f t l ti i f d th GA i t t dti f t l ti i f d th GA i t t d

11/14/2010 Intelligent Systems and Soft Computing 14

satisfactory solution is found, the GA is restarted.satisfactory solution is found, the GA is restarted.

Page 15: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Genetic algorithms: case studyGenetic algorithms: case studyA simple example will help us to understand how A simple example will help us to understand how a GA works. Let us find the maximum value of a GA works. Let us find the maximum value of the function (15the function (15x x xx22) where parameter ) where parameter xx varies varies between 0 and 15. For simplicity, we may between 0 and 15. For simplicity, we may

th tth t t k l i t l Tht k l i t l Thassume that assume that x x takes only integer values. Thus, takes only integer values. Thus, chromosomes can be built with only four genes:chromosomes can be built with only four genes:

Integer Binary code Integer Binary code Integer Binary code1 112 7 12

6 1 0 1 11 1 0 0

0 1 1 00 1 1 1

0 0 0 10 0 1 02 7 12

3 8 134 9 145 10 15

1 1 0 01 1 0 11 1 1 01 1 1 1

0 1 1 11 0 0 01 0 0 11 0 1 0

0 0 1 00 0 1 10 1 0 00 1 0 1

11/14/2010 Intelligent Systems and Soft Computing 15

5 10 15 1 1 1 11 0 1 00 1 0 1

Page 16: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Suppose that the size of the chromosome population Suppose that the size of the chromosome population NN is 6 the crossover probabilityis 6 the crossover probability pp equals 0 7 andequals 0 7 andNN is 6, the crossover probability is 6, the crossover probability ppcc equals 0.7, and equals 0.7, and the mutation probability the mutation probability ppmm equals 0.001. The equals 0.001. The fitness function in our example is definedfitness function in our example is defined bybyfitness function in our example is definedfitness function in our example is defined byby

ff((xx) =) = 1515 xx –– xx22ff((xx) ) 15 15 x x xx

11/14/2010 Intelligent Systems and Soft Computing 16

Page 17: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

The fitness function and chromosome locationsThe fitness function and chromosome locationsChromosome

labelChromosome

stringDecodedinteger

Chromosomefitness

Fitnessratio, %

X1 1 1 0 0 12 36 16.5X2 0 1 0 0 4 44 20.2X3 0 0 0 1 1 14 6.4X4 1 1 1 0 14 14 6.4X5 0 1 1 1 7 56 25 7X5 0 1 1 1 7 56 25.7X6 1 0 0 1 9 54 24.8

60f(x) 60

50

40

30

50

40

30

20

10

00 5 10 15

20

10

00 5 10 15

11/14/2010 Intelligent Systems and Soft Computing 17

x0 5 10 15

(a) Chromosome initial locations.x

0 5 10 15

(b) Chromosome final locations.

Page 18: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

In natural selection, only the fittest species can In natural selection, only the fittest species can survive breed and thereby pass their genes on tosurvive breed and thereby pass their genes on tosurvive, breed, and thereby pass their genes on to survive, breed, and thereby pass their genes on to the next generation.the next generation. GAs use a similar approach, GAs use a similar approach, but unlike nature the size of the chromosomebut unlike nature the size of the chromosomebut unlike nature, the size of the chromosome but unlike nature, the size of the chromosome population remains unchanged from one population remains unchanged from one generation to the next.generation to the next.generation to the next.generation to the next.

The last column in Table shows the ratio of the The last column in Table shows the ratio of the individual chromosome’s fitness to theindividual chromosome’s fitness to theindividual chromosome s fitness to the individual chromosome s fitness to the population’s total fitness. This ratio determines population’s total fitness. This ratio determines the chromosome’s chance of being selected for the chromosome’s chance of being selected for ggmating. The chromosome’s average fitness mating. The chromosome’s average fitness improves from one generation to the next.improves from one generation to the next.

11/14/2010 Intelligent Systems and Soft Computing 18

Page 19: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Roulette wheel selectionRoulette wheel selectionThe most commonly used chromosome selection The most commonly used chromosome selection techniques is the techniques is the roulette wheel selectionroulette wheel selection..

100 0X1: 16.5%

75 2

X1: 16.5%X2: 20.2%X3: 6.4%75.2 X3: 6.4%X4: 6.4%X5: 25 3%

36.743.149.5

X5: 25.3%X6: 24.8%

11/14/2010 Intelligent Systems and Soft Computing 19

Page 20: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

CrossoverCrossover operatoroperator In our example, we have an initial population of 6 In our example, we have an initial population of 6

chromosomes. Thus, to establish the same chromosomes. Thus, to establish the same ,,population in the next generation, the roulette population in the next generation, the roulette wheel would be spun six times. wheel would be spun six times. pp

Once a pair of parent chromosomes is selected, Once a pair of parent chromosomes is selected, the the crossovercrossover operator is applied.operator is applied.p ppp pp

11/14/2010 Intelligent Systems and Soft Computing 20

Page 21: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

First, the crossover operator randomly chooses a First, the crossover operator randomly chooses a crossover point where two parent chromosomescrossover point where two parent chromosomescrossover point where two parent chromosomes crossover point where two parent chromosomes “break”, and then exchanges the chromosome “break”, and then exchanges the chromosome parts after that point As a result two newparts after that point As a result two newparts after that point. As a result, two new parts after that point. As a result, two new offspring are created.offspring are created.

If a pair of chromosomes does not cross overIf a pair of chromosomes does not cross over If a pair of chromosomes does not cross over, If a pair of chromosomes does not cross over, then the chromosome cloning takes place, and the then the chromosome cloning takes place, and the offspring are created as exact copies of eachoffspring are created as exact copies of eachoffspring are created as exact copies of each offspring are created as exact copies of each parent.parent.

11/14/2010 Intelligent Systems and Soft Computing 21

Page 22: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

CrossoverCrossover

0 0X6i 1 00 0 01 0 X2i0 10 0

0X1i 0 11 1 X5i1 01 0 11 101 0

0 01 0X2i 0 11 1 X5i

11/14/2010 Intelligent Systems and Soft Computing 22

i i

Page 23: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Mutation operatorMutation operatorMutation represents a change inMutation represents a change in the gene.the gene.Mutation is a background operator. Its role is to Mutation is a background operator. Its role is to

provide a guarantee that the search algorithm is provide a guarantee that the search algorithm is not trapped on a local optimum.not trapped on a local optimum.

The mutation operator flips a randomly selected The mutation operator flips a randomly selected gene in a chromosome.gene in a chromosome.

The mutation probability is quite small in nature, The mutation probability is quite small in nature, and is kept low for GAs, typically in the range and is kept low for GAs, typically in the range b 0 001 d 0 01b 0 001 d 0 01between 0.001 and 0.01.between 0.001 and 0.01.

11/14/2010 Intelligent Systems and Soft Computing 23

Page 24: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

MutationMutation

X6'i 1 00 0 0

0 01 0X2'i 0 1

0 11 1X5' 01 0

1 1 1 X1"i1 10X1'i 1 1 1

0 11 1X5 i 01 0

X2"i0 1 00 1 0X2i

0 1 111X5i

ii

11/14/2010 Intelligent Systems and Soft Computing 24

Page 25: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

The genetic algorithm cycleThe genetic algorithm cycle

Generation iCrossover

1 01 0X1i

0 01 0X2i

0 00 1X3i

1 11 0X4i

f = 36

f = 44

f = 14

f = 14

X6i 1 00 0 01 0 X2i

0X1i 0 11 1 X5i1 01 0

0 10 0

11 101 01 11 0X4i

0 11 1X5i f = 56

1 00 1X6i f = 54

f 14

Generation (i + 1)

0 01 0X2i 0 11 1 X5i

0X1i 0 11 1 X5i1 01 001 0

1 00 0X1i+1

0 01 1X2i+1

1 10 1X3i+1

0 01 0X4i+1

f = 56

f = 50

f = 44

f = 44

Mutation

X6'i 1 00

0 01 0X2'i 0 1

0 0

0 0 0i+1

0 11 0X5i+1 f = 54

0 11 1X6i+1 f = 56

f

0 11 1X5'i 01 0

1 1 1 X1"i1 1

X2"i0 1 0

0X1'i 1 1 1

0 1 0X2i

11/14/2010 Intelligent Systems and Soft Computing 25

0 1 111X5i

Page 26: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Genetic algorithms: case studyGenetic algorithms: case study Suppose it is desired to find the maximum of the Suppose it is desired to find the maximum of the

“peak” function of two variables:“peak” function of two variables:2222

)()1(),( 33)1(2 yxyx eyxxexyxf

The first step is to represent the problem variables The first step is to represent the problem variables where parameters where parameters x x and and y y vary between vary between 3 and 3.3 and 3.

as a chromosome as a chromosome parameters parameters x x and and y y as a as a concatenated binary string:concatenated binary string:

1 00 0 1 10 0 0 10 1 1 10 1

11/14/2010 Intelligent Systems and Soft Computing 26

yx

Page 27: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

We also choose the size of the chromosome We also choose the size of the chromosome population for instance 6 and randomly generatepopulation for instance 6 and randomly generatepopulation, for instance 6, and randomly generate population, for instance 6, and randomly generate an initial population.an initial population.

The next step is to calculate the fitness of each The next step is to calculate the fitness of each

First, a chromosome, that is a string of 16 bits, is First, a chromosome, that is a string of 16 bits, is

ppchromosome. This is done in two stages.chromosome. This is done in two stages.

1 00 0 1 10 0 0 10 1 1 10 1and

, , g ,, , g ,partitioned into two 8partitioned into two 8--bit strings:bit strings:

Then these strings are converted from binary Then these strings are converted from binary (base 2) to decimal (base 10):(base 2) to decimal (base 10):

00 0 0 0 0 0 0a d

( ) ( )( ) ( )10

012345672 )138(2021202120202021)10001010(

and

11/14/2010 Intelligent Systems and Soft Computing 27

1001234567

2 )59(2121202121212020)00111011(

Page 28: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Now the range of integers that can be handled by Now the range of integers that can be handled by 88 bits that is the range from 0 to (2bits that is the range from 0 to (288 1) is1) is88--bits, that is the range from 0 to (2bits, that is the range from 0 to (288 1), is 1), is mapped to the actual range of parameters mapped to the actual range of parameters x x and and yy, , that is the range fromthat is the range from 3 to 3:3 to 3:that is the range from that is the range from 3 to 3:3 to 3:

0235294.01256

6

To obtain the actual values of To obtain the actual values of x x and and yy, we multiply , we multiply their decimal values by 0 0235294 and subtract 3their decimal values by 0 0235294 and subtract 3

1256

their decimal values by 0.0235294 and subtract 3 their decimal values by 0.0235294 and subtract 3 from the results:from the results:

24705880302352940)138( x 2470588.030235294.0)138( 10 x

and61176471302352940)59( 10 y

11/14/2010 Intelligent Systems and Soft Computing 28

6117647.130235294.0)59( 10 y

Page 29: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Using decoded values of Using decoded values of x x and and y y as inputs in the as inputs in the mathematical function the GA calculates themathematical function the GA calculates themathematical function, the GA calculates the mathematical function, the GA calculates the fitness of each chromosome.fitness of each chromosome.

To find the maximum of the “peak” function weTo find the maximum of the “peak” function we To find the maximum of the peak function, we To find the maximum of the peak function, we will use crossover with the probability equal to 0.7 will use crossover with the probability equal to 0.7 and mutation with the probability equal to 0 001and mutation with the probability equal to 0 001and mutation with the probability equal to 0.001. and mutation with the probability equal to 0.001. As we mentioned earlier, a common practice in As we mentioned earlier, a common practice in GAs is to specify the number of generations.GAs is to specify the number of generations.GAs is to specify the number of generations. GAs is to specify the number of generations. Suppose the desired number of generations is 100. Suppose the desired number of generations is 100. That is, the GA will create 100 generations of 6 That is, the GA will create 100 generations of 6 , g, gchromosomes before stopping.chromosomes before stopping.

11/14/2010 Intelligent Systems and Soft Computing 29

Page 30: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Chromosome locations on the surface of the Chromosome locations on the surface of the “ k”“ k” f ti i iti l l tif ti i iti l l ti“peak”“peak” function: initial populationfunction: initial population

11/14/2010 Intelligent Systems and Soft Computing 30

Page 31: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Chromosome locations on the surface of the Chromosome locations on the surface of the “ k”“ k” f ti fi t tif ti fi t ti“peak”“peak” function: first generationfunction: first generation

11/14/2010 Intelligent Systems and Soft Computing 31

Page 32: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Chromosome locations on the surface of the Chromosome locations on the surface of the “ k” f ti l l i“ k” f ti l l i“peak” function: local maximum“peak” function: local maximum

11/14/2010 Intelligent Systems and Soft Computing 32

Page 33: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Chromosome locations on the surface of the Chromosome locations on the surface of the “ k” f ti l b l i“ k” f ti l b l i“peak” function: global maximum“peak” function: global maximum

11/14/2010 Intelligent Systems and Soft Computing 33

Page 34: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Performance graphs for 100 generations of 6 Performance graphs for 100 generations of 6 chromosomes: local maximumchromosomes: local maximumchromosomes: local maximumchromosomes: local maximum

pc = 0.7, pm = 0.0010. 7

0. 5

0. 6

0. 3

0. 4

n e

s s

0 1

0. 2

F i t

n

BestAverage0

0. 1

11/14/2010 Intelligent Systems and Soft Computing 34

G e n e r a t i o n s80 90 10060 7040 5020 30100

-0.1

Page 35: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Performance graphs for 100 generations of 6 Performance graphs for 100 generations of 6 chromosomes: global maximumchromosomes: global maximumchromosomes: global maximumchromosomes: global maximum

pc = 0.7, pm = 0.011.8

1.4

1.6

1.0

1.2

t n e

s s

0.6

0.8

F i

BestAverage

0 2

0.4

11/14/2010 Intelligent Systems and Soft Computing 35

100

G e n e r a t i o n s80 9060 7040 5020 30100

0.2

Page 36: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Performance graphs for 20 generations of Performance graphs for 20 generations of 60 chromosomes60 chromosomes60 chromosomes60 chromosomes

pc = 0.7, pm = 0.0011.8

1.4

1.6

1.0

1. 2

n e

s s

0 6

0.8

F i t

BestAverage0.4

0.6

11/14/2010 Intelligent Systems and Soft Computing 36

20G e n e r a t i o n s

16 1812 148 1046200.2

Page 37: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Case study: maintenance schedulingCase study: maintenance schedulingMaintenance scheduling problems are usually Maintenance scheduling problems are usually

solved using a combination of search techniques solved using a combination of search techniques g qg qand heuristics.and heuristics.

These problems are complex and difficult toThese problems are complex and difficult toThese problems are complex and difficult to These problems are complex and difficult to solve.solve.

They are NPThey are NP--complete and cannot be solved bycomplete and cannot be solved by They are NPThey are NP complete and cannot be solved by complete and cannot be solved by combinatorial search techniques.combinatorial search techniques.

Scheduling involves competition for limitedScheduling involves competition for limited Scheduling involves competition for limited Scheduling involves competition for limited resources, and is complicated by a great number resources, and is complicated by a great number of badly formalised constraints.of badly formalised constraints.

11/14/2010 Intelligent Systems and Soft Computing 37

yy

Page 38: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Steps in the GA developmentSteps in the GA development

1. Specify the problem, define constraints and 1. Specify the problem, define constraints and optimum criteria;optimum criteria;

2. Represent the problem domain as a 2. Represent the problem domain as a p pp pchromosome;chromosome;

33 D fi fi f i l hD fi fi f i l h3.3. Define a fitness function to evaluate the Define a fitness function to evaluate the chromosome performance;chromosome performance;

4. Construct the genetic operators;4. Construct the genetic operators;5 R th GA d t it t5 R th GA d t it t

11/14/2010 Intelligent Systems and Soft Computing 38

5. Run the GA and tune its parameters.5. Run the GA and tune its parameters.

Page 39: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

CaseCase studystudyS h d li f 7 i i 4 l i lS h d li f 7 i i 4 l i lScheduling of 7 units in 4 equal intervalsScheduling of 7 units in 4 equal intervals

The problem constraints:The problem constraints: The maximum loads expected during four intervals are The maximum loads expected during four intervals are

80, 90, 65 and 70 MW;80, 90, 65 and 70 MW; M i f i h b i i fM i f i h b i i f Maintenance of any unit starts at the beginning of an Maintenance of any unit starts at the beginning of an

interval and finishes at the end of the same or adjacent interval and finishes at the end of the same or adjacent interval The maintenance cannot be aborted or finishedinterval The maintenance cannot be aborted or finishedinterval. The maintenance cannot be aborted or finished interval. The maintenance cannot be aborted or finished earlier than scheduled;earlier than scheduled;

The net reserve of the power system must be greater or The net reserve of the power system must be greater or p y gp y gequal to zero at any interval.equal to zero at any interval.

The optimum criterion is the maximum of the net The optimum criterion is the maximum of the net

11/14/2010 Intelligent Systems and Soft Computing 39

ppreserve at any maintenance period.reserve at any maintenance period.

Page 40: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

CaseCase studystudyUnit data and maintenance requirementsUnit data and maintenance requirements

Unitnumber

Unit capacity,MW

Number of intervals requiredfor unit maintenance

12 0 221

21 533 5 1

11

33 544 051 5

161 571 0 1

11/14/2010 Intelligent Systems and Soft Computing 40

Page 41: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

U it lU it lCaseCase studystudy

Unit gene poolsUnit gene pools

Unit 1: 1 01 0 0 1 0 0 10 1Unit 2: 1 01 0 0 1 0 0 10 1Unit 3: 1 00 0 0 1 0 0 10 0 0 00 1Unit 4: 1 00 0 0 1 0 0 10 0 0 00 1Unit 5: 1 00 0 0 1 0 0 10 0 0 00 1Unit 6: 1 00 0 0 1 0 0 10 0 0 00 1Unit 6: 1 00 0 0 1 0 0 10 0 0 00 1Unit 7: 1 00 0 0 1 0 0 10 0 0 00 1

Chromosome for the scheduling problemChromosome for the scheduling problem

0 11 0 0 10 1 0 00 1 1 00 0 0 01 0 0 10 0 1 00 0Unit 1 Unit 3Unit 2 Unit 4 Unit 6Unit 5 Unit 7

11/14/2010 Intelligent Systems and Soft Computing 41

0 11 0 0 10 1 0 00 1 1 00 0 0 01 0 0 10 0 1 00 0

Page 42: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

CaseCase studystudyThe crossover operatorThe crossover operator

Parent 10 11 0 0 10 1 0 00 1 1 00 0 0 01 0 0 10 0 1 00 0Parent 1

1 01 0 0 11 0 0 01 0 0 00 1 0 10 0 1 00 0 0 01 0Parent 21 01 0 0 11 0 0 01 0 0 00 1 0 10 0 1 00 0 0 01 0

0 11 0 0 10 1 0 00 1 1 00 0 0 10 0 1 00 0 0 01 0Child 1

1 01 0 0 11 0 0 01 0 0 00 1 0 01 0 0 10 0 1 00 0Child 2

11/14/2010 Intelligent Systems and Soft Computing 42

Page 43: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Th t ti tTh t ti tCaseCase studystudy

The mutation operatorThe mutation operator

1 01 0 0 11 0 0 010 0 00 1 0 01 0 0 10 0 1 00 00 01 0

1 01 0 0 11 0 0 010 0 00 1 0 01 0 0 10 0 1 00 00 00 11 01 0 0 11 0 0 010 0 00 1 0 01 0 0 10 0 1 00 00 00 1

11/14/2010 Intelligent Systems and Soft Computing 43

Page 44: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Performance graphs and the best maintenance Performance graphs and the best maintenance schedules created in a population of 20 chromosomesschedules created in a population of 20 chromosomesschedules created in a population of 20 chromosomesschedules created in a population of 20 chromosomes

N = 20, pc = 0.7, pm = 0.001

10

15

s sBestAverage

10

-5

0

5F

i t n

e s

150Unit 2 Unit 2 Unit 1

N e t r e s e r v e s:15 35 35 25

5 15 25 3510 3020 40 45 500-10

G e n e r a t i o n s

60

90

120Unit 7 Unit 1

Unit 6

Unit 1

Unit 3Unit 5

Unit 4

M W

0

30

60

1 2 3 4

11/14/2010 Intelligent Systems and Soft Computing 44

((aa) 50 generations) 50 generationsT i m e i n t e r v a l

Page 45: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Performance graphs and the best maintenance Performance graphs and the best maintenance schedules created in a population of 20 chromosomesschedules created in a population of 20 chromosomesschedules created in a population of 20 chromosomesschedules created in a population of 20 chromosomes

N = 20, pc = 0.7, pm = 0.001

B t10

20

s sBe stAverage

10

0

10F

i t n

e

G e n e r a t i o n sN e t r e s e r v e s :

40 25 20 25Unit 2U it 1U it 1

150

10 30 50 70200 6040 80 90 100-10

G e n e r a t i o n s

Unit 2

Unit 2

Unit 7Unit 1

Unit 6

Unit 1

Unit 3Unit 5

Unit 4

90

120

0

30

60

12 34

11/14/2010 Intelligent Systems and Soft Computing 45

((bb) 100) 100 generationsgenerations12 34

T i m e i n t e r v a l

Page 46: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Performance graphs and the best maintenance Performance graphs and the best maintenance schedules created in a population of 100 chromosomesschedules created in a population of 100 chromosomesschedules created in a population of 100 chromosomesschedules created in a population of 100 chromosomes

N = 100, pc = 0.7, pm = 0.001

20

30

s s

BestAverage

10

0

10F

i t n

e s

35 25 25 25Unit 1 Unit 1

150

G e n e r a t i o n sN e t r e s e r v e s:

10 30 50 70200 6040 80 90 100-10

Unit 2

Unit 7

Unit 1

Unit 6

Unit 1Unit 3

Unit 5

Unit 4

90

120

12 340

30

60

11/14/2010 Intelligent Systems and Soft Computing 46

((aa) Mutation rate is 0.001) Mutation rate is 0.00112 34

T i m e i n t e r v a l

Page 47: Lecture 9 Evolutionary Computationrahimi/cs437/slides/lec09.pdf · Lecture 9 Evolutionary Computation: Genetic algorithmsGenetic algorithms Introduction, or can evolution be intelligent?

Performance graphs and the best maintenance Performance graphs and the best maintenance schedules created in a population of 100 chromosomesschedules created in a population of 100 chromosomesschedules created in a population of 100 chromosomesschedules created in a population of 100 chromosomes

N = 100, c = 0.7, m = 0.0130

20s s

BestAverage

20

-10

0

10F

i t n

e

N e t r e s e r v e s :25 25 30 30

Unit 2Unit 1150

Unit 1

G e n e r a t i o n s10 30 50 70200 6040 80 90 100

-20

Unit 2

Unit 2

Unit 7Unit 6

Unit 1Unit 3

Unit 5Unit 4

60

90

120

Unit 1

1 2 3 40

30

60

11/14/2010 Intelligent Systems and Soft Computing 47

((bb) Mutation rate is 0.01) Mutation rate is 0.01T i m e i n t e r v a l