An Exordium of Genetic Algorithms (GAs

)

Mithun.k Mtech ² Technology Management
1

Overview
y History of Genetic Algorithm y Introduction to Genetic Algorithms y GA operators and parameters y Examples for the optimization using GA y Classification of GA y Conclusion

2

4

History Of Genetic Algorithms
y Four historical paradigms that have served as the basis for

Evolutionary Computing are
1) 2) 3) 4)

evolutionary programming evolutionary strategies genetic algorithms genetic programming

(Forgel (Recheuberg (Holland (John Koza

1966) 1973) 1975) 1992)

y differs in the nature of the
o representation schemes, o the reproduction operators o and selection methods.

5

History
1)Genetic Algorithm
y Representation - fixed-length bit string

continue«

0111011011011
y the string is ´evaluated as a collection of structural features of a

solution that have little or no interactionsµ. ||

´Gene represents an entity that is structurally independent of
other genesµ.

6

History
y Position in string

continue«

Value stored in position
y Reproduction :

- feature of an individual - how feature is expressed?

* * *

Cross over Mutation Inversion

7

History
2)Genetic Programming

continue«

y Representation - variable-sized tree of functions and values y entire tree corresponds to a single function that may be evaluated. y Reproduction :
* * * Cross over Mutation Inversion

8

History
3)Evolutionary Strategies y Representation - fixed-length real-valued vector.

continue«

y Reproduction

o Gaussian Mutation o Intermediate Recombination

9

History
4)Evolutionary Programming
y Representing individuals· phenotypically.

continue«

y Applied in finite state machines capable of responding to

environmental stimuli and developing operators for effecting structural and behavioral change over time. y any type of computing tool could be evolved in some way using the GA principles y Reproduction ² Mutation
- No exchange of materials between individuals in population

Why Genetic Algorithm«?
y Conventional methods selecting only one individual at a time

which make them to be in a danger of trapped in a local minima or maxima.

10

What Are Genetic Algorithms (GAs)?

Genetic Algorithms are search and optimization techniques based on Darwin·s Principle of Natural Selection.

11

Darwin·s Principle Of Natural Selection
y IF there are organisms that reproduce, and y IF offspring's inherit traits from their progenitors, and y IF there is variability of traits, and y IF the environment cannot support all members of a growing

population, y THEN those members of the population with less-adaptive traits will die out & those members with more-adaptive traits will survive. y The result is the evolution of species.

12

An Example of Natural Selection
y Giraffes have long necks.
Giraffes with slightly longer necks could feed on leaves of higher branches when all lower ones had been eaten off. They had a better chance of survival. Favorable characteristic propagated through generations of giraffes. Now, evolved species has long necks.

NOTE: Longer necks may have been a deviant characteristic (mutation) initially but since it was favorable, was propagated over generations. Now an established trait.

13

An Example of Natural Selection

continue«

14

Evolution Through Natural Selection
Initial Population Of Animals Struggle For Existence-Survival Of the Fittest Surviving Individuals Reproduce, Propagate Favorable Characteristics

Millions Of Years

Evolved Species
(Favorable Characteristic Now A Trait Of Species)

15

Nature to Computer Mapping

Nature
Population Individual Fitness Chromosome Gene Reproduction

Computer
Set of solutions. Solution to a problem. Quality of a solution. Encoding for a Solution. Part of the encoding of a solution. Crossover

16

Flowchart of Genetic Algorithm

17

Flowchart Explanation
Step 1: Create a Random Initial Population
y An initial population is created from a random selection of solutions y These solutions have been seen as represented by chromosomes as in living

organisms y A chromosome is a packet of genetic information organized in a standard way that defines completely and individual (solution). y The genetic structure (way in which that information is packed and defined) enables the solutions to be manipulated. y The genetic operands (way in which that information can be manipulated) enables the solutions to reproduces and evolve

18

Flowchart Explanation
Step 2:Evaluate Fitness

continue«

y A value for fitness is assigned to each solution (chromosome) depending

on how close it actually is to solving the problem.
y Therefore we need to define the problem, model it, simulate it or have a

data set as sample answers
y Each possible solution has to be tested in the problem & the answer

evaluated (or marked) on how good it is
y The overall mark of each solution relative to all the marks of all

solutions produces a fitness ranking.
19

Flowchart Explanation
Step 3:Produce Next Generation

continue«

y Those chromosomes with a higher fitness value are more likely to y y y y

