Presentation is loading. Please wait.

Presentation is loading. Please wait.

EE368 Soft Computing Genetic Algorithms.

Similar presentations


Presentation on theme: "EE368 Soft Computing Genetic Algorithms."— Presentation transcript:

1 EE368 Soft Computing Genetic Algorithms

2 Outline Genetic Algorithms Basic Components General Structure Example
Economic Load Dispatch problem using GA MATLAB code for ELD using GA

3 Genetic Algorithms Genetic algorithms are a particular class of evolutionary algorithms that use techniques inspired by evolutionary biology such as inheritance, mutation, selection, and crossover (also called recombination). Genetic algorithms are implemented as a computer simulation in which a population of abstract representations (called chromosomes) of candidate solutions (called individuals) to an optimization problem evolves toward better solutions. Traditionally, solutions are represented in binary as strings of 0s and 1s, but other encodings are also possible.

4 Genetic Algorithms The evolution usually starts from a population of randomly generated individuals and happens in generations. In each generation, the fitness of every individual in the population is evaluated, multiple individuals are selected from the current population (based on their fitness), and modified (recombined and possibly mutated) to form a new population. The new population is then used in the next iteration of the algorithm. Commonly, the algorithm terminates when either a maximum number of generations has been produced, or a satisfactory fitness level has been reached for the population.

5 Key terms Individual - Any possible solution
Population - Group of all individuals Search Space - All possible solutions to the problem Chromosome - Representation for an individual Locus - The position of a gene on the chromosome Genome - Collection of all chromosomes for an individual

6 GA Requirements A typical genetic algorithm requires two things to be defined: a genetic representation of the solution domain, and a fitness function to evaluate the solution domain.

7 Basic Components In general, a GA has five basic components, as summarized A genetic representation of potential solutions to the problem. A way to create a population (an initial set of potential solutions). An evaluation function rating solutions in terms of their fitness. Genetic operators that alter the genetic composition of offspring (selection, crossover, mutation, etc.). Parameter values that genetic algorithm uses (population size, probabilities of applying genetic operators, etc.).

8 General Structure of Genetic Algorithms
Genetic Representation and Initialization: The genetic algorithm maintains a population P(t) of chromosomes or individuals vk(t), k=1, 2, …, popSize for generation t. Each chromosome represents a potential solution to the problem at hand. Evaluation: Each chromosome is evaluated to give some measure of its fitness eval(vk). Genetic Operators: Some chromosomes undergo stochastic transformations by means of genetic operators to form new chromosomes, i.e., offspring.

9 General Structure of Genetic Algorithms
There are two kinds of transformation: Crossover, which creates new chromosomes by combining parts from two chromosomes. Mutation, which creates new chromosomes by making changes in a single chromosome. New chromosomes, called offspring C(t), are then evaluated. Selection: A new population is formed by selecting the more fit chromosomes from the parent population and the offspring population. Best solution: After several generations, the algorithm converges to the best chromosome, which hopefully represents an optimal or suboptimal solution to the problem.

10 General Structure of Genetic Algorithm
Initial solutions encoding crossover CC(t) t P(t) offspring chromosome mutation offspring selection N new population termination condition? decoding P(t) + C(t) solutions candidates Y roulette wheel stop fitness computation best solution

11 Example with Simple Genetic Algorithms
The numerical example of optimization problem is given as follows: max f (x1, x2) = x1·sin(4p x1) + x2·sin(20p x2) s. t £ x1 £ 12.1 4.1 £ x2 £ 5.8

12 Representation The required bits (denoted with mj) for a variable is calculated as follows: x1 : (12.1-(-3.0))  10,000 = 151,000 217 <151,000  218, m1 = 18 bits x2 : ( )  10,000 = 17,000 214 <17,000  215, m2 = 15 bits

13 Representation precision requirement: m = m1 + m2 = = 33 bits

14 Representation Binary String Decoding
The mapping from a binary string to a real number for variable xj is completed as follows:

15 Initial Population Initial population is randomly generated as follows: v1 = [ ] = [x1 x2] = [ ] v2 = [ ] = [x1 x2] = [ ] v3 = [ ] = [x1 x2] = [ ] v4 = [ ] = [x1 x2] = [ ] v5 = [ ] = [x1 x2] = [ ] v6 = [ ] = [x1 x2] = [ ] v7 = [ ] = [x1 x2] = [ ] v8 = [ ] = [x1 x2] = [ ] v9 = [ ] = [x1 x2] = [ ] v10 = [ ] = [x1 x2] = [ ]

