Ming-Feng Yeh 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.
Ming-Feng Yeh1-103 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.
Ming-Feng Yeh1-104 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 fitness of an organism is measured by success of the organism in its life.
Ming-Feng Yeh1-105 Search 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 Yeh1-106 Basic 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 Yeh1-107 Basic Genetic Algorithm
Ming-Feng Yeh1-108 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.
Ming-Feng Yeh1-109 Basic GA: part 2 Step 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 Yeh1-110 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.
Ming-Feng Yeh1-111 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 Chromosome 2 Each bit in this string can represent some characteristic of the solution. One can encode directly integer or real numbers.
Ming-Feng Yeh1-112 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.
Ming-Feng Yeh1-113 Roulette Wheel Selection Parents are selected according to their fitness. The better the chromosomes are, the more chances to be selected they have.
Ming-Feng Yeh1-114 Example fitness values f(x)=x 2 xstringfitness f(x)% of total total
Ming-Feng Yeh1-115 Rank Selection: 1 Rank selection first ranks the population and then every chromosome receives fitness from this ranking.
Ming-Feng Yeh1-116 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.
Ming-Feng Yeh1-117 Operators of GA: Crossover Crossover selects genes from parent chromosomes and creates a new offspring. Chromosome 1 | Chromosome 2 | Offspring 1 | Offspring 2 | “ | “ is the crossover point
Ming-Feng Yeh1-118 Crossover Single point crossover: = Two point crossover: = Uniform crossover : = Arithmetic crossover: = (AND)
Ming-Feng Yeh1-119 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 1 Mutated offspring 1 Original offspring 2 Mutated offspring 2
Ming-Feng Yeh1-120 Control Parameters GA has two control parameters: crossover rate (p c ) and mutation rate (p m ). p c (0.5~1.0): The higher the value of p c, the quicker are the new solutions introduced into the population. p m (0.005~0.05): Large values of p m 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 Yeh1-121 Numerical Example No.string xfitness% of total (max) total
Ming-Feng Yeh1-122 Numerical Example No.actual count (max)1.97 (max)2 (max) average
Ming-Feng Yeh1-123 Numerical Example No.string mate crossover site new string 10110| | | |
Ming-Feng Yeh1-124 Numerical Example No. new population xf(x)=x (max) (max)
Ming-Feng Yeh1-125 Real-Valued GA Basic (binary) GA 當系統參數增多時,編碼 (encoding) 及解碼 (decoding) 過程相當耗時,尤 其當字串長度不足時,亦可能造成浮點數運算 之精確度不足,而導致無法搜尋到「真正」的 最佳值。 實數型基因演算法是直接以實數參數運算,無 須透過離散式的編碼形式。故可以免除編碼及 解碼過程,亦可以提高系統之精確度。
Ming-Feng Yeh1-126 交配過程及突變過程 假設 P 1 與 P 2 為父代, C 1 與 C 2 為子代 交配過程: C 1 = P 1 + (1 ) P 2 C 2 = P 1 + (1 ) P 2 其中 和 為隨機值,且 , [0, 1] 突變過程: C ’ = C + random_noise 其中 random_noise 為所加入之隨機雜訊
Ming-Feng Yeh1-127 整數型基因演算法 直接以整數型態作為運算之基本單位,無須再 進行二進位轉換。 設變數之區間為 [0, ] ,若以 4 位元編碼,則 可將此區間均分為 15 等分: 二進位 整數 實數 0 / /
Ming-Feng Yeh1-128 交配過程及突變過程 交配過程: 與 Binary GA 相似 突變過程:交換法 例:原始字串 突變後字串