genetic algorithm

40
Genetic Algorithm Made By -Garima Singhal

Upload: garima931

Post on 20-Jan-2015

13.214 views

Category:

Education


0 download

DESCRIPTION

Presentation is about genetic algorithms. Also it includes introduction to soft computing and hard computing. Hope it serves the purpose and be useful for reference.

TRANSCRIPT

Page 1: Genetic algorithm

Genetic Algorithm

Made By-Garima Singhal

Page 2: Genetic algorithm

Introduction

• One of the central challenges of computer science

is to get a computer to do what needs to be done,

without telling it how to do it.

Page 3: Genetic algorithm

• Before looking forward to what actually is

GENETIC PROGRAMMING we shall first get

acquainted with Soft Computing.

Page 4: Genetic algorithm
Page 5: Genetic algorithm
Page 6: Genetic algorithm

Soft Computing

• It is another field of computer science.

• It is the fusion of methodologies that were designed to model

and enable solutions to real world problems, which are not

modeled, or too difficult to model, mathematically.

• It is associated with fuzzy, complex and dynamic system with

uncertain parameters.

• Quality of Service Networking is an example of the class of

complex, fuzzy and dynamic systems with uncertain

parameters, which soft computing is intended to model and

compute.

Page 7: Genetic algorithm

Difference between Soft computing And Conventional Computing

Hard Computing(Conventional)

Soft Computing

Requires precisely stated analytical model and a lot of computation time.

Tolerant of imprecision, uncertainty and approximation.

Based on binary logic, numerical analysis and crisp software.

Based on fuzzy logic, neural networks and probabilistic reasoning.

Requires programs to be written. Can evolve its own programs.

Deterministic. Incorporates stochasticity.

Strictly sequential. Allows parallel computations.

Page 8: Genetic algorithm

Current Applications of Soft Computing include

• Handwriting Recognition

• Image Processing and Data Compression

• Automotive Systems and Manufacturing

• Decision –Support Systems

• Neurofuzzy Systems

• Fuzzy Logic Control

Page 9: Genetic algorithm

Evolutionary Computation

• Evolutionary computation simulates evolution on a computer. The Evolutionary computation simulates evolution on a computer. The

result of such a simulation is a series of optimization algorithms, result of such a simulation is a series of optimization algorithms,

usually based on a simple set of rules. Optimizationusually based on a simple set of rules. Optimization iteratively iteratively

improves the quality of solutions until an optimal, or at improves the quality of solutions until an optimal, or at

least feasible, solution is found.least feasible, solution is found.

Page 10: Genetic algorithm

Contd…

• Evolutionary Computations can be studied under 2 categories:

Genetic Algorithm

Genetic programming

Page 11: Genetic algorithm
Page 12: Genetic algorithm

F inonacc i N ew ton

D irect m ethods Indirect m ethods

C alcu lus-based techn iques

Evolu tionary s trategies

C entra l ized D is tr ibuted

Para l le l

S teady-s ta te G enera tiona l

Sequentia l

G enetic a lgori thm s

Evolutionary a lgori thm s S im u lated annealing

G uided random search techniques

D ynam ic program m ing

Enum erative techn iques

Search techniques

Page 13: Genetic algorithm

Genetic Algorithm Terminologies

Now, before we start, we should understand some key terms :

Individual  Any possible solution

 Population Group of all individuals

Search Space

All possible solutions to the problem

Chromosome Blueprint for an individual

Trait Possible aspect of an individual

Allele  Possible settings for a trait

Locus  The position of a gene on the chromosome

Genome Collection of all chromosomes for an individual

Page 14: Genetic algorithm

Premise

Evolution works biologically so maybe it will work with

simulated environments.

Here each possible solution (good or bad) is represented

by a chromosome (i.e. a pattern of bits which is sort of

synonymous to DNA)

Determine the better solutions

Mate these solutions to produce new solutions which are

(hopefully!) occasionally better than the parents.

Do this for many generations.

Page 15: Genetic algorithm

Outline of the Genetic Algorithm

• Randomly generate a set of possible solutions to a problem,

representing each as a fixed length character string

• Test each possible solution against the problem using a

fitness function to evaluate each solution

• Keep the best solutions, and use them to generate new

possible solutions

• Repeat the previous two steps until either an acceptable

