ming-feng yeh1-102 4. genetic algorithm genetic algorithms are a part of evolutionary computing,...
TRANSCRIPT
Ming-Feng Yeh 1-1
4. Genetic Algorithm4. Genetic AlgorithmGenetic algorithms are a part of evolutionary computing, which is a rapidly growing area of artificial intelligence. Based on Darwinian principles of biological evolution. “ 物競天擇,適者生存”First proposed by Prof. John Holland and his colleague at Univ. of Michigan.
Ming-Feng Yeh 1-2
Biological Background: 1Biological Background: 1
Chromosomes are strings of DNA and serves as a model for the whole organism.A chromosome consists of genes. Each gene encodes a trait.Complete set of genetic material (all chromosomes) is called genome.Particular set of genes in genome is called genotype.
Ming-Feng Yeh 1-3
Biological Background: 2Biological Background: 2
During reproduction, first occurs recombination (or crossover).Genes from parents form in some way the whole new chromosome.The new created offspring can then be mutated. Mutation means, that the elements of DNA are a bit changed. This changes are mainly caused by errors in copying genes from parents. The fitness of an organism is measured by success of the organism in its life.
Ming-Feng Yeh 1-4
Search SpaceSearch Space
The space of all feasible solutions (it means objects among those the desired solution is) is called search space (also state space).Each point in the search space represent one feasible solution. The looking for a solution is then equal to a looking for some extreme (minimum or maximum) in the search space.Search methods: hill climbing, tabular search, simulated annealing and genetic algorithm.
Ming-Feng Yeh 1-5
Basic Description of GABasic Description of GA
Algorithm is started with a set of solutions (represented by chromosomes) called population. Solutions from one population are taken and used to form a new population. The new population (offspring) will be better than the old one (parent).Solutions which are selected to form new solutions are selected according to their fitness - the more suitable they are the more chances they have to reproduce.
Ming-Feng Yeh 1-6
Basic Genetic AlgorithmBasic Genetic Algorithm
Ming-Feng Yeh 1-7
Basic GA: part 1Basic GA: part 1
Step 1: [Start] Generate random population of n chromosomes (suitable solutions for the problem.)
Step 2: [Fitness] Evaluate the fitness f(x) of each chromosome x in the population.
Step 3: [New population] Create a new population by repeating following steps until the new population is complete.
Ming-Feng Yeh 1-8
Basic GA: part 2Basic GA: part 2Step 3: Create a new population:1. [Selection] Select two parent chromosomes from a
population according to their fitness.2. [Crossover] With a crossover probability cross over
the parents to form a new offspring (children). If no crossover was performed, offspring is an exact copy of parents.
3. [Mutation] With a mutation probability mutate new offspring at each locus.
4. [Accepting] Place new offspring in a new population
Ming-Feng Yeh 1-9
Basic GA: part 3Basic GA: part 3
Step 4: [Replace] Use new generated population for a further run of algorithm
Step 5: [Test] If the end condition is satisfied, stop, and return the best solution in current population
Step 6: [Loop] Go to step 2.
Ming-Feng Yeh 1-10
Operators of GA: EncodingOperators of GA: Encoding
The chromosome should in some way contain information about solution which it represents.
The most used way of encoding is a binary string. Chromosome 1 1101100100110110 Chromosome 2 1101111000011110
Each bit in this string can represent some characteristic of the solution. One can encode directly integer or real numbers.
Ming-Feng Yeh 1-11
Operators of GA: SelectionOperators of GA: Selection
Chromosomes are selected from the population to be parents to crossover.
According to Darwin's evolution theory the best ones should survive and create new offspring.
For example: roulette wheel selection, Boltzman selection, tournament selection, rank selection, steady state selection and some others.
Ming-Feng Yeh 1-12
Roulette Wheel SelectionRoulette Wheel Selection
Parents are selected according to their fitness.
The better the chromosomes are, the more chances to be selected they have.
Ming-Feng Yeh 1-13
ExampleExample
fitness values f(x)=x2
x string fitness f(x) % of total
13 01101 169 14.4
24 11000 576 49.2
8 01000 64 5.5
19 10011 361 30.9
total 1170 100.0
Ming-Feng Yeh 1-14
Rank Selection: 1Rank Selection: 1
Rank selection first ranks the population and then every chromosome receives fitness from this ranking.
Ming-Feng Yeh 1-15
Rank Selection: 2Rank Selection: 2
After this all the chromosomes have a chance to be selected.
But this method can lead to slower convergence, because the best chromosomes do not differ so much from other ones.
Ming-Feng Yeh 1-16
Operators of GA: CrossoverOperators of GA: Crossover
Crossover selects genes from parent chromosomes and creates a new offspring.
Chromosome 111011 | 00100110110Chromosome 211011 | 11000011110Offspring 1 11011 | 11000011110Offspring 2 11011 | 00100110110 “ | “ is the crossover point
Ming-Feng Yeh 1-17
CrossoverCrossover
Single point crossover: 11001011+11011111 = 11001111
Two point crossover: 11001011 + 11011111 = 11011111
Uniform crossover: 11001011 + 11011101 = 11011111
Arithmetic crossover: 11001011 + 11011111 = 11001001 (AND)
Ming-Feng Yeh 1-18
Operators of GA: MutationOperators of GA: Mutation
Prevent falling all solutions in population into a local optimum of solved problem
Mutation changes randomly the new offspring.
Original offspring 11101111000011110Mutated offspring 11100111000011110Original offspring 21101100100110110Mutated offspring 21101101100110110
Ming-Feng Yeh 1-19
Control ParametersControl Parameters
GA has two control parameters: crossover rate (pc) and mutation rate (pm).
pc (0.5~1.0): The higher the value of pc, the quicker are the new solutions introduced into the population.
pm (0.005~0.05): Large values of pm transform the GA into a purely random search algorithm, while some mutations are required to prevent the premature convergence of the GA to suboptimal solutions.
Ming-Feng Yeh 1-20
Numerical ExampleNumerical Example
No. string x fitness % of total
1 01101 13 169 14.4
2 11000 24 576 (max) 49.2
3 01000 8 64 5.5
4 10011 19 361 30.9
total 1170 100.0
Ming-Feng Yeh 1-21
Numerical ExampleNumerical Example
No. actual count
1 0.14 0.58 1
2 0.49 (max) 1.97 (max) 2 (max)
3 0.06 0.22 0
4 0.31 1.23 1
average 0.25 1.0 1.0
ii ff / ff i /
Ming-Feng Yeh 1-22
Numerical ExampleNumerical Example
No. string matecrossover
site new string
1 0110|1 2 4 01100
2 1100|0 1 4 11001
3 11|000 4 2 11011
4 10|011 3 2 10000
Ming-Feng Yeh 1-23
Numerical ExampleNumerical Example
No.new
populationx f(x)=x2
1 01100 12 144
2 11001 25 625
3 11011 27 729 (max)
4 10000 16 256
1 01101 13 169
2 11000 24 576 (max)
3 01000 8 64
4 10011 19 361
Ming-Feng Yeh 1-24
Real-Valued GAReal-Valued GA
Basic (binary) GA 當系統參數增多時,編碼 (encoding) 及解碼 (decoding) 過程相當耗時,尤其當字串長度不足時,亦可能造成浮點數運算之精確度不足,而導致無法搜尋到「真正」的最佳值。實數型基因演算法是直接以實數參數運算,無須透過離散式的編碼形式。故可以免除編碼及解碼過程,亦可以提高系統之精確度。
Ming-Feng Yeh 1-25
交配過程及突變過程交配過程及突變過程假設 P1與 P2為父代, C1與 C2為子代交配過程:C1 = P1 + (1) P2
C2 = P1 + (1 ) P2
其中 和 為隨機值,且 , [0, 1]
突變過程:C’ = C + random_noise其中 random_noise 為所加入之隨機雜訊
Ming-Feng Yeh 1-26
整數型基因演算法整數型基因演算法直接以整數型態作為運算之基本單位,無須再進行二進位轉換。設變數之區間為 [0, ] ,若以 4 位元編碼,則可將此區間均分為 15 等分:
二進位 0000 0001 --- 1000 --- 1111
整數 0 1 --- 8 --- 15
實數 0 / 15 --- 8 / 15 ---
Ming-Feng Yeh 1-27
交配過程及突變過程交配過程及突變過程交配過程:與 Binary GA 相似
突變過程:交換法例:原始字串 突變後字串 123456 125436