reproduce offspring The population for the next Generation will be produced using the genetic operators Reproduction by Copy or Crossing Over and Mutation will be applied to the chromosomes according to the selection rule This rule states that the fitter and individual is, the higher the probability it has to reproduce Note that this works with probabilities!

20

Flowchart Explanation
Step 4:Next Generation or Termination

continue«

y If the population in the last generation contains a solution that produces

y y y y

an output that is close enough or equal to the desired answer then the problem has been solved. This is the ideal termination criterion of the evolution If this is not the case, then the new generation will go through the same process as their parents did, and the evolution will continue A termination criterion that always must be included is Time-Out Since one drawback of Evolutionary Programming is that is very difficult (impossible most of the time) to know if the ideal termination criterion is going to be satisfied, or when.

21

GA Operators and Terminologies

22

23

GA Operators and Terminologies
Encoding 2) Fitness function 3) Selection 4) Recombination
1)
y Crossover y Mutation

1) Encoding
The process of representing the solution in the form of a string that conveys the necessary information.
y Just as in a chromosome, each gene controls a particular characteristic

of the individual, similarly, each bit in the string represents a characteristic of the solution.
y Binary Encoding y Octal Encoding y Hexadecimal Encoding y Permutation Encoding y Value Encoding

24 24

Encoding Methods

y Binary Encoding ² Most common method of encoding. Chromosomes are strings of 1s and 0s and each position in the chromosome represents a particular characteristic of the problem.

Chromosome A Chromosome B

10110010110011100101 11111110000000011111

25

Encoding Methods

continue«

y Permutation Encoding ² Useful in ordering problems such as the Traveling Salesman Problem (TSP). Example. In TSP, every chromosome is a string of numbers, each of which represents a city to be visited.

Chromosome A Chromosome B

1 5 3 2 6 4 7 9 8 8 5 6 7 2 3 1 4 9

26

Encoding Methods

continue«

y Value Encoding ² Used in problems where complicated values, such as real numbers, are used and where binary encoding would not suffice.

Good for some problems, but often necessary to develop some specific crossover and mutation techniques for these chromosomes.
Chromosome A Chromosome B 1.235 5.323 0.454 2.321 2.454 (left), (back), (left), (right), (forward)

27

2) Fitness

Function

A fitness function quantifies the optimality of a solution (chromosome) so that that particular solution may be ranked against all the other solutions.
y A fitness value is assigned to each solution depending on how close it

actually is to solving the problem.
y Ideal fitness function correlates closely to goal + quickly computable. y Example. In TSP, f(x) is sum of distances between the cities in solution.

The lesser the value, the fitter the solution is.
28

3)Selection Selection is the process of choosing one or two parents from the population for reproduction.
y The higher the fitness value, the more chance an individual has to be

selected ,which will increase the convergence rate of GA.
y Basic Types y a)Proportionate based :- based on fitness criteria y b)Ordinal based :- based on ranking within the population

29

Selection methods
Roulette Wheel Selection b) Rank Selection c) Tournament Selection d) Elitism
a)

30

a)Roulette Wheel Selection
in proportion to it·s fitness.

31

y Each current string in the population has a slot assigned to it which is

y We spin the weighted roulette wheel thus defined n times (where n is the

total number of solutions).
y Each time Roulette Wheel stops, the string corresponding to that slot

is created. Strings that are fitter are assigned a larger slot and hence have a better chance of appearing in the new population.
31

Example Of Roulette Wheel Selection
No.
1 2 3

String
01101 11000 01000 10011

Fitness
169 576 64 361 1170

% Of Total
14.4 49.2 5.5 30.9 100.0

4

Total
32

Roulette Wheel For Example

33

b)Rank Selection
If the best chromosome fitness is 90%, its circumference occupies 90% of Roulette wheel, and then other chromosomes have too few chances to be selected.
y Ranks the population and every chromosome receives

fitness from the ranking. y The worst has fitness 1 and the best has fitness N. y It preserves diversity and results in slow convergence.

34

c)Tournament Selection
The Tournament selection strategy provides selective pressure by holding a tournament competition among N individuals.
y The best individual from the tournament is the one with

the highest fitness, which is the winner of tournament.
y Tournament competitions and the winner are then

inserted into the mating pool.

35

Tournament Selection (example)
Mating Pool
7993

4 1 3 2 5 6
6872

6872

4 3 2 1 5 6
8971 8673

4 3 2 1 5 6

3 6 4 1 2 5
8673

5 2 6 4 3 1
8971 7993

5 2 6 4 3 1 3 6 4 1 2 5
7993

4 1 3 2 5 6
8479 8142