solution is found, or until the algorithm has iterated through a

given number of cycles (generations)

Page 16: Genetic algorithm

Basic Operators of Genetic Algorithm

• Reproduction: It is usually the first operator applied on population. Chromosomes are selected from the population of parents to cross over and produce offspring. It is based on Darwin’s evolution theory of “Survival of the fittest”. Therefore, this operator is also known as ‘Selection Operator’.

• Cross Over: After reproduction phase, population is enriched with better individuals. It makes clones of good strings but doesnot create new ones. Cross over operator is applied to the mating pool with a hope that it would create better strings.

• Mutation: After cross over, the strings are subjected to mutation. Mutation of a bit involves flipping it,changing 0 to 1 and vice-versa.

Page 17: Genetic algorithm

Basic genetic algorithmsBasic genetic algorithms

• Step 1Step 1: : Represent the problem variable domain as a chromosome of a Represent the problem variable domain as a chromosome of a fixed length, choose the size of a chromosome population fixed length, choose the size of a chromosome population NN, the , the crossover probability crossover probability ppcc and the mutation probability and the mutation probability ppmm..

• Step 2Step 2: : Define a fitness function to measure the performance, or Define a fitness function to measure the performance, or fitness, of an individual chromosome in the problem domain. The fitness fitness, of an individual chromosome in the problem domain. The fitness function establishes the basis for selecting chromosomes that will be function establishes the basis for selecting chromosomes that will be mated during reproduction.mated during reproduction.

• Step 3Step 3: : Randomly generate an initial population of chromosomes of size Randomly generate an initial population of chromosomes of size NN::xx11, , xx22 , . . . , , . . . , xxNN

• Step 4Step 4: : Calculate the fitness of each individual chromosome:Calculate the fitness of each individual chromosome: f f ((xx11), ), f f ((xx22), . . . , ), . . . , f f ((xxNN))

Page 18: Genetic algorithm

• Step 5Step 5: : Select a pair of chromosomes for mating from the current Select a pair of chromosomes for mating from the current population. Parent`chromosomes are selected with a probability related population. Parent`chromosomes are selected with a probability related to their fitness.to their fitness.

• Step 6Step 6:: Create a pair of offspring chromosomes by applying the genetic Create a pair of offspring chromosomes by applying the genetic operators operators - - crossovercrossover and mand mutationutation..

• Step 7Step 7:: Place the created offspring chromosomes in the new Place the created offspring chromosomes in the new population.population.

• Step 8Step 8:: RepeatRepeat Step 5 Step 5 until the size of the new chromosome population until the size of the new chromosome population becomes equal to the size of the initial population, becomes equal to the size of the initial population, NN..

• Step 9Step 9:: Replace the initial (parent) chromosom population with the Replace the initial (parent) chromosom population with the new (offspring) population.new (offspring) population.

• Step 10Step 10:: Go to Go to Step 4Step 4, and repeat the process until the termination , and repeat the process until the termination criterion is satisfied.criterion is satisfied.

Page 19: Genetic algorithm

Working Principle of Genetic Algorithm

Page 20: Genetic algorithm

Genetic Algorithms: Case StudyGenetic Algorithms: Case Study

• A simple example will help us to understand how a GA works. Let A simple example will help us to understand how a GA works. Let us find the maximum value of the function (15us find the maximum value of the function (15x x - - xx22) where ) where parameter parameter xx varies between 0 and 15. For simplicity, we may varies between 0 and 15. For simplicity, we may assume that assume that x x takes only integer values. Thus, chromosomes can be takes only integer values. Thus, chromosomes can be built with only four genes:built with only four genes:

Integer Binary code Integer Binary code Integer Binary code1 112 7 123 8 134 9 145 10 15

6 1 0 1 11 1 0 01 1 0 11 1 1 01 1 1 1

0 1 1 00 1 1 11 0 0 01 0 0 11 0 1 0

0 0 0 10 0 1 00 0 1 10 1 0 00 1 0 1

Page 21: Genetic algorithm

• Suppose that the size of the chromosome population NSuppose that the size of the chromosome population N is 6, the is 6, the

crossover probability crossover probability ppcc equals 0.7, and the mutation probability equals 0.7, and the mutation probability ppmm

