Evolutionary Algorithms Evolutionary Algorithms What is Evolutionary Algorithms (EAs)? Evolutionary algorithms are iterative and stochastic search methods that mimic the natural biological evolution and/or the social behavior of species Such algorithms have been developed to arrive at nearoptimum solutions to large-scale optimization problems, for which traditional mathematical techniques may fail EAs operate on a set of individuals (population) Each individual represents a potential solution to the problem being solved 2
Evolutionary Algorithms What is Evolutionary Algorithms (EAs)? Initially, the population is randomly generated Every individual in the population is assigned a measure of its goodness with respect to the problem under consideration (fitness function) This value is the quantitative information the algorithm uses to guide the search Examples include: Genetic Algorithms, Memetic Algorithms, Swarm Optimization, Ant Colony,. 3 Evolutionary Algorithms What is Evolutionary Algorithms (EAs)? EAs share a common approach for their application to a given problem The problem first requires some representation to suit each method. Then, the evolutionary search algorithm is applied iteratively to arrive at a near-optimum solution 4
Evolutionary Algorithms What is Evolutionary Algorithms (EAs)? EAs apply the principle of survival of the fittest to produce better and better approximations to a solution EAs model natural processes, such as selection, recombination, and mutation Structure of an EA 5 Evolutionary Algorithms Difference between EAs and other traditional search and optimization methods EAs search a population of points in parallel, not just a single point EAs do not require derivative information or other auxiliary knowledge; only the objective function and corresponding fitness levels influence the directions of search EAs use probabilistic transition rules, not deterministic ones EAs are generally more straightforward to apply, because no restrictions for the definition of the objective function exist EAs can provide a number of potential solutions to a given problem, the final choice is left to the user 6
Evolutionary Algorithms Difference between EAs and other traditional search and optimization methods EAs are blind, they need only an objective function and decision variables. No derivatives are needed EAs are random, all possible options are open Regardless of their blindness and randomness, they use guided search system They can work with continuous, discrete, integer, and mixed decision parameters EAs can solve a wide class of real-life problems 7 Evolutionary Algorithms Main Steps of EAs Selection (Reproduction): The selection mechanism simulates the survival of the fittest principle Recombination Recombination produces new individuals by combining the information contained in the parents Mutation Individual variables are then mutated with low probability Reinsertion After producing offspring they must be inserted into the population 8
Genetic Algorithms 9
Genetic Algorithms The genetic algorithms (GAs) are the most extended group of methods representing the application of evolutionary Algorithms A solution to a given problem is represented in the form of a string, called chromosome, consisting of a set of elements, called genes, that hold a set of values for the optimization variables The fitness of each chromosome is determined by evaluating it against an objective function 11 Genetic Algorithms Chromosomes The chromosome represents a feasible solution for the problem under study The length of the chromosome equals the number of variables Gene values can be either binary coding (0 or 1 values) or real coding (actual values) Variable value 1 2 3................. N 97 36 30 44 3 78 18 52 2.... 61 Number of variables 12
Genetic Algorithms Binary Versus Real Coding Any number can be represented in a binary code (0, 1 values) For example: 230 represented in 0-1 format as follow: 11100110 11100110 = 1 x 2 7 +1 x 2 6 + 1 x 2 5 + 0 x 2 4 + 0 x 2 3 + 1 x 2 2 + 1 x 2 1 + 0 x 2 0 = 128 + 64 + 32 + 4 + 2 = 230 The binary code could be created by dividing the given number by 2 with the reminder either 0 or 1, then divide the quotient by 2 with the reminder either 0 or 1 and so on The reminders will represent the binary coding of the number 13 Genetic Algorithms Binary Versus Real Coding Example Determine the binary number that represents 230. 230/2 = 115 reminder = 0; 115/2 = 57 reminder = 1 57/2 = 28 reminder = 1; 28/2 = 14 reminder = 0 14/2 = 7 reminder = 0; 7/2 = 3 reminder = 1 3/2 = 1 reminder = 1; 1/2 = 0 reminder = 1 Then, the binary number is: 11100110 14
Example Genetic Algorithms This example illustrates the binary coding for a set of variables 15 Genetic Algorithms Standard GAs Steps Create population at random Calculate the fitness of each chromosome Calculate the relative fitness of each chromosome Apply the GA operators Reproduction Crossover Mutation 16
Example Genetic Algorithms Determine the maximum value for the function y = -0.005 x 2 + 1.5 x + 10 where 0 < x < 255 17 Example Genetic Algorithms Start with randomized population of solutions Assume the population equals 10 Calculate the value of y for each chromosome (this represents the objective functions we are looking for the maximum y) Then, calculate the relative fitness for each chromosome Then apply the selection process (reproduction process) using the roulette wheel 18
Example GAs: Ranking 19 GAs: Ranking Fitness Ranking: Proportional Ranking In this method each individual has a rank based on its objective function values in relative to the sum of the objective function values for the whole population For example having 3 individuals with objective function equal: 5, 10, 25 Then the relative fitness of the first is 5/40 = 0.125, the second is 10/40 = 0.25, and the third is 25/40 = 0.625 20
GAs: Ranking Fitness Ranking: Proportional Ranking As seen previously, individuals with higher objective function values have a higher proportional fitness Accordingly, proportional ranking may lead premature convergence This might happen when the population contains few chromosomes have higher fitness values compared to the reminder of the population These chromosome will have a higher probability of selection 21 GAs: Ranking Fitness Ranking: Linear Ranking To overcome the problem of proportional ranking, linear ranking is used Instead of using the relative fitness, chromosomes are ranked according to their fitness The worst chromosome will have a rank of one and the second worst two The best chromosome will have a rank N 22
GAs: Ranking Linear Ranking: Example Consider the following six chromosomes 180 21 23 GAs: Ranking Fitness Ranking: Example Linear ranking allows for more divergence in the population 24
GAs: Selection Roulette Wheel Selection Also called stochastic sampling In this process, a random number is generate and the individual whose segment spans the random number is selected The process is repeated with a number equals the total number of the individuals (population) Assume the following example 25 GAs: Selection Roulette Wheel Selection: Example Number of individual 1 2 3 4 5 6 7 8 9 10 11 fitness value 2.0 1.8 1.6 1.4 1.2 1.0 0.8 0.6 0.4 0.2 0.0 selection probability 0.18 0.16 0.15 0.13 0.11 0.09 0.07 0.06 0.03 0.02 0.0 Assume six random numbers are: 0.81, 0.32, 0.96, 0.01, 0.65, 0.42 Selected individuals: 1, 2, 3, 5, 6, 9 26
GAs: Selection Roulette Wheel Selection In this process, fit individuals can be produced more than one Unfit individuals are expected to leave the pool (population) Number on population will always remain fixed The roulette wheel selection provides no bias but does not guarantee a minimum spread 27 GAs: Selection Stochastic Universal Selection This method provides n bias and allows for minimum spread The individuals are mapped to continuous segments of a line, such that each individual's segment is equal in size to its fitness exactly as in roulette-wheel selection Equally spaced pointers (1/no of selection) are placed over the line as the number of individuals to be selected The first pointer is selected randomly between 0 and 1/no of selections 28
GAs: Selection Stochastic Universal Selection: Example As the previous example, consider six individuals to be selected The distance between the pointers is 1/6 = 0.167 The first pointer is selected randomly between 0 and 0.167, assume 0.1 Selected individuals: 1, 2, 3, 4, 6, 8 29 GAs: Recombination Recombination: Crossover Recombination performs an exchange of variable values between the individuals These individuals are called parents and the resulted individual called offspring Each individual has equal probability of being selected The position at which the parent contributes its variable to the offspring is chosen randomly 30
GAs: Recombination Crossover Crossover (marriage) is a more common process A crossover probability (P c ) is applied with the range between 0.6 and 1 P c provides probability that P c * n chromosomes undergo crossover operation One or multiple points crossover may be selected There are other examples of crossover such as: uniform crossover and shuffle crossover The two child (offspring chromosomes) replace their parents so that the population size remain constant 31 GAs: Recombination Crossover For each chromosome, a random number r between (0, 1) is generated. If r < Pc, then this string is selected for crossover For each couple of chromosomes, two random numbers are generated between [1 and m-1], where m is the length of the chromosome and the portions of the strings between the two randomly selected locations are exchanged Reproduction and crossover together give GA most of their searching power 32
GAs: Recombination Single Point Crossover Parent gene (A) A1 A2 A3 A4 A5 A6... AQ Parent gene (B) B1 B2 B3 B4 B5 B6... BQ Generate random point (e.g., 3) Offspring (child) (A) A1 A2 B3 B4 B5 A6... AQ Offspring (child) (B) B1 B2 A3 A4 A5 A6... AQ 33 GAs: Recombination Two Point Crossover Parent gene (A) Parent gene (B) A1 B1 A2 A3 A4 A5 A6... AQ Crossover range B2 B3 B4 B5 B6... BQ Generate random range (e.g., 3 5) Offspring (child) (A) A1 A2 B3 B4 B5 A6... AQ Offspring (child) (B) B1 B2 A3 A4 A5 B6... BQ 34
GAs: Mutation Mutation As opposed to crossover, which resembles the main natural method of reproduction, mutation is a rare process that resembles the process of a sudden generation of an offspring that turns to be a genius The benefit of the mutation process is that it breaks any stagnation in the evolutionary process, avoiding local minimums If one important information is missing, crossover will not be able to alleviate, mutation may introduce this missed information 35 GAs: Mutation Mutation Mutation, as it does in nature, takes place very rarely, on the order of once in a thousand bit string locations Mutation probability (P m ) is usually chosen less than 0.05 bit/generation The mutation probability (P m ) gives the expected number of mutated bits as P m x number of genes x number of chromosomes A random number " r " between [0, 1] is generated, if r is smaller than P m then mutate the bit, otherwise, go to another bit 36
GAs: Mutation Start Generate initial random population No Termination Criterion satisfied? Yes End BAsic GA Flow Chart Gen = Gen +1 Evaluate fitness Yes Reproduction - Select one individual - Perform reproduction i = 0 i = M No Genetic operations Crossover - Select two individuals - Perform crossover Mutation - Select one individual - Perform mutation Copy into new population Insert two offspring chromosomes into new population Insert mutated chromosome into new population i = i+ 1 37 GAs: Example 10-memebr Truss Problem It is needed to determine the cross sectional area of the 10 members so as to minimize the cost of the truss to support the load, stress and strain constraints must be satisfied 38
GAs: Example 10-memebr Truss Problem A binary representation of the cross sectional area is used of 4-bits element (0 0 0 0) For example (0 1 1 1) a 7-inch cross section Chromosome structure Compute the weight of the truss and determine the cost Stresses are computed using appropriate methods of structural analysis 39 GAs: Example 10-memebr Truss Problem Penalize violations of stress constraints For example, increase the cost of that solution in order to decrease its fitness The smaller the total cost is the better Set population size Number of generations Crossover probability Mutation probability Termination criteria 40
Steady State GAs In the steady-state approach only one chromosome is replaced at a time, rather than an entire "generation" being replaced The reproduction process takes place by either crossover or mutation In crossover two members of the population are chosen randomly in such a way that its probability of being selected is proportional to its relative merit to produce a single child This ensures that best chromosomes have higher likelihood of being selected 41 Steady State GAs Also, the mutation process can be done by randomly selecting one chromosome from the population and then arbitrarily changing some of its information Once an offspring is generated by either method, it is evaluated in turn and can be retained only if its fitness is higher than that of others in the population Throughout the process, the entire population soon improves since more fit offspring chromosomes replace unfit parents In this case, the number of generations equals the number of individual trials divided by the size of the population 42
Steady State GAs Star t - Generate one chromosome at random. - Calculate its objective function. Steady Yes End No All Population generated? End Yes State GA Last offspring? No Yes No Evaluate relative merits and determine the worst population chromosome Last offspring? Determine if crossover or mutation applies and generate an offspring Discard the offspring Determine the fitness of the offspring chromosome Replace the worst chromosome No Is offspring better than the worst chromosome in the population? Yes 43 Steady State GAs: Example A square construction site is divided into 9 grid units We need to use GAs to determine the best location of two temporary facilities A and B, so that: Facility A is as close as possible to facility B Facility A is as close as possible to the fixed facility F Facility B is as far as possible to the fixed facility F Let s consider the closeness weights (W) as follows: W AB = 100 (positive means A & B close to each other) W AF = 100 (A & F close to each other) W BF = -100 (negative means B & F far from each other) 44
Steady State GAs: Example Step 1: Problem Representation First of all, determine the way how the problem will be represented 45 Steady State GAs: Example Step 2: Chromosome Structure The variables are the locations of the facilities A and B The chromosome structure of each option presented in step 1 is presented Note that the chromosome length equal the number of variables 46
Steady State GAs: Example Step 3: Generate Population 50 to 100 is reasonable number for diversity and processing time Let s consider option 1 and population of 3 47 Steady State GAs: Example Step 4: Evaluate the Population Objective function, minimize site score = Σw i d i W AB = 100, W AF = 100, and W BF = -100 Distance between facilities are represented as the number of horizontal and vertical blocks between them 48
Steady State GAs: Example Step 5: Calculate the Merits of Population Members Notice that smaller score gives higher merit because we are interested in minimization. In case of maximization, we use the inverse of the merit calculation. 49 Steady State GAs: Example Step 6: Calculate the Relative Merits of Population Members Step 7: Select Crossover and Mutation Operators Crossover rate = 96% (marriage is the main avenue for evolution) Mutation rate = 4% (genius people are very rare) To select which operator to use in current cycle, we generate a random number (from 0 to 100). If the value is between 0 to 96, then crossover, otherwise, mutation. 50
Steady State GAs: Example Step 8: Use the Selected Operator (assume crossover) Randomly select two parents according to their relative merits of Step 6 Assume two random numbers of 76 and 39 Then P3 and P2 is picked Then, apply crossover to generate offspring 51 Steady State GAs: Example Step 9: Evaluate the Offspring Notice that Offspring 2 is invalid because both facilities A & B are at same coordinates (x = 2 and Y = 3) and this is not allowed 52
Steady State GAs: Example Step 9: Evolve the Population Compare the offspring with population Since the offspring score = 200 is better than the worst member (P1 has a score of 600), then the offspring survives and P1 dies (will be replaced by the offspring) Continue, GOTO STEP 4, repeating the process thousands of times until the best solution is determined One of the top solutions 53