4 1 3 2 5 6

2 6 3 4 5 1
6872

6 3 4 5 2 1
8142

2 6 3 4 5 1
6872

4 3 2 1 5 6
8479

4 3 2 1 5 6
8673 8142

6 3 4 5 2 1 2 6 3 4 5 1

5 2 6 4 3 1
8142

2 6 3 4 5 1

36

d) Elitism
Elitism is a method which copies the best chromosome to the new offspring population before crossover and mutation.
y When creating a new population by crossover or mutation the

best chromosome might be lost.
y Forces GAs to retain some number of the best individuals at each

generation.
y Has been found that elitism significantly improves performance.

37

4)Recombination
y It is the process for getting new offspring for the mating

pool.
y Types
a) Crossover b) Mutation

38

a) Crossover - Recombination
It is the process in which two chromosomes (strings) combine their genetic material (bits) to produce a new offspring which possesses both their characteristics.
y Two strings are picked from the mating pool at random to cross over. y The method chosen depends on the Encoding Method.

39

Crossover Methods - Recombination
Single Point Crossover ii) Two Point Crossover iii) Uniform Crossover
i)

40

Crossover methods- Recombination
1)Single Point Crossover

Chromosome1 Chromosome 2 Offspring 1 Offspring 2

11011 | 00100110110 11011 | 11000011110 11011 | 11000011110 11011 | 00100110110

41

Crossover methods- Recombination
2)Two-Point Crossover- Two random points are chosen on the
individual chromosomes (strings) and the genetic material is exchanged at these points.
Chromosome1 Chromosome 2 Offspring 1 Offspring 2 11011 | 00100 | 110110 10101 | 11000 | 011110 10101 | 00100 | 011110 11011 | 11000 | 110110

NOTE: These chromosomes are different from the last example.
42

Crossover methods- Recombination
3)Uniform Crossover- Each gene (bit) is selected randomly from
one of the corresponding genes of the parent chromosomes.

Chromosome1 Chromosome 2 Offspring

11011 | 00100 | 110110 10101 | 11000 | 011110 10111 | 00000 | 110110

NOTE: Uniform Crossover yields ONLY 1 offspring.

43

b) Mutation - Recombination
It is the process by which a string is deliberately changed so as to maintain diversity in the population set. Mutation Probability - determines how often the parts of
a chromosome will be mutated. Types :y flipping y interchanging y reversing

44

b)Mutation - Recombination
Flipping :-

continue«

Interchanging : -

Reversing : -

45

Example 1

Genetic Algorithms To Solve The

Maximum of Function

46

GA to solve max<

>

continue«

47

GA to solve max<

>

continue«

y Here I·m using Roulette Wheel Selection.

48

GA to solve max<

>

continue«

The actual count of string no 1 is 1, hence it occurs once in the mating pool.The actual count of string no 2 is 2, hence it occurs twice in the mating pool. Since the actual count of string no 3 is 0, it does not occur in the mating pool. Similarly, the actual count of string no 4 being 1, it occurs once in the mating pool.

crossover operation is performed.
49

GA to solve max<
Mutation is performed

>

continue«

population average fitness has improved from 288.75 to 636.5 in 1 generation

50

Example 2

Genetic Algorithms To Solve The

Traveling Salesman Problem (TSP)

51

The Problem
The Traveling Salesman Problem is defined as:
¶We are given a set of cities and a symmetric distance matrix that indicates the cost of travel from each city to every other city. The goal is to find the shortest circular tour, visiting every city exactly once, so as to minimize the total travel cost, which includes the cost of traveling from the last city back to the first city·.

52

Traveling Salesman Problem

TSP Encoding
y Each city is represented with an integer . y Consider 6 Indian cities ²

Mumbai, Cochin, Calcutta, Delhi , Bangalore and Chennai and assign a number to each. Mumbai Cochin Calcutta Delhi Bangalore Chennai
53

1 2 3 4 5 6

TSP Encoding
6.

continue«

y Thus a path would be represented as a sequence of integers from 1 to

y The path [1 2 3 4 5 6 ] represents a path from Mumbai to Cochin,

Cochin to Calcutta, Calcutta to Delhi, Delhi to Bangalore, Bangalore to Chennai, and finally from Chennai to Mumbai.
y This is an example of Permutation Encoding as the position of the

elements determines the fitness of the solution.

54

Fitness Function
y The fitness function will be the total cost of the tour represented by

each chromosome.
y This can be calculated as the sum of the distances traversed in each

travel segment.

The Lesser The Sum,The Fitter The Solution Represented By That Chromosome.