equals 0.001. The fitness function in our example is definedequals 0.001. The fitness function in our example is defined byby

ff((xx) = ) = 15 15 x x – – xx22

Page 22: Genetic algorithm

The fitness function and chromosome The fitness function and chromosome locationslocations

Chromosomelabel

Chromosomestring

Decodedinteger

Chromosomefitness

Fitnessratio, %

X1 1 1 0 0 12 36 16.5X2 0 1 0 0 4 44 20.2X3 0 0 0 1 1 14 6.4X4 1 1 1 0 14 14 6.4X5 0 1 1 1 7 56 25.7X6 1 0 0 1 9 54 24.8

x

50

40

30

20

60

10

00 5 10 15

f(x)

(a) Chromosome initial locations.

x

50

40

30

20

60

10

00 5 10 15

(b) Chromosome final locations.

Page 23: Genetic algorithm

• The last column in Table shows the ratio of the individual The last column in Table shows the ratio of the individual

chromosome’s fitness to the population’s total fitness. This ratio chromosome’s fitness to the population’s total fitness. This ratio

determines the chromosome’s chance of being selected for mating. The determines the chromosome’s chance of being selected for mating. The

chromosome’s average fitness improves from one generation to the chromosome’s average fitness improves from one generation to the

next.next.

Page 24: Genetic algorithm

Roulette wheel selectionRoulette wheel selection

• The most commonly used chromosome selection techniques is the The most commonly used chromosome selection techniques is the roulette wheel selectionroulette wheel selection..

100 0

36.743.149.5

75.2

X1: 16.5%X2: 20.2%X3: 6.4%X4: 6.4%X5: 25.3%X6: 24.8%

Page 25: Genetic algorithm

Crossover operatorCrossover operator

• In our example, we have an initial population of 6 chromosomes. In our example, we have an initial population of 6 chromosomes. Thus, to establish the same population in the next generation, the Thus, to establish the same population in the next generation, the roulette wheel would be spun six times.roulette wheel would be spun six times.

• Once a pair of parent chromosomes is selected, the Once a pair of parent chromosomes is selected, the crossovercrossover operator is applied.operator is applied.

• First, the crossover operator randomly chooses a crossover point First, the crossover operator randomly chooses a crossover point where two parent chromosomes “break”, and then exchanges the where two parent chromosomes “break”, and then exchanges the chromosome parts after that point. As a result, two new offspring chromosome parts after that point. As a result, two new offspring are created.are created.

• If a pair of chromosomes does not cross over, then the chromosome If a pair of chromosomes does not cross over, then the chromosome cloning takes place, and the offspring are created as exact copies of cloning takes place, and the offspring are created as exact copies of each parent.each parent.

Page 26: Genetic algorithm

X6i 1 00 0 01 0 X2i

0 01 0X2i 0 11 1 X5i

0X1i 0 11 1 X5i1 01 0

0 10 0

11 101 0

Page 27: Genetic algorithm

Mutation operatorMutation operator

• Mutation represents a change inMutation represents a change in the gene.the gene.

• Mutation is a background operator. Its role is to provide a guarantee Mutation is a background operator. Its role is to provide a guarantee

that the search algorithm is not trapped on a local optimum.that the search algorithm is not trapped on a local optimum.

• The mutation operator flips a randomly selected gene in a The mutation operator flips a randomly selected gene in a

chromosome.chromosome.

• The mutation probability is quite small in nature, and is kept low for The mutation probability is quite small in nature, and is kept low for

GAs, typically in the range between 0.001 and 0.01.GAs, typically in the range between 0.001 and 0.01.

Page 28: Genetic algorithm

0 11 1X5'i 01 0

X6'i 1 00

0 01 0X2'i 0 1

0 0

0 1 111X5i

1 1 1 X1"i1 1

X2"i0 1 0

0X1'i 1 1 1

0 1 0X2i

Page 29: Genetic algorithm

1 01 0X1i

Generation i

0 01 0X2i

0 00 1X3i

1 11 0X4i

0 11 1X5i f = 56

1 00 1X6i f = 54

f = 36

f = 44

f = 14

f = 14

1 00 0X1i+1

Generation (i + 1)

0 01 1X2i+1

1 10 1X3i+1

0 01 0X4i+1

0 11 0X5i+1 f = 54