16 Evaluation Example: (x1=-2.687969, x2= 5.361653)
The process of evaluating the fitness of a chromosome consists of the following three steps: f (x1, x2) = x1·sin(4π x1) + x2·sin(20π x2) Example: (x1= , x2= ) eval(v1) = f ( , ) =

17 Evaluation An evaluation function plays the role of the environment, and it rates chromosomes in terms of their fitness. The fitness function values of above chromosomes are as follows: It is clear that chromosome v4 is the strongest one and that chromosome v3 is the weakest one. eval(v1) = f ( , ) = eval(v2) = f ( , ) = eval(v3) = f ( , ) = eval(v4) = f ( , ) = eval(v5) = f ( , ) = eval(v6) = f ( , ) = eval(v7) = f ( , ) = eval(v8) = f ( , ) = eval(v9) = f ( , ) = eval(v10) = f ( , ) =

18 Genetic Operators Selection: In most practices, a roulette wheel approach is adopted as the selection procedure, which is one of the fitness-proportional selection and can select a new population with respect to the probability distribution based on fitness values. The roulette wheel can be constructed with the following steps: input: population P(t-1), C(t-1) output: population P(t), C(t) step 1: Calculate the total fitness for the population step 2: Calculate selection probability pk for each chromosome vk step 3: Calculate cumulative probability qk for each chromosome vk step 4: Generate a random number r from the range [0, 1]. step 5: If r  q1, then select the first chromosome v1; otherwise, select the kth chromosome vk (2  k  popSize) such that qk-1< r  qk .

19 å Genetic Operators Illustration of Selection: 135372 . 178 ) ( = eval
step 1: Calculate the total fitness F for the population. 135372 . 178 ) ( 10 1 = å k eval F v step 2: Calculate selection probability pk for each chromosome vk. step 3: Calculate cumulative probability qk for each chromosome vk. step 4: Generate a random number r from the range [0,1]. , , , , , , , , ,

20 Genetic Operators Illustration of Selection:
step 5: q3< r1 =  q4, it means that the chromosome v4 is selected for new population; q3< r2 =  q4, it means that the chromosome v4 is selected again, and so on. Finally, the new population consists of the following chromosome. v1' = [ ] (v4 ) v2' = [ ] (v4 ) v3' = [ ] (v8 ) v4' = [ ] (v9 ) v5' = [ ] (v4 ) v6' = [ ] (v7 ) v7' = [ ] (v2 ) v8' = [ ] (v4 ) v9' = [ ] (v1 ) v10' = [ ] (v2 )

21 crossing point at 17th gene
Genetic Operators Crossover (One-cut point Crossover) Crossover used here is one-cut point method, which random selects one cut point. Exchanges the right parts of two parents to generate offspring. Consider two chromosomes as follow and the cut point is randomly selected after the 17th gene: crossing point at 17th gene v1 = [ ] v2 = [ ] c1 = [ ] c2 = [ ]

22 mutating point at 16th gene
Genetic Operators Mutation Alters one or more genes with a probability equal to the mutation rate. Assume that the 16th gene of the chromosome v1 is selected for a mutation. Since the gene is 1, it would be flipped into 0. So the chromosome after mutation would be: mutating point at 16th gene v1 = [ ] c1 = [ ]

23 Example with Simple Genetic Algorithms
Next Generation v1' = [ ], f ( , ) = v2' = [ ], f ( , ) = v3' = [ ], f ( , ) = v4' = [ ], f ( , ) = v5' = [ ], f ( , ) = v6' = [ ], f ( , ) = v7' = [ ], f ( , ) = v8' = [ ], f ( , ) = v9' = [ ], f ( , ) = v10' = [ ], f ( , ) =

24 Example with Simple Genetic Algorithms
Final Result The test run is terminated after 1000 generations. We obtained the best chromosome in the 884th generation as follows: max f (x1, x2) = x1·sin(4p x1) + x2·sin(20p x2) s. t £ x1 £ 12.1 4.1 £ x2 £ 5.8 eval ( v * ) =f ( 11 . 622766 , 5 . 624329 ) = 38 . 737524 x * = 11 . 622766 1 x * = 5 . 624329 2 f ( x * ,x * ) = 38 . 737524 1 2

25 Economic Load Dispatch problem using GA
Similarly Economic Load Dispatch problem can be solved Minimize Limits for PG1


Download ppt "EE368 Soft Computing Genetic Algorithms."

Similar presentations


Ads by Google