18
Genetic Algorithms Genetic Algorithms Siddhartha K. Shakya Siddhartha K. Shakya School of Computing. School of Computing. The Robert Gordon University The Robert Gordon University Aberdeen, UK Aberdeen, UK [email protected] [email protected]

Genetic Algorithms Siddhartha K. Shakya School of Computing. The Robert Gordon University Aberdeen, UK [email protected]

Embed Size (px)

Citation preview

Page 1: Genetic Algorithms Siddhartha K. Shakya School of Computing. The Robert Gordon University Aberdeen, UK ss@comp.rgu.ac.uk

Genetic AlgorithmsGenetic AlgorithmsSiddhartha K. ShakyaSiddhartha K. ShakyaSchool of Computing.School of Computing.

The Robert Gordon UniversityThe Robert Gordon UniversityAberdeen, UKAberdeen, UK

[email protected]@comp.rgu.ac.uk

Page 2: Genetic Algorithms Siddhartha K. Shakya School of Computing. The Robert Gordon University Aberdeen, UK ss@comp.rgu.ac.uk

What are GAs?What are GAs?

Class of Evolutionary algorithmClass of Evolutionary algorithm Based on Darwinian EvolutionBased on Darwinian Evolution First proposed by John Holland 1960s. First proposed by John Holland 1960s.

1970s1970s Used to solve wide verity of Optimization Used to solve wide verity of Optimization

problems occurring in engineering Science problems occurring in engineering Science and Business.and Business.

Page 3: Genetic Algorithms Siddhartha K. Shakya School of Computing. The Robert Gordon University Aberdeen, UK ss@comp.rgu.ac.uk

What is an Optimization Problem?What is an Optimization Problem?

Is to find optimum or near optimum Is to find optimum or near optimum solution from the possible set of candidate solution from the possible set of candidate solutionsolution

Search through big solution space to find Search through big solution space to find best solutionbest solution

There is some scoring criteria for There is some scoring criteria for evaluating goodness of solution also evaluating goodness of solution also called fitness of solutioncalled fitness of solution

Page 4: Genetic Algorithms Siddhartha K. Shakya School of Computing. The Robert Gordon University Aberdeen, UK ss@comp.rgu.ac.uk

Example: Graph colouring problem Example: Graph colouring problem (GCP)(GCP)

Given a set of colours, GCP is to try and assign Colour to each nodes in such the way that neighbouring nodes will not have same colour

a

b de

f

c

Page 5: Genetic Algorithms Siddhartha K. Shakya School of Computing. The Robert Gordon University Aberdeen, UK ss@comp.rgu.ac.uk

What is a solution and a fitness?What is a solution and a fitness?

Solution is a set of colours assigned to the Solution is a set of colours assigned to the nodes of graph. nodes of graph.

Fitness is the number of correctly coloured Fitness is the number of correctly coloured nodes.nodes.

Page 6: Genetic Algorithms Siddhartha K. Shakya School of Computing. The Robert Gordon University Aberdeen, UK ss@comp.rgu.ac.uk

What is a solution and a fitness?What is a solution and a fitness?

Given 2 colourBlack = 0White = 1

a

b de

f

c1

10

0

10

a

b de

f

c

1

11

0

00

a

b de

f

c1

10

0

00

a

b de

f

c

1

10

1

10

a

b de

f

c

Fitness = 1

Fitness = 2

Fitness = 6

Fitness = 0

Page 7: Genetic Algorithms Siddhartha K. Shakya School of Computing. The Robert Gordon University Aberdeen, UK ss@comp.rgu.ac.uk

Graph Colouring Problem (GCP)Graph Colouring Problem (GCP)

Looks very simpleLooks very simple But as the size of the graph grows, it But as the size of the graph grows, it

becomes increasingly difficult. becomes increasingly difficult. Lots of different problems can be see as a Lots of different problems can be see as a

GCPGCP One of the approach to solve GCP is GAOne of the approach to solve GCP is GA

Page 8: Genetic Algorithms Siddhartha K. Shakya School of Computing. The Robert Gordon University Aberdeen, UK ss@comp.rgu.ac.uk

Representation of Problem in GARepresentation of Problem in GA

Solution is usually represented as a bit Solution is usually represented as a bit string called chromosomestring called chromosome

1

10

1

10

a

b de

f

c

1 0 0 1 1 1

a b c d e f

1

fitness

1

11

0

00

a

b de

f

c1 0 1 0 1 0 6

Page 9: Genetic Algorithms Siddhartha K. Shakya School of Computing. The Robert Gordon University Aberdeen, UK ss@comp.rgu.ac.uk

Work flow of GAWork flow of GA

1.1. Initialization of parent populationInitialization of parent population

2.2. EvaluationEvaluation

3.3. SelectionSelection

4.4. Crossover/recombinationCrossover/recombination

5.5. MutationMutation

6.6. Evaluate child and Go to step 3 until Evaluate child and Go to step 3 until termination criteria satisfiestermination criteria satisfies

Page 10: Genetic Algorithms Siddhartha K. Shakya School of Computing. The Robert Gordon University Aberdeen, UK ss@comp.rgu.ac.uk

Initialization of parent populationInitialization of parent population

Generate the Generate the MM number of solution string number of solution string known as parent populationknown as parent population

Mostly randomMostly random

1 0 1 0 0 1

0 0 1 0 1 1

1 0 1 0 1 1

0 1 0 0 1 1

Page 11: Genetic Algorithms Siddhartha K. Shakya School of Computing. The Robert Gordon University Aberdeen, UK ss@comp.rgu.ac.uk

EvaluationEvaluation

