Upload
levi
View
40
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Evolutionary Optimization Wi th focus on genetic algorithm and regarding applications. Introduction to. In memory of Caro Lucas, Valuable Iranian Scientist . Danial Khashabi ([email protected]) Amirkabir University of Technology, School of Electrical Engineering July 22, 2010. - PowerPoint PPT Presentation
Citation preview
Evolutionary Optimization
With focus on genetic algorithm and regarding applications
Danial Khashabi ([email protected])Amirkabir University of Technology, School of Electrical EngineeringJuly 22, 2010
Introduction to
In memory of Caro Lucas, Valuable Iranian Scientist
Lecture Overview:• Evolutionary optimization.
– What is EO in general.• Genetic Algorithms.
– Overview of search methods.– Some examples of evolutionary optimization for getting
perception!– Brief history of Digital Genetics.– Introducing genetic algorithm members.
• Steps for solving a problem using genetic algorithm, a detailed view.• A review on genetic algorithm.• Introducing applications of GA.• Some examples:
– Optimizing a one-variable function.– Optimizing a two-variable function.– Traveling Salesman problem(TSP).– Evolving hardware using GA.
Evolutionary Optimization• Solution for problem is formed by “Population” • Population consists of individuals.• Individuals that are more fitter, have more chance to survive! • Solutions are evolved in every generation.• Every population is parent generation for next generation.• Fitness in population grows gradually, as generations pass.
– This is called “Evolution”!
[“Evolutionary Algorithms”: S.N.Razavi]
What is EO in general?• It’s a branch of Computation Theory in Computer
Science?– So why an engineer needs to know about EO?– It is an optimization method and it can be applied
to bunch of problems!• It is inspired from Darwin's “Evolution Theory”.• Genetic algorithms are a part of evolutionary
computing, which is a rapidly growing area of artificial intelligence.
[Charles Darwin: 1809-1882 : http://en.wikipedia.org/wiki/Charles_Darwin]
Genetic Algorithm• A way to employ evolution in solutions• Why evolution?!
– Man computational problems require searching through a large possibilities for solutions.
• Search and Optimization– Based of variation and selection– by understanding the adaptive processes of natural systems
• Search for ?! – Find a better solution to a problem in a large space.
• What is a better solution? – A good solution is specified by “Fitness Function”!
[http://media.brainz.org/uploads/2009/02/genetic-algorithms.jpg]
Overview of Search Methods
F inon acc i N ew ton
D irec t m ethods Indirec t m ethods
C alcu lus-based tech n iques
Evolu tionary s trategies
C entra l ized D is tributed
Para l le l
S tea dy-s ta te G enera tiona l
Sequentia l
G ene tic a lgor ithm s
Evolutionary a lgorithm s Sim u lated an nealing
G uide d random sea rch techniques
D ynam ic program m in g
Enu m erative techn iques
Sea rch tec hniques
You are here !
[Genetic Algorithms: A Tutorial: W.Wliliams]
Local vs. Global; a BIG challenge!
• This an important challenge !
[Optimization with Genetic Algorithm/Direct Search Toolbox : Ed Hall]
GA vs. Some other search methods
• Search methods: – Aggressive methods(e.g. Simulated Annealing)
• Can be trapped in local minima• Initial position is important
– Non-Aggressive methods(e.g. GA)• Traces Global minima• Can not guarantee discovery of hilltop
[Genetic Algorithms: A.Dix, M.Sifalakis]
One example !
[Optimization with Genetic Algorithm/Direct Search Toolbox, E.Hall]
One example !
[Optimization with Genetic Algorithm/Direct Search Toolbox, E.Hall]
Brief History
• Evolutionary computing – was introduced in the 1960s – by I. Rechenberg – in his work "Evolution strategies"
• Genetic Algorithms (GAs) – invented by John Holland – This lead to Holland's book "Adaption in Natural
and Artificial Systems" published in 1975. • Genetic Programming?!• In 1992 John Koza has used genetic algorithm to
evolve programs to perform certain tasks. He called his method "genetic programming" (GP).
Genetic Algorithm• A chromosome is a string representation of a candidate solution to
a problem. – Bin(0/1) 101000111010111010111– Decimal(0-9) 345304539475330394537– Alfa(A-Z) ABBCBDCCCBBDBAAABCA– Hex(0-F): 982234BA68AB23634FDD
• The genes are single or subset of digits at specific locations in the chromosome string:
Bin 0101000100100111101 • An Allele is possible values a gene can take; e.g. 1/0 for binary.
Gene
Solving a Problem using GAStep 1: Encoding
• We need to encode the problem in a proper manner.• Solutions are coded as “chromosomes”
– Algorithm only understands numbers.– Improper coding may result inefficient solutions.– Some times a new method of coding may result in
new methods and solutions. – It’s a kind of Heuristic.
• Encoding depends on the problem heavily.• This could be:
– String of real numbers.– String of 1 and 0(binary coding)
• This is the most common coding.• This is a simple encoding and also powerful and fast.
Chromosome A 101100101100101011100101
Chromosome B 111111100000110000011111
Solving a Problem using GAStep 1: Encoding
• Example1:
• Example2:
– Solution for 23, ' 6+5*4/2+1' would be represented like so:
0110 1010 0101 1100 0100 1101 0010 1010 00016 + 5 * 4 / 2 + 1
– These genes are all strung together to form the chromosome: 011010100101110001001101001010100001
- The possible genes 1110 & 1111 will remain unused and will be ignored by the algorithm if encountered.
1 0 1 1 0 1 0 0 0 1 0 1 1
Size Shape Speed
A Sample Chromosome
[Genetic Algorithms: Dr.K.Kiani]
Decimal
Binary Coded Decimal(BCD)
0 00001 00012 00103 00114 01005 01016 01107 01118 10009 1001+ 1010- 1011* 1100/ 1101
Solving a Problem using GAStep 1: Encoding
• Example:
• Every encoding needs a decoding(After Optimization)– Expected coding is :
number -> operator -> number -> operator– We may encounter some conditions that is not predicted based on encoding
algorithm:
• The best encoding is which:– Probability of encountering an undefined condition is low– By means of least bits it represents the most information– It covers whole search space!
• We must define a rule how to deal with unexpected conditions.– By the above rule we can interpret above chromosome as:
2 + 7[Genetic Algorithms: Dr.K.Kiani]
0010 1010 0011 1100 0101 1010 0110 2 + 3 * 5
+ 6=30
1000 1100 0011 1101 0011 1010 0010 8 * 3 / 3
+ 2=10
0010 0010 1010 1110 1011 0111 0010 2 2 + n/a -
7 2
Solving a Problem using GAStep 1: Encoding
• Direct value encoding for real numbers: – In the value encoding, every chromosome is a sequence of some values
Example of Problem: Finding weights for a neural networkThe problem: A neural network is given with defined architecture. Find
weights between neurons in the neural network to get the desired output from the network.
Encoding: Real values in chromosomes represent weights in the neural network.
[Genetic Algorithms: Dr.K.Kiani]
Chromosome A 1.2324 5.3243 0.4556 2.3293 2.4545
Chromosome C (back), (back), (right), (forward), (left)
Solving a Problem using GAStep 2: GA Operators
• Crossover(Recombination): – Operate on selected parent chromosomes to create new
offspring– decomposes two distinct solutions (chromosomes) and then
randomly mixes their parts to form novel solutions (chromosomes)
• Mutation:– A surprisingly small role is played by mutation.– Randomly changes the offspring.– This creates diversity in search space. – Prevent falling of all solutions into a local optimum.– Most mutations are damaging rather than beneficial.
• therefore, rates must be low to avoid the destruction of species.
Solving a Problem using GAStep 2: GA Operators
• Crossover:– Example(Single Point Crossover)
– Example(Two- Point Crossover)
– Example(Simple Arithmetic Crossover)• Parents :
• Pick random gene (k) after this point mix values
[Genetic Algorithms: Dr.K.Kiani]
Parent1
Parent2 1011011111
1010000000 1011011111
1010000000Offspring2
Offspring1Random
1011011111
1010000000Parent1
Parent2
Random
1010011111
1011000000Offspring1
Offspring2
nxx ..., ,1
nxkxkykxx )1(ny ..., ,1)1(1 , ..., ,1 nyy ..., ,1
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
0.3
0.1 0.4 0.5 0.3 0.2 0.6 0.6 0.3Parent 1:Parent 2:
Offspring 1:
Offspring 2:
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.6 0.46.064.016.048.08.0)8.01(6.08.0
0.3 0.1 0.4 0.5 0.3 0.2 0.6 0.8 0.8
4.042.018.024.09.0)8.01(3.08.0
8.076.012.064.06.0)8.01(8.08.0 8.078.006.072.03.0)8.01(9.08.0
Solving a Problem using GAStep 2: GA Operators
• Mutation:– Example:
• Example( Order Changing Mutation):• two numbers are selected and exchanged
• Example(Adding Mutation)• a small number (for real value encoding) is added to
(subtracted from) selected values
[Genetic Algorithms: Dr.K.Kiani]
1010000000Parent Offspring
Random
1010000100
mutated
(1 2 3 4 5 6 8 9 7) => (1 8 3 4 5 6 2 9 7)
(1.29 5.68 2.86 4.11 5.55) => (1.29 5.68 2.73 4.22 5.55)
Solving a Problem using GAStep 3: Start Optimization!
• Lets have a look on optimization process:
A random population of chromosomes are generated.(Initial Population)
Repeat {The fitness function is applied to each chromosome.(Evaluation)Selection is applied in a favorable manner.(Selection)Crossover is applied on pairs to generate new population. Mutation is applied to some offspring. }
• Generating Initial Generation:– Most of time it’s random– Initial population must be diverse
Solving a Problem using GAStep 3: Selection(Reproduction)
• New generation is produced based on generation’s fitness value.• Must make sure that fittest chromosomes are propagated to the next generation.• One popular selection: Roulette-wheel selection method:
– Every individual has a probability(chance) to be selected proportional proportional to its fitness value.
– So better individuals(more fitted individuals) have more chance to be selected! – Even less fitted solutions have chance to be selected !
• This is a good characteristic ! • Causes more diversity on population. • As a result algorithm avoids of trapping in local minimum.
[http://www.edc.ncl.ac.uk/assets/hilite_graphics/rhjan07g02.png]
Solving a Problem using GAA Review on Algorithm:
[Genetic Algorithms: A.Dix, M.Sifalakis]
A Review on Characteristics:
• Stochastic• Used for -> hard problems• Maintains -> population• Every Solution -> chromosome • Reproduction -> new population • Better solutions -> more chance of
survival
Let see an examples!: one variable function(Slide1)
• Optimizing a one variable function:– If– The goal is to
• Because function is determined explicitly its possible to determine maximum of function by gradient:
• Numerical result:
0.1).10sin(.)( xxxf
-1 -0.5 0 0.5 1 1.5 2-1
-0.5
0
0.5
1
1.5
2
2.5
3
[Genetic Algorithms: Dr.K.Kiani]
)(maxarg]2,1[
xfx
xxxxxxf
.10).10tan(0).10cos(.10).10sin()(
85.20.1)2
18sin(.85.1)85.1(
85.12037
19
f
x
)(max]2,1[xf
x
Let see an examples!: one variable function(Slide2)
• Lets again review: What we exactly need to find maximum of a one variable function:- Find a proper encoding for solutions- A proper GA operator algorithms(Mutation and Crossover).- A proper selection method.Now we are going to discuss each one: • Encoding:
• Goal to encode real numbers [-1,2] using binary string: 111010….01• I assume this corresponding:
• The length of chromosome depends on required precision.• If I need N digit of accuracy in real numbers space: (Say N is 6)
• If I don’t care decimal point, I have:
• So by having a 22-digit length string it is possible to compute a rang of real numbers with 6-precision, specifically [-1,2]
• For finding corresponding real number from binary string, if chromosome is•
000 ... 0
111 ... 1-12
41943042300000022097152 2221
202021 )( bbb
312
2.0.1 22
10
21
0
i
iib
x
Let see an examples!: one variable function(Slide3)
• Example of a chromosome:
• For simplicity, we use simplest(one-point) crossover and mutation methods. • Fitness Function:
– It is clear that a clear that a chromosome with higher f(x) is better! – So we can assume that: where x is real part of
chromosome.– E.g:
[Genetic Algorithms: Dr.K.Kiani]
Chromosome: 10001011101101010001112288967)1111010100011000101110( 2
637197.04194303
3.22889670.1 x
)()( xfvnctionFittnessFu
627888.1)0111111100011110000000(958973.0)0000000001000000001110(
637197.0)1111010100011000101110(
33
22
11
xtodcorresponevxtodcorresponevxtodcorresponev
250650.2)()(078878.0)()(
586345.1)()(
33
22
11
xfvFitnessxfvFitnessxfvFitness
Let see an examples!: one variable function(Slide4)
• For simplicity, we use simplest(one-point) crossover and mutation methods.
• Mutation:
• Crossover:
[Genetic Algorithms: Dr.K.Kiani]
721638.1)0111111100011110100000(
627888.1)0111111100011110000000(
3'
3'
33
xtodcorresponev
xtodcorresponev
082257.0)()(
250650.2)()(
3'
3'
33
xfvfitness
xfvfitness
627888.1)0111111100011110000000(958973.0)0000000001000000001110(
33
22
xtodcorresponevxtodcorresponev
250650.2)()(078878.0)()(
33
22
xfvfitnessxfvfitness
666028.1)0000000001001110001110(
998113.0)0111111100010000000000(
3'
3'
2'
2'
xtodcorresponev
xtodcorresponev459245.2)()(
940865.0)()(
3'
3'
2'
2'
xfvfitness
xfvfitness
Let see an examples!: one variable function(Slide5)
• Results: – If populationSize = 50– P_crossover = 0.25– P_mutation = 0.01
• Note about improvement of best answer.• After 150 generations:
• Remember result from explicit method:
[Genetic Algorithms: Dr.K.Kiani]
Generation number
Fitness function
1 1.4419426 2.2500038 2.2502839 2.250284
10 2.25036312 2.32807739 2.34425140 2.34508751 2.73893099 2.849246137 2.850217145 2.850227
850773.1)0100010000011111001101(
max
max
xtodcorresponev
85.20.1)2
18sin(.85.1)85.1(
85.12037
19
f
x
Another examples!A 2-variable function(Slide1)
• If
• Again we need to decode x1 and x2 like previous example.• As mentioned number of digits in chromosomes depends on desired
precision.
[Genetic Algorithms: Dr.K.Kiani]
).20sin(.).4sin(.5.21),( 221121 xxxxxxf 8.51.41.123 21 xandx
Another examples!A 2-variable function(Slide2)
• Domain of x1 is 12.1-(-3)=15.1– 4 digits of precision: – So we need 18-length bit string for representing x1
• Doman of x2 is 5.8-4.1=1.7– 4 digits of precision: – So we need 15-length bit string for representing x2
• We can assume that out chromosome has length 15+18=33• Example chromosome: 010001001011010000111110010100010• If we want to decode? E.g.: above chromosome.
So above chromosome corresponds to (x1, x2)= (1.052426,5.755330)And the fitness value for this point is: f(1.052426,5.755330) =
20.252640 [Genetic Algorithms: Dr.K.Kiani]
).20sin(.).4sin(.5.21),( 221121 xxxxxxf 8.51.41.123 21 xandx
26214421510002131072 1817
32768217000216384 1514
052426.1262143
1.15.703520.312
)0.3(1.12).110100000100010010(0.3 1821
decimalx
755330.532767
7.1.319061.4121.48.5).00101111001010(1.4 1522
decimalx
Another examples!A 2-variable function(Slide3)
• Initial Population:– populationSize = 20– Generated randomly:
[Genetic Algorithms: Dr.K.Kiani]
110100010111110011110011011100101100000011000111111111110001010100101011111010100001110100111010000101000110111111001111010110101111011000110100100011111101100111100110001111101101110000101110111011001011110010100001010100100100110110000000100010001000111110111110000010101000011101101001101000101000000110111110110101100110011111011101000011100110000010000011110100000000111101100010110100000001111011010110001110100011000011000011101101111100110101110010001000011101011111110010101000001010000101011111100001010011010001110110010100000111001101001111000110001101101011101111001000000000100000010101010001100110111001110001001111101001101100001111111001101000
20
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
vvvvvvvvvvvvvvvvvvvv
Another examples!A 2-variable function(Slide4)
• Evaluating by fitness fun:
[Genetic Algorithms: Dr.K.Kiani]
7768.3876669.13),(),(|7573.49359.7|1101000101111100111100110111001010959.20),(),(|3955.57466.1|1000000110001111111111100010101004141.15),(),(|1582.58430.3|1010111110101000011101001110100006961.13),(),(|5713.43675.3|1010001101111110011110101101011118672.23),(),(|9937.42115.9|0110001101001000111111011001111000602.30),(),(|0545.50889.11|1100011111011011100001011101110118762.19),(),(|1513.53359.1|0010111100101000010101001001001103167.27),(),(|3786.51346.11|1100000001000100010001111101111100116.15),(),(|2394.43561.9|0000101010000111011010011010001014106.23),(),(|9960.41300.3|0000001101111101101011001100111112784.21),(),(|7937.45548.2|0111010000111001100000100000111101277.16),(),(|3814.57954.0|1000000001111011000101101000000019597.17),(),(|7030.49106.4|1110110101100011101000110000110000208.16),(),(|5802.59914.0|0111011011111001101011100100010001004.18),(),(|3919.48117.1|0111010111111100101010000010100003411.25),(),(|7344.42551.1|1010111111000010100110100011101104067.17),(),(|5934.52786.5|010100000111001101001111000110001
5263.19),(),(|3903.45166.2|1011010111011110010000000001000005800.7),(),(|3802.43484.10|0101010100011001101110011100010010196.26),(),(|6522.50844.6|111101001101100001111111001101000
21212120
21212119
21212118
21212117
21212116
21212115
21212114
21212113
21212112
21212111
21212110
2121219
2121218
2121217
2121216
2121215
2121214
2121213
2121212
2121211
FitnessTotalxxfxxfitnessxxvxxfxxfitnessxxvxxfxxfitnessxxvxxfxxfitnessxxvxxfxxfitnessxxvxxfxxfitnessxxvxxfxxfitnessxxvxxfxxfitnessxxvxxfxxfitnessxxvxxfxxfitnessxxvxxfxxfitnessxxvxxfxxfitnessxxvxxfxxfitnessxxvxxfxxfitnessxxvxxfxxfitnessxxvxxfxxfitnessxxvxxfxxfitnnessxxvxxfxxfitnessxxvxxfxxfitnessxxvxxfxxfitnessxxv
It is clear, that the chromosome v15 is the strongest one, and the chromosome v2 the weakest.
Another examples!A 2-variable function(Slide5)
• We can use simplest mutation and crossover methods• By considering a selection method it is easy to calculate the
solution.• Its on your own to calculate the result!
• Have a look at Matlab’s GA toolbox – Just type: gatool
Some Important Applications of GA• Economics
– Biding Strategies, stock trends• Social Systems• Numerical and Combinatorial Optimization
– Job-shop scheduling, Traveling salesman problem(TSP)• Automatic Programming
– Genetic Programming• Machine Learning
– Classification, NN training and designing, • Control
– Gas pipeline, pole balancing, missile evasion• Design Problems
– Semiconductor Design, Aircraft Design, Keyboard configuration, Communication networks, Resource Allocation(e.g. electrical power networks.)
• Robotics:– Trajectory Planning
• Signal Processing: – Filter design
Traveling Salesman Problem(TSP)
• A single salesman travels to each of the cities and completes the route by returning to the city he started from.
• There are cities and given distances between them.• Each city is visited by the salesman exactly once.• Find a sequence of cities with a minimal travelled distance.
Encoding: Chromosome describes the order of cities, in which the salesman will visit them
423835262135327
3846445860697678716967628494
0
20
40
60
80
100
120
0 10 20 30 40 50 60 70 80 90 100
y
x
TSP30 Solution (Performance = 420)
[Genetic Algorithms: A Tutorial: W.Wliliams]
Evolvable Hardware(1)• How to Evolve a Hardware ?! “Design and Optimizing a digital combinational
logic circuit using GA.”• It is important to have a proper encoding.• Assume that your gate are placed on such sheet(Gate-Matrix)
• And each gate is like this(Gate-Characteristic):– Each gate get its input from previous levels: in-1(I,j) in-2(I,j).– Output is connected to a gate: out(I,j).– G(i,j) is position of gate in gate matrix.– Its possible to use several gate types, e.g. : {AND, OR, XOR, NOR, NAND}.
• The only limit is that gate-matrix be a complete set, i.e. it is possible to make any circuit by the use of that set.
• By designing a suitable encoding we can design an algorithm for designing a combinational circuit.
[“Design and Optimizing Digital Combinational Gates”: M.Moosavi, D.Khashabi]
Evolvable Hardware(2)• Fitness Function: What is the best circuit?
– Difference between truth table and output of circuit must be minimum(Zero is desirable)
– Minimum number of gates is desired. – A weighted fitness function:
• N-match is number of output that match truth table.• N-Null is number of Null gates .• W-match is weight(importance) of having true output results.• W-Null is weight(importance) of having minimum gates.
– Most of times W-match/W-null = 10 is a desirable value. • Its important that output be same as truth table even though circuit isn't an
optimized one!–
[“Design and Optimizing Digital Combinational Gates”: M.Moosavi, D.Khashabi]
Evolvable Hardware(3)• An example of results:
– If
– Evolved hardware:
– Fitness-value plot:
[“Design and Optimizing Digital Combinational Gates”: M.Moosavi, D.Khashabi]
Question?Thanks!
App: References:• [1] K.Kiani, Presentation: “Genetic Algorithms” .• [2] A.Dix, M.Sifalakis, Presentation: “Genetic Algorithms”.• [3] W.Wliliams, Presentation: “Genetic Algorithms:A
Tutorial”.• [4] S.N.Razavi, Presentation: “Evolutionary Algorithms”.• [5] E.Hall, Presentation: “Optimization with Genetic
Algorithm/Direct Search Toolbox”• [6] M.Moosavi, D.Khashabi, “Designing and Optimizing
Digital Combinational Logic Circuits”, ISCEE-2010(Submitted!).