Dispense Algoritmi Genetici

Embed Size (px)

Citation preview

  • 8/7/2019 Dispense Algoritmi Genetici

    1/24

    1. Introduction

    As a first definition, it may be said that Genetic Algorithms (GA) are numerical searchtools aiming at finding the global maximum (or minimum) of a given real objective functionof one or more real variables, possibly subject to various linear or non linear constraints.Later, we shall see that the GAs are also suitable for other applications, such as finding

    the optimal control function of an industrial plant or improving the medical imaging.The GAs owe their name to the fact that their functioning is inspired by the rules of thenatural selection: correspondingly, the adopted language contains many terms borrowedfrom biology, which need to be suitably redefined to fit the algorithmic context. Thus,when we say that the GA operate on a set of (artificial) chromosomes, these must beunderstood as strings of numbers, generally sequences of binary digits 0 and 1. If theobjective function has many arguments, each string is partitioned in as many substringsof assigned lengths, one for each argument and, correspondingly, we say that each chro-mosome is analogously partitioned in (artificial) genes. The genes constitute the so calledgenotype of the chromosome and the substrings, when decodified in real numbers calledcontrol factors, constitute its phenotype. When the objective function is evaluated in cor-respondence of the values of the control factors of a chromosome, its value is called thefitness of that chromosome. Thus each chromosome gives rise to a trial solution to theproblem.

    The GA search is performed by constructing a sequence of populations of chromosomes,the individuals of each population being the children of those of the previous populationand the parents of those of the successive population. The initial population is generatedby randomly sampling the bits of all the strings. At each step, the new population isthen obtained by manipulating the strings of the old population in order to arrive ata new population hopefully characterized by an increased mean fitness. This sequencecontinues until a termination criterion is reached. As for the natural selection, the string

    manipulation consists in selecting and mating pairs of chromosomes in order to groomchromosomes of the next population. This is done by repeatedly performing on the stringsthe four fundamental operations of reproduction, crossover, replacement and mutation, allbased on random sampling 1. These operations will be detailed below.

    2. Definitions

    Individuals and Population: An individual is a chromosome, constituted by n 1 genesand a population is a collection of individuals. To code/decode the ith gene in a controlfactor, that is in an argument of the objective function, the user:

    defines the range (ai, bi) of the corresponding argument in the objective function;

    assignes the resolution of that independent variable by dividing the range (ai, bi) in2ni intervals. A number ni of bits is then assigned to the substring representative ofthe gene and the relation between a real value x (ai, bi) and its binary counterpart

    1 In the literature, the two operations of crossover and replacement are often unifiedand the resulting operation is called crossover, so that the fundamental operations are thenthree.

    1

  • 8/7/2019 Dispense Algoritmi Genetici

    2/24

    is

    x = ai + bi ai

    2ni

    The values ai, bi, ni are called the phenotyping parameters of the gene.Figure 1 shows the constituents of a chromosome made up of three genes and the relation

    between the genotype and the external environment, i.e. the phenotype, constituted bythree control factors, x1, x2, x3, one for each gene. The passage from the genotype tothe phenotype and viceversa is ruled by the phenotyping parameters of all genes, whichperform the coding/decoding actions. Each individual is characterized by a fitness, definedas the value of the objective function calculated in correspondence of the control factorspertaining to that individual. Thus a population is a collection of points in the solutionspace, i.e. in the space of f.

    0 0 01 1 10 01 10 001 1

    Gene # 1 Gene # 2 Gene # 3Chromosome

    Genotype

    Phenotypingparameters

    Phenotype x 1 x x 3

    1

    2

    2 3f(x ,x ,x )Fitness

    Bit-string

    Bit-strings(of assigned lengths)

    coding /decoding

    Factors(one for each gene)

    objective function

    Fig.1 Components of an individual (a chromosome) and its fitness.

    An important feature of a population is its genetic diversity: if the population is too small,the scarcity of genetic diversity may result in a population dominated by almost equalchromosomes and then, after decoding the genes and evaluating the objective function,in the quick convergence of the latter towards an optimum which may well be a localone. In other words, the algorithm could easily be trapped in a local optimum. At theother extreme, in too large populations, the overabundance of genetic diversity can leadto clustering of individuals around different local optima: then the mating of individuals

    belonging to different clusters can produce children (newborn strings) lacking the goodgenetic part of either of the parents. In addition, the manipulation of large populationsmay be excessively expensive in terms of computer time and the procedure does not differtoo much from a gridtype search.

    In most computer codes the population size is kept fixed at a value set by the user so asto suit the requirements of the model at hand. The individuals are left unordered, but anindex is sorted according to their fitnesses. During the search, the fitnesses of the newbornindividuals are computed and the fitness index is continuously updated.

    2

  • 8/7/2019 Dispense Algoritmi Genetici

    3/24

    3. Creation of the initial population

    As said in the Introduction, the initial population is generated by random sampling the bitsof all the strings. This procedure corresponds to uniformly sampling each control factorwithin its range. The chromosome creation, while quite simple in principle, presents somesubtleties worth to mention: indeed it may happen that the admissible hypervolume of the

    control factors is only a small portion of that resulting from the cartesian product of theranges of the single variables, so that one must try to reduce the search space by resorting tosome additional condition. In the Example n.1 below described (The Natural Gas PipelineSystem), the chromosome is made up of 150 bits so that the search hypervolume contains 1045 possible points. Obviously, it is highly improbable that an optimal solution can befound by a random search in such a huge space and indeed the search was unsuccessfuluntil we realized that the value sampled for a gene drastically reduced the admissible rangefor the successive gene of the chromosome. By adopting this condition, which we calledconditioned sampling, the search hypervolume was drastically reduced and the solutionwas readily found. The upshot is that the in the course of the population creation, a

    chromosome should be accepted only if suitable criteria are satisfied. This remark alsoapplies to the chromosome replacement, below described.

    4. The traditional breeding algorithm

    The breeding algorithm is the way in which the (n + 1)th population is generated fromthe nth previous one.

    The first step of the breeding procedure is the generation of a temporary new population.Assume that the user has chosen a population of size N (generally an even number). Thepopulation reproduction is performed by resorting to the Standard Roulette Selection rule:to find the new population, the cumulative sum of the fitnesses of the individuals in the oldpopulation is computed and normalized to sum to unity. The new population is generatedby random sampling individuals, one at a time with replacement, from this cumulative sumwhich then plays the role of a cumulative distribution function (cdf) of a discrete randomvariable (the position of an individual in the population). By so doing, on the average,the individuals in the new population are present in proportion to their relative fitness inthe old population. Since individuals with relatively larger fitness have more chance to besampled, most probably the mean fitness of the new population is larger.

    The second step of the breeding procedure, i.e. the crossover, is performed as indicated inFig.2: after having generated the new (temporary) population as above said, N/2 pairs ofindividuals, the parents, are sampled at random without replacement and irrespectively oftheir fitness, which has already been taken into account in the first step. In each pair, the

    corresponding genes are divided into two portions by inserting at random a separator in thesame position in both genes (onesite crossover): finally, the first portions of the genes areexchanged. 2 The two chromosomes so produced, the children, are thus a combination ofthe genetic features of their parents. A variation of this procedure consists in performing

    2 A different kind of crossover is the arithmetic crossover according to which the genesof the children are linear combinations of those of the parents. More specifically, let ai , bibe the control factors relating to the ith pair of homologous genes in the chromosomes of

    3

  • 8/7/2019 Dispense Algoritmi Genetici

    4/24

    the crossover with an assigned probability pc (generally rather high, say pc 0.6): arandom number R is uniformly sampled in (0, 1] and the crossover is performed only ifR < pc. Viceversa, if R pc, the two children are copies of the parents.

    0 01 1

    0 10 1

    0 00 1

    0 11 1

    crossover

    0 0 01 1 1

    0 1 100 1

    0 0 000 1

    0 1 111 1

    0 001 1

    1 111 0

    1 001 1

    0 111 0

    Parent # 1

    Parent # 2

    splice splice splice

    Child # 1

    Child # 2

    Fig.2 Example of crossover in a population with chromosomes constituted by three genes.

    The third step of the breeding procedure, performed after each generation of a pair ofchildren, concerns the replacement in the new population of two among the four involvedindividuals. The simplest recipe, again inspired by natural selection, just consists in thechildren replacing the parents: children live, parents die. In this case each individualbreeds only once.

    The fourth and last step of the breeding procedure eventually gives rise to the final (n+1)th population by applying the mutation procedure to the (up to this time temporary)population obtained in the course of the preceding steps. The procedure concerns themutation of some bits in the population, i.e. the change of some bits from their actualvalues to the opposite one (0 1) and viceversa. The mutation is performed on the basisof an assigned mutation probability for a single bit (generally quite small, say 103). Theproduct of this probability by the total number of bits in the population gives the meannumber of mutations. If < 1 a single bit is mutated with probability . Those bitsto be actually mutated are then located by randomly sampling their positions within theentire bit population.

    End of the search The sequence of successive population generations is usually stoppedaccording to one of the following criteria:

    i) when the mean fitness of the individuals in the population increases above an assignedconvergence value;

    the two parents. The control factors in the corresponding pair of chromosomes pertainingto the two children are ai = r ai + (1 r) bi) and bi = (1 r) ai + r bi), where r U(0, 1],i.e. a random number sampled from the uniform distribution.

    4

  • 8/7/2019 Dispense Algoritmi Genetici

    5/24

    ii) when the median fitness of the individuals in the population increases above an as-signed convergence value;

    iii) when the fitness of the best individual in the population increases above an assignedconvergence value. This criterion guarantees that at least one individual is goodenough;

    iv) when the fitness of the weakest individual in the population drops below an as-signed convergence value. This criterion guarantees that the whole population isgood enough;

    v) when the assigned number of population generations is reached.

    5. More sophisticated breeding procedures

    Reproduction: Alternative procedures are:

    i) Hybrid Roulette Selection: the main disadvantage of the Standard Roulette Selectionprocedure follows from the fact that the new individuals are actually sampled from a

    multinomial distribution, so that their fitnesses are fairly dispersed around the meanand the convergence towards the best solution can be delayed or even lost. The HybridRoulette Selection rule starts by normalizing the fitnesses to their sum and by samplingone of them as in the Standard Roulette Selection case. This normalized fitness isthen multiplied by the population size (number of individuals in the population) andthe integer part of the product yields the number of individuals, identical to thathaving fitness f in the old population, which are deterministically assigned to thenew population (of course, this number may be zero). The remainder of the aboveproduct is then treated as the probability of adding a further identical individual tothe new population. By so doing the permanence of good individuals, i.e. those withrelatively higher fitness, is favoured along the population sequence. However, the

    genetic diversity may decline.ii) Random Selection and Mating: the two parents are randomly selected with replace-

    ment over the entire population, regardless of the fitnesses of the individuals. Withrespect to both Roulette Methods, on the average, this procedure is more disruptiveof the genetic codes: in other words, the chromosomes of the two parents, suitablydecodified, can give rise to points very far from each other in the control factor spaceand, correspondingly, the fitnesses of the newborn children can be largely far apart inthe solution space.

    iii) FitFit Selection and Mating: the population is scanned by stepping through the fit-ness index and pairing each individual with the next fittest idividual. On the average,

    this procedure is highly conservative of the genetic information and a (generally local)maximum of the objective function is soon attained since weak individuals are rapidlyeliminated;

    iv) FitWeak Selection and Mating: as in the preceding case, the population is scannedby stepping through the fitness index, but this time each individual is paired withthat individual located in the symmetric position of the fitness index, with respect tothe mid of the fitness list. On the average, this procedure is highly disruptive of thegenetic codes, but it helps in improving the genetic diversity. It is seldom adopted.

    5

  • 8/7/2019 Dispense Algoritmi Genetici

    6/24

    In all the described procedures, after having selected the two parents and before proceed-ing to the selection of another couple, the two parents are crossed and the two individualsresulting from the adopted replacement procedure are immediately replaced in the popu-lation. Most important, before selecting the successive pair of parents, the fitness indexis immediately updated: by so doing the sampling is performed on a dynamically varying

    population.Crossover: An obvious generalization of the simple onesite crossing described above, is themultisite crossing, consisting the interposition of more than one separator in the substringsrepresentative of the homologous genes of the parents, followed by the exchange of piecesof the involved substrings. The simplest case is the twosite crossing: two separators arerandomly positioned in the homologous substrings and the bits between the two points areinterchanged. However it should be said that the multisite crossing is rarely adopted andthat the simple, onesite, crossover remains the most popular technique.

    Replacement: Alternative procedures are:i) Fittest individuals: out of the four individuals involved in the crossover procedure,

    the fittest two, parent or child, replace the parents. This procedure should not beused when weak individuals are discarded in the parent selection step, otherwise theweak individuals have a large chance to remain forever in the population.

    ii) Weakest individuals: the children replace the two weakest individuals in the entirepopulation, parents included, provided the children fitness is larger. This techniqueshortens the permanence of weak individuals in the successive populations and it isparticularly efficient in large populations.

    iii) Random replacement: the children replace two individuals randomly chosen in theentire population, parents included. By this technique, weak individuals have thesame chance as the fit ones of being included in the new population: therefore themethod is particularly efficient in small populations since it can give rise to a deep

    search in the space of the control factors.

    6. The ArchiveThe GA optimization procedure may be improved by implementing an archive in whichthe features of the best individuals appeared in the course of the various generations arestored. At the end of each generation, the best individual of the current population iscandidate for being cloned in the archive. As long as the archive is not full, the controlfactors and the fitness of this individual are directly stored in the archive. Later, when thearchive is full, the best individual in the population is compared with the worst individualin the archive and the one with better fitness survives whereas the other dies.The main advantage resulting from the inclusion of an archive in the GA process is thatit allows keeping track of the best individuals which appeared only in one or a few gener-ations and then disappeared because of the interplay of the various phases of the breedingprocedure.The presence of an archive has the further advantage of allowing the socalled elitistselection according to which, in the reproduction phase of the breeding algorithm, one ofthe two parents to be mated may be sampled with assigned probability from the archive.

    6

  • 8/7/2019 Dispense Algoritmi Genetici

    7/24

    7. Affine transform of the fitness

    In general, the initial population contains a majority of secondrate individuals togetherwith few chromosomes which, by chance, have moderately good fitnesses. Then, in a fewgenerations, the selection rules cause that these moderately good ones, which are actuallymediocre individuals, are selected as parents and generate children of similar fitnesses.

    Almost all the secondrate individuals disappear, and most of the population gathersin a small region of the search space around one of the mediocre individuals: the geneticdiversity is drastically reduced and we may have a premature convergence of the populationfitness towards a local maximum. In the course of the successive generations, the crossoverprocedure generates mediocre individuals in place of mediocre individuals and the geneticselection may be seen as a random walk among mediocres [GOL, p.77].To obviate to this unpleasant premature convergence to mediocrity, a pretreatment of thefitness function is welcome. In the following we shall approach this problem by means ofthe affine transform of the fitnesses: instead of applying the selection rules to the fitnessf(x) we shall use its affine transform f(x), viz.,

    f(x) = a f(x) + b

    with a > 0. Let fm , favg , fM and f

    m , f

    avg , f

    M be the minimum, average and maximumfitnesses before and after the transform, respectively. In case of the roulette selection, theprobability of sampling the kth individual is pk = fk/

    Ni=1 fi. After the transform, the

    same individual is sampled with probability

    pk =fkN

    i=1 f

    i

    =a fk + b

    aN

    i=1 fi + N b=

    pk +b

    a

    fi

    1 + N ba

    fi

    =pk +

    1

    Nb

    a favg

    1 + ba favg

    so thatpk = pk +

    bafavg

    (1

    N pk)

    Clearly, ifb were set to zero, the transform would be useless, since the probability of select-ing any population member would be the same before and after the transform. Otherwise,for b > 0, from the above equation it is seen that pk > pk provided pk < 1/N, that isprovided fk < favg . Therefore a positive b value favours the selection of lowly individualsand viceversa a negative b value favours the valuable ones.A first condition generally adopted for the determination of the coefficients a , b stemsfrom the following consideration: when going from a generation to the successive one,we must perform N samplings with replacement of individuals of the old generation to

    create the new N individuals. In these samplings the probability of getting k times theaverage individual obeys a binomial distribution with probability of success in a single trialpavg = favg /

    fi. The expected value of k is then N pavg = 1. Thus, on the average,

    the average individual is sampled once and then it has one child. To preserve this relationafter the fitness transform, the transformed and the original fitnesses should have equalaverage fitnesses, viz.,

    favg = favg or f

    avg = a favg + b

    7

  • 8/7/2019 Dispense Algoritmi Genetici

    8/24

    Note that from this condition it follows that the sum of the fitnesses is invariant withrespect to the transform, viz.,

    i

    fi =

    i

    fi

    Therefore, when the parents are selected in proportion to their fitnesses, we may comparethe probabilities of selecting the ith individual with reference to the original or to thetransformed fitness just by comparing the numerical values of fi and f

    i .The second condition follows from the above consideration that the evolution of the chro-mosome population may be divided in two phases:

    i) at the beginning, the lowly individuals are dispersed throughout the whole search spaceand the few best ones, situated by chance in more favourable regions of that space,are only moderately good ones. Then the average population fitness is very low. Inthe course of the successive generations, if we sample individuals in proportion of theirfitnesses, the population tends to accumulate around one of these moderately goodindividuals and the whole population soon becomes composed of similarly mediocre

    individuals. A local, likely mediocre, maximum is thereby attained. Viceversa, wemay increase the genetic diversity by biasing the sampling probabilities in such a waythat the new individuals are preferably created by the lowly ones which, as above said,are dispersed throughout the space. Now it is the whole search space the one which isaccurately spanned so that the portion of the space characterized by high fitness maybe arrived at, and the successive populations are driven to concentrate more and morein it. This biasing may be achieved by limiting the contribute of the best individual tothe next generation. IfC is the average offspring of the best individual, the conditionis that C should be not much larger than one: for typical small populations rangingin the interval from 50 to 100 individuals, Goldberg [GOL, p.77] suggests a C valuein the interval (1.2 , 2). This second condition yields the following expression for the

    transform of the maximum fitness

    fM = C favg or a f

    M + b = C favg

    The a , b values thereby resulting are

    a = (C 1) favgfM favg ; b = (fM C favg )

    favgfM favg

    The selection of the lowly individuals is then favoured provided b is positive, that isfor C < fM/favg . By so doing the few good individuals are scaled down and the

    majority of the mediocre members are scaled up;ii) later, with the progression of the generations, the fitness of the best individual im-

    proves but in the meantime the average fitness improves faster and gets close andclose to the best one. Then, it may happen that the above expressions for a, b yielda negative value for the minimum transformed fitness, fm, which is unacceptable. Insuch case the second condition is substituted by the following

    fm = 0

    8

  • 8/7/2019 Dispense Algoritmi Genetici

    9/24

    Then, the expressions for the a, b values are

    a =favg

    favg fm ; b = favg

    favg fm fm

    In this case b turns out to be negative so that the affine transform favours the selection

    of the valuable individuals.

    0 5 10 15 200

    5

    10

    15

    20

    start

    0 5 10 15 200

    5

    10

    15

    20

    later

    0 5 10 15 2010

    5

    0

    5

    10

    15

    20wrong

    0 5 10 15 200

    5

    10

    15

    20

    remedy

    Fig. 3: Qualitative evolution of the affine transforms

    Fig.3 qualitatively reports four plots which represent a possible evolution of the affinetransform along the generations. In all cases the straight lines are drawn through the twopoints (favg , f

    avg ) and (fM, f

    M). Note that at the start favg is close to fm (the majorityof the population is composed by secondrate individuals): later, favg increases fasterthan fM (secondrate individuals disappear while the fitness of the best individual slowlyincreases). The plot with the label wrong refers to the case in which fm would become

    negative so that the remedy is that of setting fm = 0.Example Let us consider the following function of two variables:

    f(x, y) =

    x sin(2x)

    y sin(2y)

    We are interested in finding the maximum of

    z(x, y) = f(x, y) for f(x, y) > 0

    0 otherwise

    9

  • 8/7/2019 Dispense Algoritmi Genetici

    10/24

    0

    1

    2

    3

    4

    5

    0

    1

    2

    3

    4

    5

    0

    1

    2

    3

    4

    5

    Fig. 4: Plot of z(x,y)

    This function, plotted in Fig.4, has 50 peaks but none of them is strongly dominating, asindicated by the fact that the global maximum is only 10 % higher than the second bestone. Therefore any search algorithm might be likely trapped in a local maximum. Makinguse of the GA technique, we tackled this problem with a population of 100 individuals.The results relating to the first 16 generations are shown in Fig.5. The upper 16 plotsrefer to the case of not performing the affine transforms of the fitnesses. The lower 16plots refer to the case of performing the affine transforms of the fitnesses. It appears thata maximum is reached earlier in the former case already at the 11th generation butthe maximum arrived at is only a local maximum. Viceversa, by performing the affinetransform, a thorough exploration of the search space is favoured which ends up later, atthe 16th generation, but with the attainment of the global maximum.

    10

  • 8/7/2019 Dispense Algoritmi Genetici

    11/24

    0 50

    50

    100

    1

    0 50

    50

    100

    2

    0 50

    50

    100

    3

    0 50

    50

    100

    4

    0 50

    50

    100

    5

    0 50

    50

    100

    6

    0 50

    50

    100

    7

    0 50

    50

    100

    8

    0 50

    50

    100

    9

    0 50

    50

    100

    10

    0 50

    50

    100

    11

    0 50

    50

    100

    12

    0 50

    50

    100

    13

    0 50

    50

    100

    14

    0 50

    50

    100

    15

    0 50

    50

    100

    16

    0 50

    50

    100

    1

    0 50

    50

    100

    2

    0 50

    50

    100

    3

    0 50

    50

    100

    4

    0 50

    50

    100

    5

    0 50

    50

    100

    6

    0 50

    50

    100

    7

    0 50

    50

    100

    8

    0 50

    50

    100

    9

    0 50

    50

    100

    10

    0 50

    50

    100

    11

    0 50

    50

    100

    12

    0 50

    50

    100

    13

    0 50

    50

    100

    14

    0 50

    50

    100

    15

    0 50

    50

    100

    16

    Fig.5: Results of the Example: Histograms of the population fitnesses during the first 16generations. Upper plot: without affine transform; lower plot: with affine transform.

    11

  • 8/7/2019 Dispense Algoritmi Genetici

    12/24

    The performance of the affine transform degrades in presence (actually improbable) ofone or more superfit individuals. Indeed, after the transform, a superfit individual isstill superfit, whereas the rest of the individuals are clustered around a single fitness. Tocircumvent this drawback one may firstly rank, say in ascending order, the chromosomesaccording to their fitnesses and then perform an affine transform only based on the ranks

    of the chromosomes. Thus

    fi = a + i b i = 1, 2, . . . , N

    In this case, fm = 1 and fM = N so that favg =N+12

    N2

    . Proceding as before, at thestart one has

    a = (C 1) N + 1N 1 C 1 , b = (N C

    N + 1

    2)

    N + 1

    N 1 N(1C

    2)

    so that C must be chosen in the interval 1 < C < 2 NN+1

    . Later, when fm tends to become

    negative, the above expressions for a and b are substituted by

    a =N + 1

    N 1 1 , b = N + 1

    N 1 1

    Finally,

    fi i 1 iIn this last case the fitnesses of the chromosomes are almost equal to their ranks.

    8. Inducement of Species and Niches

    In the present context, a species is defined as a class of individuals sharing common features,a niche is a set of functions performed by the individuals of a species and the environment isthe collection of the external conditions, including the interactions with the other species.Examples of species, niche and environment are the humans, the elephant hunters and theivory market, respectively.In nature, we observe a large number of species which live possibly competing si-multaneously. They develop or decline according to their degree of adaptability to theenvironmental changes and survive until the environment is propitious to them. In otherwords, each species has found a niche and survives until the niche is favourable.The above considerations have been suggested by the observations of the various species

    living on the earth. In particular, for our species, the individuals are partitioned in groupsaccording to the place they live in and the kinds of activities they carry out (niches). Thisdivision in groups, joined with a wise mixing of groups, has turned out to be of utmostadvantage for the survival and the development of the species.Let us now see how the grouping experience of the human species could be beneficial whensuitably transferred to the GAs. In particular, the problem here considered is that of seeinghow the rules so far described for the selection of the successive GA populations might bealtered. We shall describe three important techniques, only: the Isolation by Distance, the

    12

  • 8/7/2019 Dispense Algoritmi Genetici

    13/24

    Spatial Mating and the Sharing. In all cases, the choice of the parents is performed withina limited number of individuals and therefore with a remarkable saving of computer time.

    Isolation by Distance: The population of chromosomes is divided in subpopulations, i.e. ingroups of individuals with scarce mutual interactions. Adopting the jargon of demography,we may say that the individuals of each subpopulation live in isolated islands and that

    the various islands evolve separately, with different convergence rates, towards possiblydifferent solutions. Such a rigid picture of totally isolated islands may be lowered bythe introduction of emigrants. In general, the individuals living in an island mate withindividuals of the same group, but there is also a small number of wanderlust individuals,the emigrants, which travel to other islands looking for the ideal mate.The algorithmic implementation of the Isolation by Distance procedure is quite easy: thesubpopulations in the various islands reproduce separately following the rules describedin the preceding Sections for the whole population. Moreover, an emigration matrix Eis assigned, whose generic element Eij gives the emigration probability of an individualfrom island i to island j. Let us consider a particular island: at the beginning of eachreproduction step, the numbers of immigrants from the other islands is sampled from theprobability matrix E and the individuals selected as below specified are added to thenatives. In the meantime an equal number of native elements (generally the weakest) areeliminated in order to keep constant the population size. The selection of the individualsemigrating from an island may be done in several different ways. A couple of them are:

    i) at random from the current subpopulation. This choice results in a great mixing ofgenes which prevents an excessive similarity among the individuals of an island;

    ii) by sending copies of the fittest individual to the other islands. With respect to theprevious one, this choice is more guided and therefore the genetic diversity among thedifferent subpopulations is lower.

    Spatial Mating: The population is again divided in subpopulations called demes 3 but

    these now overlap almost totally. Around each individual is created a deme constitutedby an user assigned number of neighbours so that there is an equal number of individualsand demes. A first parent is selected throughout the entire population following one of theabove described rules, but its partner is now selected within the corresponding deme only.There are several definition of the deme topology:

    i) the individuals are disposed on a planar square grid and the deme of an individual isconstituted by its immediate neighbours (8, 24, 48, . . .);

    ii) the individuals are disposed on a monodimensional wheel and the deme of an individ-ual is constituted by an equal number of individuals symmetrically disposed aroundit (2, 4, 6, . . .);

    iii) the deme is the entire population, again disposed on a monodimensional wheel: the

    second parent is selected by means of a random walk game with a given intervalprobability, generally an exponential distribution with a mean value of few steps: inpractice the deme has a boundary of a few mean free paths.

    Sharing: In nature,when the place where a species lives starts to become crowded, a survivalpossibility is that the individuals agree to share the available resources. To do this, each

    3 A deme is one of the administrative divisions of the ancient Attica and of modernGreece.

    13

  • 8/7/2019 Dispense Algoritmi Genetici

    14/24

    individual which takes possession of some good must divide that good among the otherindividuals.Within the GA field, when a small portion of the search space is crowded by severalindividuals, it would be desirable that their fitnesses should be shared. A possible sharingaction may be accomplished during the breeding procedure. The selection of the parents

    and their replacement are performed making use of fitnesses modified in such a way thatthe natural fitness of each individual is decreased in relation to its similarity with theremaining individuals in the population. To specify the similarity:

    i) we define a distance between pairs of individuals. Possible distances dij betweenchromosomes i and j are:

    - distance between phenotypes:

    Euclidean distance dij =G

    k=1

    (xik xjk )2

    Chebyshev distance dij =

    Gk=1

    |xik xjk |

    where G is the number of genes in a chromosome and xrk is the control factor ofthe k-th gene in the rth chromosome.

    - distance between genotypes:

    Hamming distance dij =B

    k=1

    Hkij

    where B is the number of bits in a chromosome and

    Hkij = 1 if chromosomes i, j have equal k-th bit

    0 otherwise

    ii) we introduce a sharing function s(dij ) between chromosomes i and j defined in sucha way that s(0) = 1 and s(dij ) = 0 for dij , where is a users defined value:in words, a chromosome shares 1 with himself and 0 with chromosomes farther awaythan . Often, a linear s(d) is adopted in the interval (0, ).

    iii) Finally, the modified fitness fi of the ith chromosome is

    fi =fiN

    j=1 s(dij )

    From this expression it appears that the fitness of an isolated individual (large dis-tances from the other individuals and therefore small sharing function) is increasedwhereas all the fitnesses of the individuals of a cluster (small distances among theindividuals of the group and therefore large sharing functions) are reduced. By so

    14

  • 8/7/2019 Dispense Algoritmi Genetici

    15/24

    doing, the excessive growth of the number of individuals in a small portion of spaceis avoided.

    The main advantage of the inducement of niches by the various methods is the partition ofthe whole population in subpopulations which evolve towards the various maxima of theobjective function.

    9. Multiobjective optimization (Paretos dominance). The multiobjective opti-mization problem arises when in correspondence of each point x in the search space wemust consider several objective functions fi(x), i = 1, 2, . . . , N and then identify thatx which gives rise to the best compromise among the various objective functions. Thecomparison of two solutions is achieved by resorting to the concepts of Pareto dominance[SRI,1995] which enable solutions to be compared and ranked without imposing any apriori measure as to the relative importance of individual objectives, neither in form ofsubjective weights nor arbitrary constraints. We say that solution xa dominates solutionxb if xa is better on all objectives, i.e. if fi(xa) > fi(xb) for i = 1, 2, . . . , N . The solutionnot dominated by any other are said to be nondominated solutions. Once a populationof individuals (chromosomes) has been created, we rank the individuals according to thePareto dominance criterion by looking at the N dimensional space of the objective func-tions fi(x). Figure 6 illustrates the procedure: firstly, all nondominated individuals in thecurrent population are identified and rank 1 is assigned to them. Then these solutionsare virtually removed from the population and the next set of nondominated individu-als are identified and assigned rank 2. This process continues until every solution in thepopulation has been ranked.

    II I

    III IV

    2f

    f1

    P

    ranks

    4

    3

    2

    1f

    f

    2

    1

    a) b)

    Fig.6 Case of 2 objective functions.a) Subdivision of the points with respect to P.

    I Points which dominate P.III Points which are dominated by P.

    II, IV Points which neither dominate nor are dominated by P.b) Ranking of the population in classes of dominance.

    15

  • 8/7/2019 Dispense Algoritmi Genetici

    16/24

    The selection and replacement procedures of the multiobjective approach are based on thisranking: every solution belonging to the same rank class has to be considered equivalentto any other of the same class, i.e. it has the same probability of the others to be selectedas a parent for the mating.During the optimization search, the archive is only filled with the rank 1 individuals: at

    the end of each generation, all the nondominated solutions in the current population arecompared with those already stored in the archive and the following rules are implemented:

    i) if the new solution dominates existing members in the archive, these are removed andthe new solution added;

    ii) if the new solution is dominated by any member of the archive, it is not stored;ii) if the new solution neither dominates nor is dominated by any member of the archive,

    then if the archive is not full, the new solution is stored; if the archive is full, the new solution replace the most similar one in the archive.

    Obviously, this step requires that an appropriate concept of distance, such asthe euclidean one, must be introduced for measuring the similarity between two

    solutions.

    Application to the The Natural Gas Pipeline System

    Pipeline length

    1 2 i

    Q

    Q

    Q1 PD i

    i

    i+1PS

    i+1 10

    Q 10

    The operations of a naturalgas pipeline systems are characterized by inherent nonlin-earities and numerous constraints. The optimization, actually minimization, of the totalpower required by the compressors in the transmission of natural gas in a serial pipeline

    problem was proposed by Wong and Larson [WON, 1968] and solved by the dynamic pro-gramming method. Later, the same problem was solved by Goldberg [Gol, 1989, p.125]in the framework of the GAs. We shall now reconsider the problem by utilizing the GAs,with some variations with respect to the Goldbergs approach.Let us consider a natural gas pipeline constituted by 10 compressors serially connectedby 10 pipes, as schematically shown in the above Figure. The ith compressor receives agiven gas flow rate Qi1 at the suction pressure P Si and delivers a flow rate Qi at thedischarge pressure P Di.

    16

  • 8/7/2019 Dispense Algoritmi Genetici

    17/24

    Mathematical model. Under steady state condition it is assumed that:

    i) a known fraction ri1 of Qi1 is utilized as a fuel for operating the ith compressor,so that

    Qi = (1 ri1) Qi1 (i = 1, 2, . . . , 10)

    where the ris are known constants;

    ii) the equation relating the gas pressures at the beginning and at the end of the ithpipe connecting the compressors i and i + 1 is

    P D2i P S2i+1 = Ki Q2i (i = 1, 2, . . . , 10) (1)

    where the Kis are known constants;

    iii) the power required by the ith compressor is

    HPi = Qi

    Ai

    P DiP Si

    RiBi

    , (i = 1, 2, . . . , 10) (2)

    where Ki, Ai, Bi, Ri are given constants;

    iv) The pressures are subject to the following constraints:

    (Pi1)min P Si (Pi1)max (3)

    (Pi)min P Di (Pi)max (4)

    1 P DiP Si

    (Si)max (5)

    where (Si)max, (Pi)min, (Pi)max are given constants

    The problem may be stated as follows: given

    the suction pressure P S1 at the entrance;

    the flow rate Q0 at the entrance;

    the 80 constants ri , Ki , Ai , Ri , Bi , (Pi)min , (Pi)max , (Si)maxAll the ri = 5 103; the other constants are given in the Table),

    determine the 10 pressures P Si+1 , i = 1, . . . , 10 which satisfy the constraints iv) andminimize the total power required by all the compressors, viz.,

    HP =10

    i=1

    HPi

    17

  • 8/7/2019 Dispense Algoritmi Genetici

    18/24

    i Ki Ri Ai Bi Pi,min Pi,max Si,max[psi2 mmcfd2] [hp mmcfd1] [hp mmcfd1] [psi] [psi]

    1 0.800 0.217 215.8 213.9 500 1000 1.62 0.922 0.217 215.8 213.9 500 1000 1.63 1.870 0.217 215.8 213.9 500 1000 1.5

    4 0.894 0.217 215.8 213.9 500 1000 1.35 0.917 0.217 215.8 213.9 500 900 1.66 0.989 0.217 323.7 320.8 500 1000 1.67 0.964 0.217 215.8 213.9 500 900 1.758 1.030 0.217 215.8 213.9 500 1000 1.59 1.950 0.217 215.8 213.9 500 1000 1.6

    10 1.040 0.217 215.8 213.9 500 1000 1.6

    1 mmcfd (millions of cubic feet per day) = 0.3277 m3/s;1 psi (pounds per square inch) = 0.069 bar.

    A first attempt to solve this problem consisted in trying to start with an initial populationcreated by randomly sampling the bits of all the strings. Moreover, we adpted the Gold-bergs control factors, i.e. the Ui = P D

    2i + P S

    2i . At the end of the GA processing, some

    pressures turned out to be complex, some others out of their allowed ranges. In a secondattempt, we tried to accept the randomly created chromosomes provided they satisfy theconstraints: also this attempt was quite unsuccessful since the time required for the cre-ation of the initial population was exceedingly long. This was interpreted as an indicationthat, for some reason, the admissible ranges of some control factors are much smaller thanthe nominal ones, so that the probability that a randomly created gene could fall within itand therefore be accepted, is negligible. Finally, in a third attempt, assuming that a value

    sampled for a control factor would influence the ranges of the remaining ones, we adoptedthe conditional sampling: during the creation of the initial population, the first control fac-tor of each chromosome is sampled at random within the specified range; this value is theninserted in the expressions for the problem constraints and the admissible range for thesecond control factor is computed. When the second control factor is sampled within thisreduced range, it automatically satisfies its constraint. By applying this procedure to allthe control factors of a chromosome, the creation of new chromosomes was quite easy andfast. In addition the control factors were changed from the Goldbergs Ui = P D

    2i + P S

    2i to

    Ui = P Si+1. More specifically, consider the ith pipesection between compressors i andi + 1. The value P Si is known either from the calculation of the preceding pipesection orassigned as the initial condition for i = 1.

    The conditioned range for P Si+1 is evaluated as follows:i) From constraint (3) it follows that

    (Pi)2min P S2i+1 (Pi)2max

    ii) Moreover, from equation (1) it follows that

    P S2i+1 = P D2i KiQ2i

    18

  • 8/7/2019 Dispense Algoritmi Genetici

    19/24

    so that P S2i+1 must also belong to the range:

    (P Di)2min KiQ2i P S2i+1 (P Di)2max KiQ2i

    where the range of P D2i is established by constraints (4) and (5):

    max

    (Pi)2min, P S2i

    P D2i min (Pi)2max, (S1)2maxP S2i

    iii) Finally, the range for P Si+1 is

    max

    (Pi)2min, (P Di)

    2min KiQ2i

    P S2i+1 min (Pi)2max, (P Di)2max KiQ2i

    Once the range for P Si+1 is established, a value P Si+1 is uniformly sampled. Then it ispossible to proceed to the next pipesection.In this third attempt, the input values for the GA code were:

    i) Population constituted by 50 chromosomes with 10 genes per chromosome and 15 bits

    per gene; the ranges of all the 10 control factors where from 500 to 1000 psi;ii) parents selected by means of the fitweak method;

    iii) crossover performed with probability one, using a single separator;iv) replacement performed as follows:

    by selecting the fittest individuals with probability 500/555 by selecting the weakest individuals with probability 50/555 by the method children live, parents die with probability 4/555 by a random selection with probability 1/555

    v) mutation performed with probability 0.003vi) affine transform of the fitness with a coefficient C = 1.6.

    The figure below shows eight examples of chromosome initialisation by the conditionalsampling method: the vertical lines and the stars represent the admissible ranges and thesampled P Si values, respectively. Note the variation of the ranges of a specified controlfactor in the eight examples.

    0 5 10500

    600

    700

    800

    900

    1000

    0 5 10500

    600

    700

    800

    900

    1000

    0 5 10500

    600

    700

    800

    900

    1000

    0 5 10500

    600

    700

    800

    900

    1000

    0 5 10500

    600

    700

    800

    900

    1000

    0 5 10500

    600

    700

    800

    900

    1000

    0 5 10500

    600

    700

    800

    900

    1000

    0 5 10500

    600

    700

    800

    900

    1000

    19

  • 8/7/2019 Dispense Algoritmi Genetici

    20/24

    The following figure gives the mean ranges of the control factors during initialisation bythe conditional sampling method. Note the smallness of the mean range of the fourth gene:this smallness explains why the attempt to create a population by random sampling thecontrol factors over their nominal range was unsuccessful.

    0 1 2 3 4 5 6 7 8 9 10500

    550

    600

    650

    700

    750

    800

    850

    900

    950

    1000

    Medie degli spazi delle fasi dei singoli geni

    Geni

    Rangepermesso

    Mean ranges of the control factors during initialisation by the conditional sampling method

    The next figure represents the behaviour of the minimum and mean fitnesses along thegenerations: it appears that in 70 generations they attain their minimum values.

    0 50 100 1501.14

    1.16

    1.18

    1.2

    1.22

    1.24

    1.26

    1.28x 105

    Generation

    M

    eanhorsepower(...),minimumhorsepower()

    Minimum and mean fitnesses vs. generation number.

    The results we obtained for the pipeline system are shown in the following figure, togetherwith the Goldbergs ones: it appears that our results, obtained in 30 s, are slightlybetter.

    20

  • 8/7/2019 Dispense Algoritmi Genetici

    21/24

    1 2 3 4 5 6 7 8 9 1 0 11500

    550

    600

    650

    700

    750

    800

    850

    900

    950

    1000

    Compressor

    Pressure[psi]

    Application to a Simplified Nuclear Reactor Model

    This Section summarizes the results of a research published in [MAR, 2001]. We considerthe simple Chernicks nuclear reactor model [CHE,1960] to be used for predicting on linethe reactivity variation necessary to adapt the power production to the loads of the elec-trical grid. In order to predict the system behaviour starting from a given time t0, weuse pseudo experimental (i.e. obtained by simulation) power and reactivity data takenfrom the past reactor history back to a time t preceding t0 by, say, five days (severalcharacteristic times of the Xe and I dynamics). The interval (t, t0) is further divided intotwo subintervals: (t, t) during which we only use the reactor power, and (t, t0) duringwhich both the reactor power and the reactivity changes with respect to the value at t are

    used as experimental data. The model equations, written in terms of the available data,i.e. the reactor power P = f and the reactivity variation (t) = (t) (t), are:

    dP

    dt=

    (t) + xc f

    Xe f

    P

    P

    dXe

    dt= x P + II xXe x

    fXe P

    dI

    dt= I P I I

    where is the reactivity; (cm2

    s1

    ) is the flux; Xe (cm3

    ) and I (cm3

    ) are the Xenonand Iodine concentrations, respectively; f (cm

    1) is the effective fission macroscopic crosssection; x (cm

    2) is the effective Xenon microscopic cross section; x and I are the Xenonand Iodine fission yields, respectively; x (s

    1) and I (s1) are the Xenon and Iodine

    decay rates; (s) is the effective neutron mean generation time. The temperature andXenon feedbacks are modeled via the introduction of two lumped parameters, namely:the temperature feedback coefficient, (cm2 s) and the adimensional conversion factor ofXenon concentration to reactivity, c.

    21

  • 8/7/2019 Dispense Algoritmi Genetici

    22/24

    In this model, the assumed values for the known nuclear constants are x = 0.003, I =0.061, x = 2.09 105s1, I = 2.87 105s1 and the values to be estimated are thequintuplet of effective parameters x

    f, f

    , c, , (t) plus the Xe and I concentration at t.

    In addition to these parameters, the initial concentrations of the Xe and I should also beestimated.

    The model is admittedly very simple but the use of effective parameters to be periodicallyupdated renders it potentially very reliable. Thus, the strength of this approach mainlyrests in the capability of estimating the effective parameters.For the genetic algorithm, we consider chromosomes made up of five genes, each one codingone of the five effective parameters. Table 1 contains the relevant data. Each populationis composed of 1000 chromosomes. As objective function to be optimized, we consider theinverse of the average squared residuals R between the experimental power history andthe computed one normalized to the nominal power, summed over a succession of 2001discrete time points ti (t, t0).The values found by the genetic algorithm are reported in the second-to-last column ofTable 1. The resulting power profile from t to t0 turns out to be practically indistinguish-able from the corresponding (pseudo) experimental profile. Now, at the present time t0,we have available a good model, all its effective parameters and the Xe and I values, sothat we can predict the reactivity changes needed to satisfy future power load variations.

    Table 1: genetic algorithms data and parameters values for the reference power load profile.

    Simulation Genetic algorithmsphase

    Parameter True value Range (50%) # bits GA value Relativeerror (%)

    C 1.3606 0.6 - 2.0 10 1.2938 5.0

    /f 1016 8.3802 4.0 - 12.0 10 8.7148 4.0x/f 1018 3.5358 1.75 - 5.25 10 3.5290 0.2

    102 8.3000 4.0 - 13.0 10 9.8652 20.80 102 1.5063 0.75 - 2.5 10 1.3695 10.6

    Note that the described genetic algorithms procedure leads to very good results eventhough one of the parameters, namely the generation time , has a relative error closeto 20%, thus suggesting a scarse sensitivity of the results to such parameter. The largererror in the estimation of the mean generation time is due mainly to the fact that in thefirst equation of the model, multiplies the derivative of the power which is zero most of

    the time, except during the power variations: since these last only half an hour, not muchinformation is provided for the estimation of .

    22

  • 8/7/2019 Dispense Algoritmi Genetici

    23/24

    REFERENCES

    [CHA, 1995] Lance Chambers, Ed. Practical Handbook of Genetic Algorithms: Applica-tions Vol.I; New Frontiers Vol.II, CRC Press, 1995

    [CHE,1960] J. Chernick, The dynamics of a Xenon-Controlled Reactor, Nuclear Scienceand Engineering 8, pp. 233-243

    [GOL, 1989] D.E. Goldberg Genetic Algorithms in Search, Optimization, and MachineLearning AddisonWesley Publ. Co., 1989

    [MAR,2001] M. Marseguerra and E. Zio, Genetic Algorithms for Estimating Effective Pa-rameters in a Lumped Reactor Model for Reactivity Predictions, Nuclear Science and En-gineering 139, pp. 96-104.

    [SRI, 1995] N.Srinivas, K.Deb, Multiobjective Function Optimization Using NondominatedSorting Genetic Algorithms, Evolutionary Computation, 2 (3), pp.221248

    [WON, 1968] P.J. Wong and R.E. Larson, Optimization of NaturalGas Pipeline SystemsVia Dynamic Programming, IEEE Trans. Aut. Control, Vol. AC13, No.5, October 1968

    23

  • 8/7/2019 Dispense Algoritmi Genetici

    24/24

    [mar.testi.dispense]gal .tex 111-2001

    M. Marseguerra

    Notes on :

    Introduction to Genetic Algorithms

    A.A. 20012002