55

Distance/Cost Matrix For TSP
1 1 2 3 4 5 6 0 863 1987 1407 998 1369 2 863 0 1124 1012 1049 1083 3 1987 1124 0 1461 1881 1676 4 1407 1012 1461 0 2061 2095 5 998 1049 1881 2061 0 331 6 1369 1083 1676 2095 331 0

Cost matrix for six city example.

Distances in Kilometers

56

Fitness Function

continue«

y So, for a chromosome [4 1 3 2 5 6], the total cost of travel or fitness

will be calculated as shown below
y Fitness = 1407 + 1987 + 1124 + 1049 + 331+ 2095

= 7993 kms.
y Since our objective is to Minimize the distance, the lesser the total

distance, the fitter the solution.

57

Selection Operator
y

Used Tournament Selection. As the name suggests tournaments are played between two solutions and the better solution is chosen and placed in the mating pool. Two other solutions are picked again and another slot in the mating pool is filled up with the better solution.

y

y

58

Tournament Selection
Mating Pool
7993

continue«

4 1 3 2 5 6
6872

6872

4 3 2 1 5 6
8971 8673

4 3 2 1 5 6

3 6 4 1 2 5
8673

5 2 6 4 3 1
8971 7993

5 2 6 4 3 1 3 6 4 1 2 5
7993

4 1 3 2 5 6
8479 8142

4 1 3 2 5 6

2 6 3 4 5 1
6872

6 3 4 5 2 1
8142

2 6 3 4 5 1
6872

4 3 2 1 5 6
8479

4 3 2 1 5 6
8673 8142

6 3 4 5 2 1 2 6 3 4 5 1

5 2 6 4 3 1
8142

2 6 3 4 5 1

59

Why we cannot use single-point crossover ?
y Single point crossover method randomly selects a crossover point in

the string and swaps the substrings. y This may produce some invalid offsprings as shown below.

4 1 3 2 5 6

4 1 3 1 5 6

4 3 2 1 5 6

4 3 2 2 5 6

60

Crossover Operator

y Used the Enhanced Edge Recombination operator y This operator is different from other genetic sequencing operators in

that it emphasizes adjacency information instead of the order or position of items in the sequence.
y The algorithm for the Edge-Recombination Operator involves

constructing an Edge Table first.

61

Edge Table
The Edge Table is an adjacency table that lists links into and out of a city found in the two parent sequences. If an item is already in the edge table and we are trying to insert it again, that element of a sequence must be a common edge and is represented by inverting it's sign.

62

Finding The Edge Table
Parent 1 Parent 2

4 1 3 2 5 6 4 3 2 1 5 6

1 2 3 4 5 6

4 -3 1 -6 1 -5

3 5 -2 1 2 -4

2 1 4 3 -6

5

63

Enhanced Edge Recombination Algorithm
1. 2.

Choose the initial city from one of the two parent tours. Remove all occurrences of the current city from the left hand side of the edge table.( These can be found by referring to the edge-list for the current city). If the current city has entries in it's edge-list, go to step 4 otherwise go to step 5. Determine which of the cities in the edge-list of the current city has the fewest entries in it's own edge-list.The city with fewest entries becomes the current city. In case a negative integer is present, it is given preference. Ties are broken randomly. Go to step 2. If there are no remaining unvisited cities, then stop. Otherwise, randomly choose an unvisited city and go to step 2.

3. 4.

5.

64

Enhanced Edge Recombination Algorithm
Step 1
1 2 3 4 5 6 4 -3 1 -6 3 -5 3 5 -2 1 2 -4 2 1 4 3 -6 5 1 2 3 4 5 6

continue«

Step 2
3 -3 1 -6 3 -5 2 5 -2 1 2 3 -6 5 1

4

4 6

65

Enhanced Edge Recombination Algorithm
continue«
Step 3
1 2 3 4 5 3 -3 1 1 3 2 5 -2 3 2 5 1

Step 4

1 2 3 4 5 6

3 -3 1 1 3

2 1 -2 3 2

6

-5

4 6 5

4 6 5 1

66

Enhanced Edge Recombination Algorithm
continue«
Step 5
1 2 3 -3 2

Step 6
1 2 3 4 2 5 6 2 -2 2

3 4 5

-2 3 3

6

4

6

5

1

3

4

6

5

1

3 2

67

Mutation Operator
y The mutation operator induces a change in the solution, so as to

maintain diversity in the population and prevent Premature Convergence. y In our project, we mutate the string by randomly selecting any two cities and interchanging their positions in the solution, thus giving rise to a new tour.