Give fitness to each of the solutionGive fitness to each of the solution

a

b de

f

c

1 0 1 1 0 1

0 0 1 0 1 1

1 0 1 0 1 1

0 1 0 0 1 1

Parent population

2

2

4

3

fitness

Page 12: Genetic Algorithms Siddhartha K. Shakya School of Computing. The Robert Gordon University Aberdeen, UK ss@comp.rgu.ac.uk

SelectionSelection Fit solution are likely to survive and bad solution Fit solution are likely to survive and bad solution

are likely to die offare likely to die off Select some of the best fit chromosomes from Select some of the best fit chromosomes from

parent population according some selection parent population according some selection criteria (eg. Roulette wheel selection)criteria (eg. Roulette wheel selection)

1 0 1 1 0 1

0 0 1 0 1 1

1 0 1 0 1 1

0 1 0 0 1 1

Parent population

2

2

4

3

fitness

1 0 1 0 1 1 4

0 1 0 0 1 1 3

0 1 0 0 1 1 3

1 0 1 1 0 1 4

selection fitness

Page 13: Genetic Algorithms Siddhartha K. Shakya School of Computing. The Robert Gordon University Aberdeen, UK ss@comp.rgu.ac.uk

Crossover/RecombinationCrossover/Recombination Exchange partial solution between pair of Exchange partial solution between pair of

selected solution with some probability value eg selected solution with some probability value eg 70%70%

1 0 1 0 1 1

0 1 0 0 1 1

0 1 0 0 1 1

1 0 1 1 0 1

Selected Solution

0 1 1 0 1 1

1 0 0 0 1 1

0 1 0 1 0 1

1 0 1 0 1 1

Child Population After Crossover

Page 14: Genetic Algorithms Siddhartha K. Shakya School of Computing. The Robert Gordon University Aberdeen, UK ss@comp.rgu.ac.uk

MutationMutation Change the value of an allele of solution with Change the value of an allele of solution with

some small probability value eg 1%some small probability value eg 1% Motivation is to explore new point in the solution Motivation is to explore new point in the solution

spacespace

0 1 1 0 1 1

1 0 0 0 1 1

0 1 0 1 0 1

1 0 1 0 1 1

Child Population After Crossover

0 1 1 0 1 1

1 0 0 0 1 0

0 1 0 1 0 1

1 0 1 0 1 1

Child Population After mutation

Page 15: Genetic Algorithms Siddhartha K. Shakya School of Computing. The Robert Gordon University Aberdeen, UK ss@comp.rgu.ac.uk

Replace with parent population and Replace with parent population and repeat processrepeat process

Evaluate child population and replace parent Evaluate child population and replace parent population population

Go to selection step and repeat the process until Go to selection step and repeat the process until termination criteria satisfiestermination criteria satisfies

Eg. Exit after given number of iteration finishesEg. Exit after given number of iteration finishes

0 1 1 0 1 1

1 0 0 0 1 0

0 1 0 1 0 1

1 0 1 0 1 1

Replaced Parent Population

1

2

4

6

fitnessa

b de

f

c

Page 16: Genetic Algorithms Siddhartha K. Shakya School of Computing. The Robert Gordon University Aberdeen, UK ss@comp.rgu.ac.uk

Putting Everything togetherPutting Everything together

1 0 1 1 0 1

0 0 1 0 1 1

1 0 1 0 1 1

0 1 0 0 1 1

Parent population

2

2

4

3

fitness1 0 1 0 1 1

0 1 0 0 1 1

0 1 0 0 1 1

1 0 1 1 0 1

Selected Solution

0 1 1 0 1 1

1 0 0 0 1 1

0 1 0 1 0 1

1 0 1 0 1 1

After Crossover

0 1 1 0 1 1

1 0 0 0 1 0

0 1 0 1 0 1

1 0 1 0 1 1

After mutation

1

2

6

4

fitness

Initialization Evaluation

SelectionCrossover

Mutation

Repeat iteration

ab d

e

f

c

Given 2 colours(0,1)

Page 17: Genetic Algorithms Siddhartha K. Shakya School of Computing. The Robert Gordon University Aberdeen, UK ss@comp.rgu.ac.uk

ConclusionConclusion

Different selection, crossover and mutation Different selection, crossover and mutation operators exists.operators exists.

Different GAs designed for different Different GAs designed for different problemsproblems

Hybridise GA with other search algorithmsHybridise GA with other search algorithms Probabilistic Model Building Genetic Probabilistic Model Building Genetic

Algorithms (PMBGAs)Algorithms (PMBGAs)

Page 18: Genetic Algorithms Siddhartha K. Shakya School of Computing. The Robert Gordon University Aberdeen, UK ss@comp.rgu.ac.uk

LinksLinks

Introductory tutorial on GA By D.E GoldbergIntroductory tutorial on GA By D.E Goldberghttp://online.engr.uiuc.edu/shortcourses/innovation/index.htmlhttp://online.engr.uiuc.edu/shortcourses/innovation/index.html GA ArchiveGA Archivehttp://www.aic.nrl.navy.mil/galist/http://www.aic.nrl.navy.mil/galist/

Introductory BooksIntroductory Books

David E. Goldberg. 1989. David E. Goldberg. 1989. Genetic Algorithms in search, optimization and machine Genetic Algorithms in search, optimization and machine learning.learning. Addison-Wesley.0-201-15767-5 Addison-Wesley.0-201-15767-5

Mitchell, M. (1998). Mitchell, M. (1998). An Introduction to genetic AlgorithmAn Introduction to genetic Algorithm. MIT Press. 0-262-113316-. MIT Press. 0-262-113316-

4(HB)4(HB)