0 11 1X6i+1 f = 56

f = 56

f = 50

f = 44

f = 44

Crossover

X6i 1 00 0 01 0 X2i

0 01 0X2i 0 11 1 X5i

0X1i 0 11 1 X5i1 01 0

0 10 0

11 101 0

Mutation

0 11 1X5'i 01 0

X6'i 1 00

0 01 0X2'i 0 1

0 0

0 1 111X5i

1 1 1 X1"i1 1

X2"i0 1 0

0X1'i 1 1 1

0 1 0X2i

Page 30: Genetic algorithm

Example Checkboard

• We are given an n by n checkboard in which every field can have a different colour from a set of four colours.

• Goal is to achieve a checkboard in a way that there are no neighbours with the same colour (not diagonal).

1 2 3 4 5 6 7 8 9 10

1

2

3

4

5

6

7

8

9

10

1 2 3 4 5 6 7 8 9 10

1

2

3

4

5

6

7

8

9

10

Page 31: Genetic algorithm

• Chromosomes represent the way the checkboard is coloured.

• Chromosomes are not represented by bitstrings but by bitmatrices

• The bits in the bitmatrix can have one of the four values 0, 1, 2 or 3, depending on the colour

• Crossing-over involves matrix manipulation instead of point wise operating. Crossing-over can be combining the parential matrices in a horizontal, vertical, triangular or square way

• Mutation remains bitwise changing bits in either one of the other numbers

Page 32: Genetic algorithm

• Fitness curve for the checkboard example

• This problem can be seen as a graph with n nodes and (n-1) edges, so the fitness f(x) is easily defined as: f(x) = 2 · (n-1) ·n

0 100 200 300 400 500 600130

135

140

145

150

155

160

165

170

175

180

Generations

Fitn

ess

Best FitnessMean Fitness

Page 33: Genetic algorithm

0 100 200 300 400 500130

140

150

160

170

180

Fitne

ss

Lower-Triangular Crossing Over

0 200 400 600 800130

140

150

160

170

180Square Crossing Over

0 200 400 600 800130

140

150

160

170

180

Generations

Fitne

ss

Horizontal Cutting Crossing Over

0 500 1000 1500130

140

150

160

170

180

Generations

Verical Cutting Crossing Over

Fitnesscurves for different cross-over rules

Page 34: Genetic algorithm

The GA Cycle of Reproduction

Population

Fitness EvaluationGenetic Operators

Selection(Mating Pool)

Parents

Offspring

New Generation

Manipulation Reproduction

Decoded Strings

Page 35: Genetic algorithm

Issues for Genetic Algorithm practitioners

• Choosing basic implementation issues such as

Representation

Population size and mutation rate

Selection, deletion policies

Cross over and mutation operators

• Termination criterion

• Performance and scalability

• Solution is only as good as evaluation functions.

Page 36: Genetic algorithm

Benefits Of Genetic Algorithms

• Easy to understand

• Supports multi-objective optimisation

• Good for noisy environment

• We always get answer and answer gets better with time

• Inherently parallel and easily distributed

• Easy to exploit for precious or alternate solutions

• Flexible in forming building blocks for hybrid applications

• Has substantial history and range of use

Page 37: Genetic algorithm

Genetic Algorithm Applications

Domains Application Types

Control Gas pipeline, pole balancing, missile evasion, pursuit

Robotics Trajectory planning

Signal Processing Filter design

Game Playing Poker, checker, prisoner’s dilemma

Scheduling Manufacturing facility, scheduling, resource allocation

Design Semiconductor layout, aircraft design, keyboard configuration, communication networks

Combinatorial Optimisation

Set covering, travelling salesmen, routing, bin packing, graph coloring and partitioning

Page 38: Genetic algorithm

Any Questions

Page 39: Genetic algorithm

Bibliography

• www.softcomputing.net/gpsystems.pdf

• http://cs.mwsu.edu/~simpson/

• http://geneticalgorithms.ai-depot.com/Tutorial/Overview.html

• Neural Networks, Fuzzy Logic, And Genetic Algorithm:Synthesis And Application

• S.Rajasekaran• G.A.Vijayalakshmi Pai

• http://c2.com/cgi/wiki?GeneticAlgorithm

Page 40: Genetic algorithm