280 likes | 407 Views
4. Genetic Algorithm. Genetic 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.
E N D
4. Genetic Algorithm • Genetic 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.
Biological 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.
Biological 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 fitnessof an organism is measured by success of the organism in its life.
Search Space • The space of all feasible solutions (it means objects among those the desired solution is) is called search space (also state space). • Eachpoint 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.
Basic Description of GA • Algorithm is started with a set of solutions (represented by chromosomes) calledpopulation. • 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.
Basic 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.
Basic GA: part 2 Step 3: Create a new population: • [Selection] Select two parent chromosomes from a population according to their fitness. • [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. • [Mutation] With a mutation probability mutate new offspring at each locus. • [Accepting] Place new offspring in a new population
Basic 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.
Operators 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.
Operators 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.
Roulette Wheel Selection • Parents are selected according to their fitness. • The better the chromosomes are, the more chances to be selected they have.
Example • fitness values f(x)=x2
Rank Selection: 1 • Rank selection first ranks the population and then every chromosome receives fitness from this ranking.
Rank 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.
Operators of GA: Crossover • Crossover selects genes from parent chromosomes and creates a new offspring. • Chromosome 111011 | 00100110110 • Chromosome 211011 | 11000011110 • Offspring 1 11011|11000011110 • Offspring 2 11011 | 00100110110 • “|“ is the crossover point
Crossover • Single point crossover:11001011+11011111 = 11001111 • Two point crossover: 11001011 + 11011111 = 11011111 • Uniform crossover:11001011 + 11011101 = 11011111 • Arithmetic crossover: 11001011 + 11011111 = 11001001(AND)
Operators of GA: Mutation • Prevent falling all solutions in population into a local optimum of solved problem • Mutation changes randomly the new offspring. • Original offspring 11101111000011110 • Mutated offspring 11100111000011110 • Original offspring 21101100100110110 • Mutated offspring 21101101100110110
Control 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.
Real-Valued GA • Basic (binary) GA當系統參數增多時,編碼(encoding)及解碼(decoding)過程相當耗時,尤其當字串長度不足時,亦可能造成浮點數運算之精確度不足,而導致無法搜尋到「真正」的最佳值。 • 實數型基因演算法是直接以實數參數運算,無須透過離散式的編碼形式。故可以免除編碼及解碼過程,亦可以提高系統之精確度。
交配過程及突變過程 • 假設P1與P2為父代,C1與C2為子代 • 交配過程:C1 = P1 + (1) P2C2 = P1 + (1 ) P2其中 和 為隨機值,且 , [0, 1] • 突變過程:C’ = C + random_noise其中 random_noise 為所加入之隨機雜訊
整數型基因演算法 • 直接以整數型態作為運算之基本單位,無須再進行二進位轉換。 • 設變數之區間為 [0, ],若以 4 位元編碼,則可將此區間均分為15等分:
交配過程及突變過程 • 交配過程:與Binary GA 相似 • 突變過程:交換法例:原始字串 突變後字串123456 125436