32
Introduction to Genetic Algorithm (GA) Presented By: Rabiya Khalid Department of Computer Science 1

Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

  • Upload
    dangnga

  • View
    215

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

Introduction to Genetic Algorithm (GA)

Presented By: Rabiya Khalid

Department of Computer Science

1

Page 2: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

GA (1/31)

• Introduction– Based on Darwin’s theory of evolution– Rapidly growing area of artificial intelligence– Used to solve optimization based problems– Techniques inspired by evolutionary biology

o Inheritanceo Mutationo Selectiono Crossover

• History– Evolutionary computing evolved in the 1960’s by I.Rechenberg– GA’s were invented by John Holland in the mid-70’s.

2

Page 3: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

GA (2/31)

3

Page 4: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

• Lets learn biology first– Our body is made up of trillions of cells– Each cell has a core structure (nucleus)

that contains chromosomes– Each chromosome is made up of tightly

coiled strands of deoxyribonucleic acid(DNA)

– Genes are segments of DNA thatdetermine specific traits, such as• Eye color• Hair color

– A gene mutation is an alteration in DNA– It can be inherited or acquired during

your lifetime– Some changes in genes result in genetic

disorders.

GA (3/31)

4

Page 5: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

• Natural selection– Only the organisms best adapted to their environment tend to

survive– Transmit their genetic characteristics in increasing numbers to

succeeding generations– Those less adapted tend to be eliminated

• GA is inspired from nature– A genetic algorithm maintains

o Population of candidate solutions for the problem o Makes it evolve by iteratively applying a set of stochastic operators

GA (4/31)

5

Page 6: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

GA (5/31)

6

Page 7: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

• Key terms– Individual

o Any possible solution – Population

o Group of all individuals– Search Space

o All possible solutions to the problem – Chromosome

o Blueprint for an individual– Trait

o Possible aspect (features) of an individual

– Allele o Possible settings of trait (black, blond,

etc.)– Locus

o The position of a gene on the chromosome

– Genome o Collection of all chromosomes for an

individual

GA (6/31)

7

Page 8: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

Key terms General use Role in Smart grid

Individual Any possible solution On-off status of appliances in a time slot

Population Group of all individuals Collection of all chromosomes

Search Space All possible solutions to the problem

Any values in constraint defined limits

Chromosome Blueprint for an individual Duplicate values of objective function

Allele Possible settings of trait (black, blond, etc.)

Characteristics of definedsystem to satisfy optimization limits

Locus The position of a gene on the chromosome

Single bit (0 or 1)

Genome Collection of all chromosomes for an individual

Binary on /off (1/ 0) states arrays for each appliance

GA (7/31)

8

Page 9: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

• GA requirements– A genetic representation of the solution domain (set search

space)– A fitness function to evaluate the solution domain (objective

function according to system model in case of smart grid)

• Representation– Chromosomes could be

• Bit strings (0101 ... 1100)• Real numbers (43.2 -33.1 ... 0.0 89.2) • Permutations of element (E11 E3 E7 ... E1 E15)• Lists of rules (R1 R2 R3 ... R22 R23)• Program elements (genetic programming)• ... any data structure ...

GA (8/31)

9

Page 10: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

• Algorithm1. Initialization

2. Generate population

3. Evaluate fitness

4. While gen<max_gen do

5. Select two parents

6. Crossover

7. Mutation

8. Evaluate fitness

9. Elitism

10. End

GA (9/31)

10

Page 11: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

• Fitness function– The fitness function is always problem dependent– Assigns fitness value to the individual– It summarizes, how close a solution is to achieving the set aims

GA (10/31)

11

Page 12: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

• Selection– Darwinian survival of fittest– More preference to get better guys– Ways to select

• Roulette wheel• Tournament• Truncation

– By itself, pick best

• Roulette wheel– Probability of selection is assigned to individuals based on their

fitness value– Two parents are selected randomly from set of individuals with high

selection probability– Selected parents are used to produce off-springs

GA (11/31)

12

Page 13: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

• Crossover

– Single point crossover

– Two point crossover

– Uniform crossover

GA (12/31)

13

Page 14: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

GA (13/31)

• Mutation– String subjected to mutation

after crossover– It prevents falling all solutions

into local optimum– It alters bits of chromosomes

to make the string better– Bit wise mutation is

performed with probability of mutation Po

– A random number ro is generated and compared with Po

– If Po>ro , then mutation occurs

• Types of mutation– Bit inversion

o Selected bits are inverted

– Order changingo The number are selected and

exchanged

14

Page 15: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

• Elitism– Elitism involves copying a small proportion of the fittest

candidates, unchanged, into the next generation– EA does not waste time re-discovering previously discarded

partial solutions

• Search space– The set of solutions among which the desired solution resides– Best solution among a number of possible solutions– Represented by one point in the search space

GA (14/31)

15

Page 16: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

• Advantages of GA – Concepts are easy to understand – Always an answer; answer gets better with time – Less time required for some special applications – Chances of getting optimal solution are more

• Limitations– The population considered for the evolution should be

moderate or suitable– One for the problem (normally 20-30 or 50-100)– Crossover rate should be 80%-95%– Mutation rate should be low i.e. 0.5%-1% assumed as best– The method of selection should be appropriate– Writing of fitness function must be accurate

GA (15/31)

16

Page 17: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

GA (16/31)

17

Page 18: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

GA (17/31)

18

Page 19: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

GA (18/31)

19

Page 20: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

GA (19/31)

20

Page 21: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

GA (20/31)

21

Page 22: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

GA (21/31)

22

Page 23: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

GA (22/31)

23

Page 24: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

GA (23/31)

24

Page 25: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

GA (24/31)

25

Page 26: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

GA (25/31)

26

Page 27: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

GA (26/31)

27

Page 28: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

GA (27/31)

28

Page 29: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

GA (28/31)

29

Page 30: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

GA (29/31)

30

Page 31: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

GA (30/31)

31

Page 32: Introduction to Genetic Algorithm (GA) - njavaid.com€¢Natural selection –Only the organisms best adapted to their environment tend to survive –Transmit their genetic characteristics

GA (31/31)

32