genetic algorithms
DESCRIPTION
Genetic Algorithms. What Do the Following 3 Things Have in Common?. Genetic Algorithms (GAs). GAs design jet engines. GAs draw criminals. GAs program computers. A Potpourri of Applications. General Electric’s Engineous (generalized engineering optimization). Face space (criminology). - PowerPoint PPT PresentationTRANSCRIPT
Page
Page
What Do the Following 3 Things What Do the Following 3 Things Have in Common?Have in Common?
Page
Genetic Algorithms (GAs)Genetic Algorithms (GAs)
• GAs design jet engines.
• GAs draw criminals.
• GAs program computers.
Page
A Potpourri of ApplicationsA Potpourri of Applications
1. General Electric’s EngineousEngineous (generalized engineering optimization).
2. Face space (criminology).
3. Genetic programming (machine learning).
Page
Gas Turbine DesignGas Turbine Design
Jet engine design at General Electric (Powell, Jet engine design at General Electric (Powell, Tong, & Skolkick, 1989) Tong, & Skolkick, 1989)
• Coarse optimization - 100 design variables. • Hybrid GA + numerical optimization + expert system. • Found 2% increase in efficiency. • Spending $250K $250K to test in laboratory.
• Boeing 777 designBoeing 777 design based on these results.
Page
EngineousEngineous
A new software system called Engineous combines artificial intelligence and numerical methods for the design and optimization of complex aerospace systems. Engineous combines the advanced computational techniques of genetic algorithms, expert systems, and object-oriented programming with the conventional methods of numerical optimization and simulated annealing to create a design optimization environment that can be applied to computational models in various disciplines.
Engineous has produced designs with higher predicted performance gains that current manual design processes - on average a 10-to-1 reduction of turnaround time - and has yielded new insights into product design. It has been applied to the aerodynamic preliminary design of an aircraft engine turbine, concurrent aerodynamic and mechanical preliminary design of an aircraft engine turbine blade and disk, a space superconductor generator, a satellite power converter, and a nuclear-powered satellite reactor and shield.
6 Source: Tong, S.S. ; Powell, D. ; Goel, S. Integration of artificial intelligence and numerical optimization techniques for the design of complex aerospace systems
Page
EngineousEngineous
7
Engineous Software, Inc. provides process integration and design optimization software solutions and services. The company's iSIGHT software integrates key steps in the product design process, then automates and executes those steps through design exploration tools like optimization, DOE, and DFSS techniques. The FIPER infrastructure links these processes together in a unified environment. Through FIPER, models, applications and "best" processes are easily shared, accessed, and executed with other engineers, groups, and partners. Engineous operates numerous sales offices in the U.S., as well as wholly owned subsidiaries in Asia and Europe.
Customers include leading Global 500 companies such as Canon, General Electric, General Motors, Pratt & Whitney, Honeywell, Lockheed Martin, Toshiba, MHI, Ford Motor Company, Chrysler, Toyota, Nissan, Renault, Hitachi, Peugeot, MTU Aero Engines, TRW, BMW, Rolls Royce, and Johnson Controls, Inc.
Additional information may be found at www.Engineous.com and http://components.Engineous.com.
Page
Recent news on EngineousRecent news on Engineous
8
Paris, France, and Providence, R.I., USA, June 17, 2008 – Dassault Systèmes (DS) (Nasdaq: DASTY; Euronext Paris: #13065, DSY.PA), a world leader in 3D and Product Lifecycle Management (PLM) solutions and Engineous Software, a market leader in process automation, integration and optimization, today announced an agreement in which DS would acquire Engineous Software.
This acquisition will extend SIMULIA’s leadership in providing Simulation Lifecycle Management solutions on the V6 IP collaboration platform. The proposed acquisition, for an estimated price of 40 million USD, should be completed before the end of July subject to specific closing conditions.
Dassault Systèmes to Acquire Engineous Software 06/17/2008
http://www.3ds.com/company/news-media/press-releases-detail/release//single/1789/?no_cache=1
Page
Criminal-likeness Reconstruction Criminal-likeness Reconstruction
No closed form fitness function (Caldwell & Johnston, 1991).
• Human witness chooses faces that match best.
• GA creates newfaces from whichto choose.
Page
What are GAs?What are GAs?
• GAs are biologically inspired class of algorithms that can be applied to, among other things, the optimization of nonlinear optimization of nonlinear multimodal functionsmultimodal functions.
• Solves problems in the same way that nature solves the problem of adapting living organisms to the harsh realities of life in a hostile world: evolutionevolution.
Let’s watch a video...
Page
What is a Genetic Algorithm (GA)?What is a Genetic Algorithm (GA)?
A GA is an adaptation procedure based on the mechanics of natural selection and genetics.
GAs have 2 essential components:
1. Survival of the fittest (selection) 2. Variation
Page
Nature as Problem SolverNature as Problem Solver
Beauty-of-nature argument
How Life Learned to Live (Tributsch, 1982, MIT Press)
Example: Nature as structural engineer
Page
Owl ButterflyOwl Butterfly
Page
Evolutionary is Revolutionary!Evolutionary is Revolutionary!
Street distinction evolutionary vs. revolutionary is false dichotomy.
3.5 Billion years of evolution can’t be wrong. Complexity achieved in short time in nature.
Can we solve complex problems as quickly and reliably on a computer?
Page
Why Bother?Why Bother?
Lots of ways to solve problems:
– Calculus – Hill-climbing – Enumeration – Operations research: linear,
quadratic, nonlinear programming Why bother with biology?
Page
Combinatorial ProblemCombinatorial Problem
e.g. Satisfiabilitye.g. Satisfiability
Is there a truth assignment to the boolean variables such that every clause is satisfied?
http://www.cs.sunysb.edu/~algorith/files/satisfiability.shtml
• deals with the study of finite or countable discrete structures• deciding when certain criteria can be met, and constructing and analyzing objects meeting the criteria
Page
Non-linear ProgrammingNon-linear Programming
17
In the diagram above there are many local minima; that is, points at the bottom of some portion of the graph
Consider the following nonlinear Consider the following nonlinear program:program:
minimise x(sin(3.14159x))subject to 0 <= x <= 6
nonlinear programming (NLP) is the process of solving a system of equalities and inequalities, collectively termed constraints, over a set of unknown real variables, along with an objective function to be maximized or minimized, where some of the constraints or the objective function are nonlinear
http://people.brunel.ac.uk/~mastjjb/jeb/or/nlp.html
Page
Why bother with biology?Why bother with biology?
RobustnessRobustness = BreadthBreadth ++ EfficiencyEfficiency.
Gradient search technique
A hypothetical problem spectrum:
Page
GAs Not NewGAs Not New
John Holland at University of MichiganUniversity of Michigan pioneered in the 50s.
Other evolutionaries: Fogel, Rechenberg, Schwefel. Back to the cybernetics movement and early computers. Reborn in the 70s.
Professor of Psychology and Electrical Engineering & Computer SciencePh.D. University of MichiganArea: Cognition and Cognitive Neuroscience
http://www.lsa.umich.edu/psych/people/directory/profiles/faculty/?uniquename=jholland
Page20
Genetic algorithmsGenetic algorithms
Variant of local beam search with sexual recombination.
Page21
How GAs are different from traditional How GAs are different from traditional methods?methods?
1. GAs work with a coding of the parameter setcoding of the parameter set, not the parameter themselves.
2. GAs search from a population of pointspopulation of points, not a single point.
3. GAs use payoff (objective functionobjective function) information, not derivatives or other auxilliary knowledge.
4. GAs use probabilistic transition rulesprobabilistic transition rules, not deterministic rules.
Page22
Traditional ApproachTraditional Approach
Problem:Problem: Maximise the function Maximise the function
f(f(S1, S2, S3, S4, S5S1, S2, S3, S4, S5) = sin(S1)) = sin(S1)22 * sin(S2) * sin(S2)2+s3 2+s3 - log- logee(S3)*S4-S5(S3)*S4-S5
Traditional approach: twiddle with the switch parameters.
y = f(y = f(S1, S2, S3, S4, S5S1, S2, S3, S4, S5))
output
Setting of five switches
S1, S2, S3, S4, S5
Page 23
Genetic AlgorithmGenetic Algorithm
Natural parameter set of the optimisation problem is represented as a finite-length stringfinite-length string
output
Setting of five switchesGA doesn’t need to know the workings of the black box.
00
f(x)
x 3131S1, S2, S3, S4, S5
y = f(y = f(S1, S2, S3, S4, S5S1, S2, S3, S4, S5))
Problem:Problem: Maximise the function Maximise the function
f(f(S1, S2, S3, S4, S5S1, S2, S3, S4, S5) = sin(S1)) = sin(S1)22 * sin(S2) * sin(S2)2+s3 2+s3 - log- logee(S3)*S4-S5(S3)*S4-S5
Page24
Main Attractions of Genetic AlgorithmMain Attractions of Genetic Algorithm
GAGA
• Simplicity of operation and power of effect
Traditional Optimization ApproachesTraditional Optimization Approaches
• Limitations: continuity, derivative existence, unimodality
• unconstrainedunconstrained
• work from a rich database of points simultaneouslysimultaneously, climbing many peaks in parallel
• move gingerly from a single point in the decision space to the next using some transition rule
• population of strings = points• Population of well-adapted diversityPopulation of well-adapted diversity
Page
GAGA
25
maximise 2x1 + x2 - 5loge(x1)sin(x2)subject tox1x2 <= 10 | x1 - x2 | <= 20.1 <= x1 <= 5 0.1 <= x2 <= 3
Source: Nonlinear Programming, by J E Beasley http://people.brunel.ac.uk/~mastjjb/jeb/or/nlp.html
• works from a rich database of points simultaneouslysimultaneously, climbing many peaks in parallel
Page
Page27
Genetic AlgorithmGenetic Algorithm
• Initial Step: Initial Step: random start using successive coin flips
GAGA
populationpopulation
• blind to auxiliary information
• Searches from a population
GA uses coding
GAs are blind, only payoff values associated with individual strings are required
Uses probabilistic transition rules to guide their search towards regions of the search space with likely improvement
01101110000100010011
Page
Page29
Genetic AlgorithmGenetic Algorithm
• SelectionSelection according to fitnessfitness
REPRODUCTIONREPRODUCTION
01101110000100010011
populationpopulation
• ReplicationReplication
• CrossoverCrossover – randomized information exchange
GA uses coding
Mating pool (tentative population)
Crossover point k = [1, l-1]
1
2
3
4
Weighted Roulette wheel
GA builds solutions from the past partial solutions of the previous trials
CROSSOVERCROSSOVER
Page
Page31
Genetic AlgorithmGenetic AlgorithmMUTATIONMUTATION
• ReproductionReproduction and crossoverand crossover may become overzealous and lose some potentially useful genetic material
• MutationMutation protects against irrecoverable loss; it serves as an insurance policy against premature loss of important notions
• Mutation rates: in the order of 1 mutation per a thousand bit position transfers1 mutation per a thousand bit position transfers
Page
Page33
Genetic Algorithm: ExampleGenetic Algorithm: Example
1. Coding of decision variables as some finite length stringCoding of decision variables as some finite length string
X as binary unsigned integer of length 5
[0, 31] = [00000, 11111]
2.2. Constant settingsConstant settings
Pmutation=0.0333
Pcross=0.6
Population Size=30
DeJong(1975) suggests high crossoverProbability, low mutation probability (inversely proportional to the pop.size), andA moderate population size
Problem:Problem: Maximise the function Maximise the function f(x) = xf(x) = x2 2 on the integer interval [0, on the integer interval [0, 31]31]
Page34
Genetic Algorithm: ExampleGenetic Algorithm: Example
String number
Initial Population
X value f(x) pselect Expected count
Actual count(Roulette Wheel)
1 01101 13 169 0.14 0.58 1
2 11000 24 576 0.49 1.97 2
3 01000 8 64 0.06 0.22 0
4 10011 19 361 0.31 1.23 1
f
fi
SAMPLE PROBLEMSAMPLE PROBLEM
3. Select initial population at random Select initial population at random ((use even numbered population size))
Sum 1170Ave. 293Max. 576
f
fi
• Maximize f(x) = xMaximize f(x) = x22; where x is permitted to vary between 0 and 31; where x is permitted to vary between 0 and 31
Page35
Genetic Algorithm: ExampleGenetic Algorithm: Example
1
2
3
4
SAMPLE PROBLEMSAMPLE PROBLEM
4. Reproduction: Reproduction: select mating pool by spinning roulette wheel 4 times.
Weighted Roulette wheel
01101110000100010011
14.4%14.4%
49.249.2
30.9%30.9%
5.5%5.5%
0.14
0.49
0.06
0.31
pselect
The best get more copies.The average stay even.The worst die off.
• Maximize f(x) = xMaximize f(x) = x22; where x is permitted to vary between 0 and 31; where x is permitted to vary between 0 and 31
Page36
Choosing offspring for the next generationChoosing offspring for the next generation
int SelectSelect(int Popsize, double Sumfitness, Population Pop){ partSum = 0
rand=RandomRandom * Sumfitnessj=0Repeat j++;
partSum = partSum + Pop[j].fitnessUntil (partSum >= rand) or (j = Popsize)
Return j}
[0,1]
Page37
Genetic AlgorithmGenetic Algorithm
String number
Mating Pool after Reproduction
Mate (randomly selected)
Crossover site (random)
New population
X-value f(x)=x2
1 0110|1 2 4 01100 12 144
2 1100|0 1 4 11001 25 625
3 11|000 4 2 11011 27 729
4 10|011 3 2 10000 16 256
SAMPLE PROBLEMSAMPLE PROBLEM
5.5. CrossoverCrossover – strings are mated randomly using coin tosses to pair the couples
Sum 1754Ave. 439Max. 729
- mated string couples crossover using coin tosses to select the crossing site
Page
Page39
The Genetic AlgorithmThe Genetic Algorithm
1. Initialize the algorithm.
Randomly initialize each individualindividual chromosomechromosome in the population of size N (N must be eveneven), and compute each individual’s fitnessfitness.
Page40
The Genetic AlgorithmThe Genetic Algorithm
1. Initialize the algorithm. Randomly initialize each individual chromosome in the population of size N (N must be even), and compute each individual’s fitness.
2. Select N/2N/2 pairspairs of individuals for crossover. The probability that an individual will be selected for crossover is proportional to its fitnessfitness.
Page41
The Genetic AlgorithmThe Genetic Algorithm
1. Initialize the algorithm. Randomly initialize each individual chromosome in the population of size N (N must be even), and compute each individual’s fitness.
2. Select N/2 pairs of individuals for crossover. The probability that an individual will be selected for crossover is proportional to its fitness.
3. Perform crossovercrossover operation on N/2 pairs selected in Step1.
Randomly mutatemutate bits with a small probability during this operation.
Page42
The Genetic AlgorithmThe Genetic Algorithm
1. Initialize the algorithm. Randomly initialize each individual chromosome in the population of size N (N must be even), and compute each individual’s fitness.
2. Select N/2 pairs of individuals for crossover. The probability that an individual will be selected for crossover is proportional to its fitness.
3. Perform crossover operation on N/2 pairs selected in Step1. Randomly mutate bits with a small probability during this operation.
4. Compute fitnessfitness of all individuals in new population.
Page43
The Genetic AlgorithmThe Genetic Algorithm5. (Optional Optimization)
Select NN fittest individuals from combined population of size 2N2N consisting of old and new populations pooled together.
Page44
The Genetic AlgorithmThe Genetic Algorithm5. (Optional Optimization) Select N fittest individuals from combined
population of size 2N consisting of old and new populations pooled together.
6. (Optional Optimization)
Rescale fitness of population.
Page45
The Genetic AlgorithmThe Genetic Algorithm5. (Optional Optimization) Select N fittest individuals from combined population of size 2N consisting
of old and new populations pooled together.
6. (Optional Optimization) Rescale fitness of population.
7. Determine maximummaximum fitnessfitness of individuals in the population.
If |max fitness – optimum fitness| < tolerance Then Stop
Else
Go to Step1.
Page47
A Simple GA ExampleA Simple GA Example
Page48
Let’s see a demonstration for a GA that maximizes the function
n
c
xxf
)(
n =10cc = 230 -1 = 1,073,741,823
Page49
Simple GA ExampleSimple GA Example Function to evaluate:
coeff – chosen to normalize the x parameter when a bit string of length lchrom =30 is chosen.
When the x value is normalized, the max. value of the function will be:
This happens when for the case when lchrom=30
10
( )x
f xcoeff
302 1coeff
( ) 1.0f x 302 1x
Fitness Function or Objective
Function
Page50
Test Problem CharacteristicsTest Problem Characteristics
With a string length=3030, the search space is much larger, and random walk or enumeration should not be so profitable.
There are 223030=1.07(10=1.07(101010) points) points. With over 1.07 billion points in the space, one-at-a-time methods are unlikely to do very much very quickly. Also, only 1.051.05 percent of the points have a value greater than 0.90.9.
Page51
Comparison of the functions on the unit Comparison of the functions on the unit intervalinterval
00
f(x)
x 3131
00
f(x)
x 1,073,741,8231,073,741,823
x10
x2
Page
Actual PlotActual Plot
52
Page53
Decoding a StringDecoding a String For every problem, we must create a procedure
that decodes a string to create a parameter (or set of parameters) appropriate for that problem.
11010101
DECODE
1073741823.0
OBJ FCN
Chromosome
Fitness or Figure of Merit
Parameter
first bit
Page54
GA ParametersGA Parameters
A series of parametric studies [De Jong, 1975] across a A series of parametric studies [De Jong, 1975] across a five function suite of optimization problems suggested that five function suite of optimization problems suggested that good GA performance requires the choice of:good GA performance requires the choice of:– High crossover probability– Low mutation probability (inversely proportional
to the population size)– Moderate Population Size
(e.g. pmutationpmutation=0.0333, pcrosspcross=0.6, popsizepopsize=30=30)
Page55
Limits of GALimits of GA
• GAs are characterized by a voracious appetite for processing power and storage capacity.
• GAs have no convergence guarantees in arbitrary problems.
Page56
Limits of GAsLimits of GAs
• GAs sort out interesting areas of a space quickly, but they are a weak method, without the guarantees of more convergent procedures.
• This does not reduce their utility however. More convergent methods sacrifice globality and flexibility for their convergence, and are limited to a narrow class of problem.
• GAs can be used where more convergent methods dare not tread.
Page57
Advantages of GAsAdvantages of GAs
• Well-suited to a wide-class of problems
• Do not rely on the analytical properties of the function to be optimized (such as the existence of a derivative)
Page58
Advanced GA ArchitecturesAdvanced GA Architectures
GA + Any Local Convergent MethodGA + Any Local Convergent Method– Start search using GA Start search using GA to sort out the
interesting hills in your problem. Once GA ferrets out the best regions, apply apply locally convergent schemelocally convergent scheme to climb the local peaks.
Page59
Other ApplicationsOther Applications
Optimization of a choice of Fuzzy Logic parameters
Page60
Simple GA ImplementationSimple GA Implementation
Initial population of chromosomes
Calculate fitness value
PopulationOffspring
Stop
SolutionFound?
Evolutionaryoperations
Yes
No
Page
Based on SGA-C, A C-language Implementation of aSimple Genetic Algorithm
Let’s see the documentation (pdf file)Let’s see the documentation (pdf file)
Page62
Phase 1 – Phase 1 – General InitialisationGeneral Initialisation
Initialise Parameters()
Initialise Population()
Randomize()
Warmup_Random()
Advance_Random()
Decode()
Objective Function()
Page63
Phase 2 – Phase 2 – Generation of ChromosomesGeneration of Chromosomes
Generation() SelectIndividual()
CrossOver()
Mutation()
Page64
Running the GA SystemRunning the GA System
Gen = 0 Initialize( OldPop ) Do Gen = Gen + 1 Generation( OldPop, NewPop ) For ii = 1 To PopSize OldPop(ii) = NewPop(ii) 'advance the generation'advance the generation Next ii Loop Until ( (Gen > MaxGen) or (MaxFitness > DesiredFitness) )
Page65
InitialisationInitialisationInitialise Parameters
PopSize = 30 'population size'population size lchrom = 30 'chromosome length'chromosome length MaxGen = 10 PCross = 0.6 PMutation = 0.0333 ReDim GenStat(1 To (MaxGen + 1)) 'Initialize random number generator'Initialize random number generator Randomize 'Initialize counters'Initialize counters NMutation = 0 NCross = 0
Page66
RandomizationRandomizationRandomize
Sub Randomize() Randomize Timer Warmup_Random (Rnd * 1)End Sub
[0,1]
Page67
RandomizationRandomizationWarmup_Random()
Sub Warmup_Random(RandomSeed As Single) Dim j1 As Integer Dim ii As Integer Dim NewRandom As Single Dim PrevRandom As Single OldRand(55) = RandomSeed NewRandom = 0.000000001 PrevRandom = RandomSeed For j1 = 1 To 54
ii = (21 * j1) Mod 55 'multiply first, before modulus'multiply first, before modulus OldRand(ii) = NewRandom NewRandom = PrevRandom - NewRandom If (NewRandom < 0) Then NewRandom = NewRandom + 1 PrevRandom = OldRand(ii)
Next j1 Advance_Random Advance_Random Advance_Random jrand = 0End Sub
[0, 1]
[0, 1]
Page68
RandomizationRandomizationAdvance_Random()
Sub Advance_Random() Dim j1 As Integer Dim New_Random As Single For j1 = 1 To 24 New_Random = OldRand(j1) - OldRand(j1 + 31) If (New_Random < 0) Then New_Random = New_Random + 1 OldRand(j1) = New_Random Next j1 For j1 = 25 To 55 New_Random = OldRand(j1) - OldRand(j1 - 24) If (New_Random < 0) Then New_Random = New_Random + 1 OldRand(j1) = New_Random Next j1End Sub
Max: 24+31=55
Max: 55-24=31
Page
RandomRandom
69
'Fetch a single random number between 0.0 and 1.0 - Subtractive Method'See Knuth, D. (1969), v. 2 for details
Function Random() As Single jrand = jrand + 1 If jrand > 55 Then jrand = 1 Advance_Random End If Random = OldRand(jrand)End Function
Knuth, 1969. D.E. Knuth The Art of Computer Programming 2, Addison-Wesley, Reading, MA (1969).
Page70
Initialise PopulationInitialise PopulationInitPop()
Sub InitPop() Dim j As Integer Dim j1 As Integer For j = 1 To PopSize
With OldPop(j) For j1 = 1 To lchrom .Chromosome(j1) = Flip(0.5) Next j1 .x = Decode(.Chromosome, lchrom) 'decode the string .Fitness = ObjFunc(.x) 'evaluate initial fitness .Parent1 = 0 .Parent2 = 0 .XSite = 0
End With Next jEnd Sub
Max: 24+31=55
Page71
Initialise PopulationInitialise PopulationDecode()
'decodes the string to create a parameter or set of parameters'appropriate for that problem'Decode string as unsigned binary integer: true=1, false=0
Function Decode(Chrom() As Boolean, lbits As Integer) As Single Dim j As Integer Dim Accum As Single Dim PowerOf2 As Single Accum = 0 PowerOf2 = 1 For j = 1 To lbits If Chrom(j) Then Accum = Accum + PowerOf2 PowerOf2 = PowerOf2 * 2 Next j Decode = AccumEnd Function Binary to decimal conversionBinary to decimal conversion
Page72
Initialise PopulationInitialise PopulationObjective Function()
'Fitness function = f(x) = (x/c) ^ n
Function ObjFunc(x As Single) As Single 'coef = (2 ^ 30)-1 = 1073741823'coef is chosen to normalize the x parameter when a bit string of length lchrom=30 is chosen 'since the x value has been normalized, the maximum value of the fcn wil be f(x)=1, 'when x=(2^30)-1, for the case when lchrom=30 Const coef As Single = 1073741823 'coefficient to normalize domain Const n As Single = 10 'power of x ObjFunc = (x / coef) ^ n
End Function
Page73
Generation of ChromosomesGeneration of ChromosomesSelectIndividual()
Function SelectIndividualSelectIndividual(PopSize As Integer, SumFitness As Single, Pop() As IndividualType) As Integer Dim RandPoint As Single Dim PartSum As Single Dim j As Integer PartSumPartSum = 0 j = 0 RandPoint RandPoint = Random * SumFitness Do 'find wheel slot jj = jj + 1 PartSumPartSum = PartSumPartSum + Pop(j).Fitness
Loop Until ((PartSumPartSum >= RandPoint RandPoint ) Or (jj = PopSize)) SelectIndividual = jjEnd Function
Select a single individual or offspring for the next generation via roulette wheel selection
Page74
Generation of ChromosomesGeneration of ChromosomesCrossOver()
Function CrossOver(Parent1() As Boolean, Parent2() As Boolean, Child1() As Boolean, Child2() As Boolean, lchrom As Integer, NCross As Integer, NMutation As Integer, jcross As Integer, Pcross, PMutation As Single) Dim j As Integer If (Flip(PCross)) Then jcross = Rndx(1, lchrom - 1) 'cross-over site is selected between 1 and the last cross site'cross-over site is selected between 1 and the last cross site NCross = NCross + 1 Else ‘ use full-length string l, and so a bit-by-bit mutation will take place despite the absence of a cross‘ use full-length string l, and so a bit-by-bit mutation will take place despite the absence of a cross jcross = lchrom End If For j = 1 To jcross ‘ 1st exchange, 1 to 1 and 2 to 2‘ 1st exchange, 1 to 1 and 2 to 2 Child1(j) = Mutation(Parent1(j), PMutation, NMutation) Child2(j) = Mutation(Parent2(j), PMutation, NMutation) Next j If jcross <> lchrom Then ‘ 2nd exchange, 1 to 2 and 2 to 1‘ 2nd exchange, 1 to 2 and 2 to 1 For j = jcross + 1 To lchrom Child1(j) = Mutation(Parent2(j), PMutation, NMutation) Child2(j) = Mutation(Parent1(j), PMutation, NMutation) Next j End IfEnd Function
CrossOver OldPop(Mate1).Chromosome, OldPop(Mate2).Chromosome, _ NewPop(j).Chromosome, NewPop(j + 1).Chromosome, _ lchrom, NCross, NMutation, jcross, PCross, PMutation
Page75
Generation of ChromosomesGeneration of ChromosomesMutation()
'Mutate an allele with PMutation, count number of mutations'Mutate an allele with PMutation, count number of mutations
Function Mutation(Alleleval As Boolean, PMutation As Single, NMutation As Integer) As Boolean Dim Mutate As Boolean Mutate = Flip(PMutation) If Mutate Then NMutation = NMutation + 1 Mutation = Not Alleleval Else Mutation = Alleleval End IfEnd Function
Function Flip(Probability As Single) As Boolean If Probability = 1 Then Flip = True Else Flip = (Rnd <= Probability) End IfEnd Function
Page76
Generation of ChromosomesGeneration of ChromosomesGeneration()Sub Generation()
Dim j As Integer Dim Mate1 As Integer Dim Mate2 As Integer Dim jcross As Integer j = 1 Do 'Pick a pair of mates'Pick a pair of mates Mate1 = SelectIndividual(PopSize, SumFitness, OldPop) Mate2 = SelectIndividual(PopSize, SumFitness, OldPop) 'Crossover and mutation - mutation embedded within crossover'Crossover and mutation - mutation embedded within crossover CrossOver OldPop(Mate1).Chromosome, OldPop(Mate2).Chromosome, _ NewPop(j).Chromosome, NewPop(j + 1).Chromosome, _ lchrom, NCross, NMutation, jcross, PCross, PMutation 'Decode string, evaluate fitness & record parentage date on both children'Decode string, evaluate fitness & record parentage date on both children With NewPop(j) .x = Decode(.Chromosome, lchrom) .Fitness = ObjFunc(.x) .Parent1 = Mate1 .Parent2 = Mate2 .XSite = jcross End With
With NewPop(j + 1) .x = Decode(.Chromosome, lchrom) .Fitness = ObjFunc(.x) .Parent1 = Mate1 .Parent2 = Mate2 .XSite = jcross End With j = j + 2 'increment population index Loop Until (j > PopSize)End Sub
Page
What sort of traits do fit chromosomes carry to survive generations after generations of mating and mutation?
Page78
SchemaSchema
A SchemaSchema is a similarity template describing a subset of strings with similarities at certain string positions.
We can think of it as a pattern matching pattern matching device:
a schema matches a particular string if at every location in the schema a 1 matches a 1 in the string, or a 0 matches a 0, or an ** matches either.
Page
Notation: Notation: SchemaSchema
79
For a binary alphabet {{00, , 11}}, we motivate a schema by appending a special symbol **, or don’t care symbol, producing a ternary alphabet:
V={ V={ 00, , 11, , ** }; };
* asterisk * asterisk is a don’t care symbol which matches either a 0 or a 1 at a particular position.
This allows us to build schemata:e.g.e.g.
H H = *11*0**= *11*0**StringString A A = 0111000= 0111000
Page80
They provide the basic means for analyzing the net effect of reproductionreproduction and genetic operatorsgenetic operators on the building blocks contained within the population.
Understanding the building blocks of future solutionsUnderstanding the building blocks of future solutions
Schema PropertiesSchema Properties
Schemata and their properties serve as notational devices for rigorously discussing and classifying string similaritiesstring similarities.
Page81
Schema MatchingSchema Matching
A bit stringbit string matches a particular schemataschemata if that bit string can be constructed from the schemata by replacing the symbol with the appropriate bit value.
e.g.e.g.
H H = *11*0**= *11*0**StringString A A = 0111000= 0111000
String String AA is an example of the schema is an example of the schema HH because the string alleles because the string alleles aaii match match
schema positions schema positions hhii at the fixed positions at the fixed positions
2, 32, 3 and and 55..
Page 82
Order of Schema:o(H) o(H) – is the number of fixed positions present in the template
Understanding the building blocks of future solutionsUnderstanding the building blocks of future solutions
Schema PropertiesSchema Properties
Schema Order:o(011*1**) = 4
Schema Defining Length: δ(H) = 5-1 = 4
011*1**
Schema Order:o(0******) = 1
0******Schema Defining Length: δ(H) = 0, because
there is only one fixed position
Defining Length of Schema:δδ(H) (H) – is the distance between the first and last specific string position
Page83
What happens to a particular schema when crossover is introduced?
Crossover leaves a schema unscathed if it does not cut the schema; otherwise it disrupts it.
e.g.e.g.
H1 H1 = 1***0= 1***0 H2 H2 = **11*= **11*
H1H1 is likely to be disrupted by crossover. is likely to be disrupted by crossover.H2H2 is relatively unlikely to be destroyed. is relatively unlikely to be destroyed.
Effects of Effects of CrossoverCrossover on a Schema on a Schema
Page84
What happens to a particular schema when mutation is introduced?
Mutation at normal, low rates does not disrupt a particular schema very frequently.
e.g.e.g.
H1 H1 = 110*0= 110*0 H2 H2 = **11*= **11*
H1H1 is relatively more likely to be disrupted by mutation (many is relatively more likely to be disrupted by mutation (many alleles that can be altered).alleles that can be altered).H2H2 is relatively unlikely to be mutated because it has a lower is relatively unlikely to be mutated because it has a lower order than H1.order than H1.
Effects of Effects of Mutation Mutation on a Schemaon a Schema
Page85
Building blocksBuilding blocks
Highly-fitHighly-fit, low-orderlow-order, short-defining-lengthshort-defining-length schemata (building blocks)
are propagated generation to generation by giving exponentially increasing samples to the observed best;
Who shall live and who shall die?
All these goes in parallel with no special bookkeeping or special memory other than our population of n strings.
Page
How do we choose a good coding?
Page87
Principles for Choosing a GA CodingPrinciples for Choosing a GA Coding
The user should select a coding so that short, low-order schemata are relevant to the underlying problem and relatively unrelated to schemata over other fixed positions.
When we design a coding, we should check the distances between related bit positions.
11 Principle of Meaningful Blocks
Page88
Principles for Choosing a GA CodingPrinciples for Choosing a GA Coding
The user should select the smallest alphabet that permits a natural expression of the problem.
In our previous examples, we were using binary coding. Was that a good choice then?
22 Principle of Minimal Alphabets
Page89
Principles for Choosing a GA CodingPrinciples for Choosing a GA Coding
Non-binary CodingNon-binary Coding: 26-letter alphabet {A-Z}, six digits {1-6}
Example: Refer to our previous problem
Binary String
Value X Non-binary String
Fitness
01101 13 N 169
11000 24 Y 576
01000 8 I 64
10011 19 T 361
We want to represent 32 possible values: [0, 31]
Binary CodingBinary Coding: {0, 1}
• Maximize f(x) = xMaximize f(x) = x22; where x is permitted to vary between 0 and 31; where x is permitted to vary between 0 and 31
Page90
Number of Schemata for a GA CodingNumber of Schemata for a GA Coding
Non-binary CodingNon-binary Coding: 26-letter alphabet {A-Z}, six digits {1-6}
Binary String Value X Non-binary String
Fitness
01101 13 N 169
11000 24 Y 576
01000 8 I 64
10011 19 T 361
We want to represent 32 possible values: [0, 31]
Binary CodingBinary Coding: {0, 1}
For equality of the number of points in each space, we require: 2l = km
Where l = binary code length, m = non-binary code length
Example: Refer to our previous problem
• Maximize f(x) = xMaximize f(x) = x22; where x is permitted to vary between 0 and 31; where x is permitted to vary between 0 and 31
Page
91
Number of Schemata for a GA CodingNumber of Schemata for a GA Coding
Non-binary CodingNon-binary Coding: 26-letter alphabet {A-Z}, six digits {1-6}
We want to represent 32 possible values: [0, 31]
Binary CodingBinary Coding: {0, 1}
For equality of the number of points in each space, we require: 2l = km
Where l = binary code length, m = non-binary code length
The number of schemata may then be calculated as:
Binary case: Binary case: 33ll ; 2+1 (asterisk) alphabets
Non-Binary case: Non-Binary case: (k+1)k+1)mm ; k+1 (asterisk) alphabets
Example: Refer to our previous problem
• Maximize f(x) = xMaximize f(x) = x22; where x is permitted to vary between 0 and 31; where x is permitted to vary between 0 and 31
Page
92
Number of Schemata for a GA CodingNumber of Schemata for a GA Coding
Non-binary CodingNon-binary Coding: 26-letter alphabet {A-Z}, six digits {1-6}
We want to represent 32 possible values: [0, 31]
Binary CodingBinary Coding: {0, 1}
For equality of the number of points in each space, we require: 2l = km
Where l = binary code length, m = non-binary code length
The number of schemata may then be calculated as:
Binary case: Binary case: 33ll ; 2+1 (asterisk) alphabets
Non-Binary case: Non-Binary case: (k+1)k+1)mm ; k+1 (asterisk) alphabets
The binary alphabet offers the maximum number of schemata per bit of information of any coding. Since these similarities are the essence of our search, when we design a code, we should ,maximise the number of them available for the GA to exploit.
Example: Refer to our previous problem
• Maximize f(x) = xMaximize f(x) = x22; where x is permitted to vary between 0 and 31; where x is permitted to vary between 0 and 31
Page93
Genetic algorithms: Genetic algorithms: ExerciseExercise
Think of a GA approach to solving the 8-Queens problem
Page94
Genetic algorithmsGenetic algorithms Variant of local beam search with Variant of local beam search with sexual recombination.sexual recombination.
Fitness function: number of non-attacking pairs of queens (min = 0, max = 8 × 7/2 = 28); 24/(24+23+20+11) = 31% 23/(24+23+20+11) = 29% etc
Page95
Why use Fitness Scaling?Why use Fitness Scaling?
At the start of the GA runAt the start of the GA run, it is common to have a few extraordinary individuals in a population of mediocre colleagues.
If left to the selection rule pselecti =
the extraordinary individuals would take over a significant proportion of the finite population in a single generation.
f
fi
This is undesirable, leading to a premature convergence!
Page96
Why use Fitness Scaling?Why use Fitness Scaling?Late in the runLate in the run, there may still be significant diversity within the population. However, the population’s average fitness average fitness may be close to the population’s best fitnessbest fitness.
If this is left alone,
• average membersaverage members get nearly the same number of copies in future generations, and • the survival of the fittest necessary for improvement becomes a random walk random walk among the mediocremediocre.
In both cases, at the beginning of the run, and as the run matures, fitnessfitness scalingscaling can help.
Page97
Why use Fitness Scaling?Why use Fitness Scaling?
Linear Scaling f’ = a f + b
In all cases, we want f’f’aveave = f = faveave because
subsequent use of the selection procedure will ensure that each average population member contributes one expected offspring to the next generation.
Scaled fitness
Raw fitness
Page98
Why use Fitness Scaling?Why use Fitness Scaling?
Scaled Maximum Fitness: f’max = ccmultmult * fave
For a typical population size of n = 50 to 100,
CCmultmult = [1.2, 2] has been used successfully
Number of expected copies desired for the
best population member
To control the number of offspring given to the population member with member with the maximum raw fitnessthe maximum raw fitness, we choose the other scaling relationship to obtain a scaled maximum fitnessscaled maximum fitness.
Page99
Fitness ScalingFitness Scaling
Linear Scaling Under Normal Conditions
fmin fave fmax
f’min
f’ave
f’max
Raw fitness
Scaled fitness
Page100
Problem with Linear ScalingProblem with Linear ScalingToward the end of a run, the choice of CCmultmult stretches the raw fitness values significantly.
This may in turn cause difficulty in applying the linear scaling rule.
The effects of the Linear Scaling rule works during the initial run initial run of the GA:• few extraordinary individuals get scaled down, and• the lowly members of the population get scaled up
The problemThe problem: As the run matures, points with low fitness can be scaled to negative valuesnegative values!
The stretching required on the relatively close The stretching required on the relatively close average and maximum raw fitness values causes average and maximum raw fitness values causes
the low fitness values to go the low fitness values to go negativenegative after scaling. after scaling. See for yourself, TestGA2.xlsSee for yourself, TestGA2.xls
Page101
Why use Fitness Scaling?Why use Fitness Scaling?
fmin fave fmax
f’min
f’ave
f’max
Raw fitness
Difficult situation for linear scaling in mature run
0
Negative fitness Negative fitness violates non-negativity violates non-negativity
requirement!requirement!
Page102
Fitness ScalingFitness Scaling
IfIf it’s possible to scale to the desired multiple, Cmult
ThenThen Perform linear scaling
ElseElse Scaling is performed by pivoting about the
average value and stretching the fitness until the minimum value maps to zero.
Page
ScalingScaling
Non-negative test:Non-negative test:
If( min > (fmultiple*avg - max) / (fmultiple - 1.0) ) { Perform Normal Scaling }
103
Page104
Eliminating Eliminating negative fitnessnegative fitness values values
Solution: When we cannot scale to the desired cmultcmult, we still maintain equality of the raw and scaled fitness averages and we map the minimum raw fitness fmin to a scaled fitness f’min = 0.
Description of Routines:
PrescalePrescale – takes the average, maximum and minimum raw fitness values and calculates linear scaling of the coefficients a and b based on the logic described previously. It takes into account whether the desired cmult can be reached or not.
ScalepopScalepop – called after Prescaling is done. It scales all the individual raw fitness values using the function ScaleScale.
Page105
Fitness ScalingFitness Scaling
procedure scalepopscalepop(popsize:integer; var max, avg, min, sumfitness:real; var pop:population);{ Scale entire population }var j:integer; a, b:real; { slope & intercept for linear equation }begin prescaleprescale(max, avg, min, a, b); { Get slope and intercept for function } sumfitness := 0.0; for j := 1 to popsize do with pop[j] do begin fitness := scalescale(objective, a, b); sumfitness := sumfitness + fitness; end;end; function scalescale(u, a, b:real):real;
{ Scale an objective function value }begin scale := a * u + b end;
function scalescale(u, a, b:real):real;{ Scale an objective function value }begin scale := a * u + b end;
Page106
Fitness ScalingFitness Scaling{ scale.sga: contains prescale, scale, scalepop for scaling fitnesses }
procedure prescale prescale (umax, uavg, umin:real; var a, b:real);{ Calculate scaling coefficients for linear scaling }const fmultiple = 2.0; { Fitness multiple is 2 }var delta:real; { Divisor }begin if umin > (fmultiple*uavg - umax) / (fmultiple - 1.0) { Non-negative test Non-negative test } then begin { Normal Scaling }{ Normal Scaling } delta := umax - uavg; a := (fmultiple - 1.0) * uavg / delta; b := uavg * (umax - fmultiple*uavg) / delta; end else begin { Scale as much as possible }{ Scale as much as possible } delta := uavg - umin; a := uavg / delta; b := -umin * uavg / delta; end;end;
Linear ScalingLinear Scaling
Stretch fitness until Stretch fitness until Minimum maps to zero.Minimum maps to zero.
Let’s try to solve Let’s try to solve an example using a an example using a
stored GA run.stored GA run.
Page107
Why Scaling?Why Scaling?
Simple scaling helps prevent the early domination of extraordinary individuals, while it later on encourages a healthy competition among near equals.
Page108
Stretch as much as possibleStretch as much as possible
See GA-Scaling-Goldberg.xlsGA-Scaling-Goldberg.xls
Page109
Linear ScalingLinear Scaling
This sample shows a This sample shows a violationviolation of the non- of the non-negativity requirement. This will never negativity requirement. This will never happen had we followed the multiple happen had we followed the multiple scaling scheme described previouslyscaling scheme described previously
See GA-Scaling-Goldberg.xlsGA-Scaling-Goldberg.xls
Page
Page111
MultiparameterMultiparameter, Mapped, Fixed-Point , Mapped, Fixed-Point CodingCoding
Single UU1 1 Parameter (l1 = 4)
0 0 0 0 -> Umin
1 1 1 1 -> Umax
Others map linearly in between
Multiparameter Coding (10 parameters)
0 0 0 0 || 0 0 0 0 | ....... || ....... | 0 0 0 0 || 0 0 0 0 || U1 U2 ... U9 U10
To construct a multiparameter coding, we can simply concatenateconcatenate as many single parameter codings as we require. Each coding may have its own sublengthsublength, its own Umax and Umin values.
Page112
procedure extract_parmextract_parm(var chromfrom, chromtochromto:chromosome; var jposition, lchrom, lparm:integer);{ Extract a substring from a full string }var j, jtarget:integer;begin
j := 1; jtarget := jposition + lparm - 1; if jtarget > lchrom then jtarget := lchrom; { Clamp if excessive } while (jposition <= jtarget) do begin
chromto[j] := chromfrom[jposition]; jposition := jposition + 1; j := j + 1;
end;end;
Extract a substring from a full string
Multiparameter, Mapped, Fixed-Point Multiparameter, Mapped, Fixed-Point CodingCoding
Page113
function map_parmmap_parm(x, maxparm, minparm, fullscale: real) real;
begin map_parm := minparm + (maxparm – minparm) / fullscale*xend;
Multiparameter, Mapped, Fixed-Point Multiparameter, Mapped, Fixed-Point CodingCoding
Map an unsigned binary integer to range [minparm, maxparm]
Page114
function decode_parmsdecode_parms(var nparms, lchrom: integer; var chrom: chromosome; var parms: parmspecs); Var j, jposition: integer; Chromtemp:chromosome; {temporary string buffer} begin j:= 1; {parameter counter} jposition := 1 ; {string position counter} repeat with parms[j] do if lparm > 0 then begin extract_parmextract_parm(chrom, chromtemp, jposition. lchrom, lparm); parameter :=
map_parmmap_parm(decode(chromtemp, lparm), maxparm, minparm, power(2.0, lparm)-1.0); end else parameter := 0; j := j + 1; until j > nparms; end;
Multiparameter, Mapped, Fixed-Point Multiparameter, Mapped, Fixed-Point CodingCoding
Coordinates the decoding of all nparms parameters.
Page115
function decode(chrom:chromosome; lbits:integer):real; { Decode string as unsigned binary integer - true=1, false=0 } var j:integer; accum, powerof2:real; begin accum := 0.0; powerof2 := 1; for j := 1 to lbits do begin if chrom[j] then accum := accum + powerof2; powerof2 := powerof2 * 2; end; decode := accum; end;
Multiparameter, Mapped, Fixed-Point Multiparameter, Mapped, Fixed-Point CodingCoding
Decode a single parameter
Page116
ReferencesReferences Genetic Algorithms: Darwin-in-a-box
Presentation by Prof. David E. Goldberg Department of General Engineering University of Illinois at Urbana-Champaign [email protected]
Neural Networks and Fuzzy Logic Algorithms by Stephen Welstead
Soft Computing and Intelligent Systems Designby Fakhreddine Karray and Clarence de Silva
Page117
ReferencesReferences
http://lancet.mit.edu/~mbwall/presentations/IntroToGAs/P001.html
A Genetic Algorithm Tutorial Darrell Whitley Computer Science Department