4

1

3

2

5

6

4
68

5

3

2

1

6

Classification of Genetic Algorithm

69

Classification of Genetic Algorithm
1) 2)

Simple Genetic Algorithm (SGA) Parallel and Distributed Genetic Algorithm (PGA and DGA)
a) b) c) d)

Master-Slave Parallelization Fine Grained Parallel GAs (Cellular GAs) Multiple-Deme Parallel GAs (Distributed GAs or Coarse Grained GAs) Hierarchical Parallel Algorithms

3) 4) 5)

Adaptive Genetic Algorithm (AGA) Fast Messy Genetic Algorithm (FmGA) Independent Sampling Genetic Algorithm (ISGA)

70

1) Simple Genetic Algorithm (SGA)
y A simple genetic algorithm composed of three operations y Reproduction y Crossover y Mutation y SGAs are useful and efficient when, y The search space is large, complex or poorly understood. y Domain knowledge is scarce or expert knowledge is difficult to encode to narrow the search space. y No mathematical analysis is available. y Traditional search methods fail.

71

2)Parallel and Distributed Genetic Algorithm (PGA and DGA)
y Parallel execution of various SGAs is called PGA. y Each of the Processing Elements starts with a different initial

subpopulation, evolves and stops independently. y There are no inter-PE communications. y Methods of PGA are
y Independent PGA y Migration PGA y Partition PGA

72

2)Parallel and Distributed Genetic Algorithm (PGA and DGA)
Master-Slave Parallelization:-

continue«

The master stores the population and does the selection The slaves evaluate the fitness and apply the genetic operators like crossover and mutation. y Communication occurs only when slaves return values to master. y Modes o Synchronous - master waits until it receives the fitness value for entire population. o Asynchronous - master doesn·t stop for any slow processors.
y y

73

2)Parallel and Distributed Genetic Algorithm (PGA and DGA)

continue«

Coarse & Fine grained PGA·s :y population is divided into a number of subpopulations called demes. y Demes are separated from one another and individuals compete only

within a deme.
y Coarse grained - small number of demes with many individuals y Fine Grained

- large number of demes with small number of individuals

y migration is used to move the individuals from one deme to another

(island model).

74

2)Parallel and Distributed Genetic Algorithm (PGA and DGA)

continue«

Hierarchical Parallel Algorithms : y Combination of Master-Slave with fine and coarse grained PGA

75

3)Adaptive Genetic Algorithm (AGA)
GAs whose parameters, such as the population size, the crossing over probability, or the mutation probability are varied while the GA is running .
y The mutation rate is changed according to changes in the

population; the longer the population does not improve, the higher the mutation rate is chosen.
y It is decreased again as soon as an improvement of the population

occurs.

76

Advantages of GA
y Parallelism y Solution space is wider. y Easy to discover global optimum y Only uses function evaluations. y Handles noisy functions well. y Handles large, poorly understood search spaces easily y They require no knowledge or gradient information about the

response surface y Discontinuities present on the response surface have little effect on overall optimization performance y They are resistant to becoming trapped in local optima
77

Limitations
y The problem of identifying fitness function y The problem of choosing the various parameters like the size of the

y y y y y y

population, mutation rate, cross over rate, the selection method and its strength. Cannot easily incorporate problem specific information Not good at identifying local optima No effective terminator. Not effective for smooth unimodal functions Needs to be coupled with a local search technique. Require large number of response (fitness) function evaluations

78

Applications
y y y y y y y y

Time series forecasting. Robot trajectory planning Image Processing Design²semiconductor layout, aircraft design, keyboard configuration, communication networks Scheduling²manufacturing, facility scheduling, resource allocation Machine Learning²Designing neural networks, both architecture and weights, improving classification algorithms, classifier systems Signal Processing²filter design Combinatorial Optimization²set covering, traveling salesman (TSP), Sequence scheduling, routing, bin packing, graph coloring and partitioning

79

Conclusion

80

References
y Genetic Algorithm In Search, Optimization & Machine Learning

- D. E. Goldberg
y Handbook of Genetic Algorithm

- Lawrence Davis
y Introduction To Genetic Algorithms

- S.N.Sivanandam, S.N.Deepa

y www.geneticalgorithms.ai-depot.com/Tutorial/Overview.html y www.obitko.com/tutorials/genetic-algorithms/ y www.geneticprogramming.com y en.wikipedia.org/wiki/Genetic_algorithm

81

Sign up to vote on this title
UsefulNot useful