Optimization Techniques
Genetic
Algorithms
And other approaches for similar
applications
Optimization Techniques
• Mathematical Programming
• Network Analysis
• Branch & Bound
• Genetic Algorithm
• Simulated Annealing
• Tabu Search
Genetic Algorithm
• Based on Darwinian Paradigm
Reproduction Competition
Survive Selection
• Intrinsically a robust search and optimization mechanism
Conceptual Algorithm
Genetic Algorithm
Introduction 1
• Inspired by natural evolution
• Population of individuals
• Individual is feasible solution to problem
• Each individual is characterized by a Fitness function
• Higher fitness is better solution
• Based on their fitness, parents are selected to reproduce
offspring for a new generation
• Fitter individuals have more chance to reproduce
• New generation has same size as old generation; old generation
dies
• Offspring has combination of properties of two parents
• If well designed, population will converge to optimal
solution
Algorithm
BEGIN
Generate initial population;
Compute fitness of each individual;
REPEAT /* New generation /*
FOR population_size / 2 DO
Select two parents from old generation;
/* biased to the fitter ones */
Recombine parents for two offspring;
Compute fitness of offspring;
Insert offspring in new generation
END FOR
UNTIL population has converged
END
Example of convergence
Introduction 2
• Reproduction mechanisms have no
knowledge of the problem to be solved
• Link between genetic algorithm and
problem:
• Coding
• Fitness function
Basic principles 1
• Coding or Representation
• String with all parameters
• Fitness function
• Parent selection
• Reproduction
• Crossover
• Mutation
• Convergence
• When to stop
Basic principles 2
• An individual is characterized by a set of parameters:
Genes
• The genes are joined into a string: Chromosome
• The chromosome forms the genotype
• The genotype contains all information to construct
an organism: the phenotype
• Reproduction is a “dumb” process on the
chromosome of the genotype
• Fitness is measured in the real world (‘struggle for
life’) of the phenotype
Coding
• Parameters of the solution (genes) are concatenated
to form a string (chromosome)
• All kind of alphabets can be used for a chromosome
(numbers, characters), but generally a binary
alphabet is used
• Order of genes on chromosome can be important
• Generally many different codings for the parameters
of a solution are possible
• Good coding is probably the most important factor
for the performance of a GA
• In many cases many possible chromosomes do not
code for feasible solutions
Genetic Algorithm
• Encoding
• Fitness Evaluation
• Reproduction
• Survivor Selection
Encoding
• Design alternative individual
(chromosome)
• Single design choice gene
• Design objectives fitness
Example
• Problem
• Schedule n jobs on m processors such that
the maximum span is minimized.
Design alternative: job i ( i=1,2,…n) is assigned to processor j (j=1,2,…,m)
Individual: A n-vector x such that xi = 1, …,or m
Design objective: minimize the maximal span
Fitness: the maximal span for each processor
Reproduction
• Reproduction operators
• Crossover
• Mutation
Reproduction
• Crossover
• Two parents produce two offspring
• There is a chance that the chromosomes of the two parents
are copied unmodified as offspring
• There is a chance that the chromosomes of the two parents
are randomly recombined (crossover) to form offspring
• Generally the chance of crossover is between 0.6 and 1.0
• Mutation
• There is a chance that a gene of a child is changed randomly
• Generally the chance of mutation is low (e.g. 0.001)
Reproduction Operators
• Crossover
• Generating offspring from two selected
parents
Single point crossover
Two point crossover (Multi point crossover)
Uniform crossover
One-point crossover 1
• Randomly one position in the chromosomes is
chosen
• Child 1 is head of chromosome of parent 1 with tail
of chromosome of parent 2
• Child 2 is Randomly
head of 2 with
chosen tail of 1
position
Parents: 1010001110 0011010010
Offspring: 0101010010 0011001110
Reproduction Operators comparison
• Single point crossover
Cross point
• Two point crossover (Multi point crossover)
One-point crossover - Nature
1 2 1 2
2 1 2 1
Two-point crossover
• Randomly two positions in the chromosomes are
chosen
• Avoids that genes at the head and genes at the tail
of a chromosome are always split when recombined
Randomly chosen positions
Parents: 1010001110 0011010010
Offspring: 0101010010 0011001110
Uniform crossover
• A random mask is generated
• The mask determines which bits are copied from one
parent and which from the other parent
• Bit density in mask determines how much material is
taken from the other parent (takeover parameter)
Mask: 0110011000 (Randomly generated)
Parents: 1010001110 0011010010
Offspring: 0011001010 1010010110
Reproduction Operators
• Uniform crossover
• Is uniform crossover better than single crossover
point?
– Trade off between
• Exploration: introduction of new combination of features
• Exploitation: keep the good features in the existing solution
Problems with crossover
• Depending on coding, simple crossovers can have
high chance to produce illegal offspring
• E.g. in TSP with simple binary or path coding, most offspring
will be illegal because not all cities will be in the offspring
and some cities will be there more than once
• Uniform crossover can often be modified to avoid
this problem
• E.g. in TSP with simple path coding:
Where mask is 1, copy cities from one parent
Where mask is 0, choose the remaining cities in the order of the
other parent
Reproduction Operators
• Mutation
• Generating new offspring from single parent
• Maintaining the diversity of the individuals
Crossover can only explore the combinations of the
current gene pool
Mutation can “generate” new genes
Reproduction Operators
• Control parameters: population size,
crossover/mutation probability
• Problem specific
• Increase population size
Increase diversity and computation time for each
generation
• Increase crossover probability
Increase the opportunity for recombination but also
disruption of good combination
• Increase mutation probability
Closer to randomly search
Help to introduce new gene or reintroduce the lost gene
• Varies the population
• Usually using crossover operators to recombine the genes to
generate the new population, then using mutation operators
on the new population
Parent/Survivor
Selection
• Strategies
• Survivor selection
Always keep the best one
Elitist: deletion of the K worst
Probability selection : inverse to their
fitness
Etc.
Parent/Survivor Selection
• Too strong fitness selection bias can lead to
sub-optimal solution
• Too little fitness bias selection results in
unfocused and meandering search
Parent selection
Chance to be selected as parent proportional to
fitness
• Roulette wheel
To avoid problems with fitness function
• Tournament
Not a very important parameter
Parent/Survivor
Selection
• Strategies
• Parent selection
Uniform randomly selection
Probability selection : proportional to their fitness
Tournament selection (Multiple Objectives)
Build a small comparison set
Randomly select a pair with the higher rank one beats the lower
one
Non-dominated one beat the dominated one
Niche count: the number of points in the population
within
certain distance, higher the niche count,
lower the
rank.
Etc.
How GA are Different than
Traditional Search Methods
• GAs work with a coding of the parameter set, not the
parameters themselves.
• GAs search from a population of points, not a single
point.
• GAs use payoff information, not derivatives or
auxiliary knowldege.
• GAs use probablistic transition rules, not
deterministic rules.
Vocabulary
• Gene – An single encoding of part of the solution
space.
• Chromosome – A string of “Genes” that represents a
solution.
• Population - The number of “Chromosomes”
available to test.
Simple Example
• f(x) = {MAX(x2): 0 <= x <= 32 }
• Encode Solution: Just use 5 bits (1 or 0).
• Generate initial population.
A 0 1 1 0 1
B 1 1 0 0 0
C 0 1 0 0 0
D 1 0 0 1 1
• Evaluate each solution against objective.
Sol. String Fitness % of Total
A 01101 169 14.4
B 11000 576 49.2
C 01000 64 5.5
D 10011 361 30.9
Simple Example (cont.)
• Create next generation of solutions
• Probability of “being a parent” depends on the
fitness.
• Ways for parents to create next generation
• Reproduction
Use a string again unmodified.
• Crossover
Cut and paste portions of one string to another.
• Mutation
Randomly flip a bit.
• COMBINATION of all of the above.
The Basic Genetic Algorithm
1. [Start] Generate random population of n chromosomes
(suitable solutions for the problem)
2. [Fitness] Evaluate the fitness f(x) of each chromosome x in the
population
3. [New population] Create a new population by repeating
following steps until the new population is complete
1. [Selection] Select two parent chromosomes from a
population according to their fitness (the better fitness, the
bigger chance to be selected)
2. [Crossover] With a crossover probability cross over the
parents to form new offspring (children). If no crossover was
performed, offspring is the exact copy of parents.
3. [Mutation] With a mutation probability mutate new
offspring at each locus (position in chromosome).
4. [Accepting] Place new offspring in the new population
4. [Replace] Use new generated population for a further run of
the algorithm
5. [Test] If the end condition is satisfied, stop, and return the best
solution in current population
6. [Loop] Go to step 2