January 17 th , 2011
Metaheuristics Classification
Basic Concepts
Genetic Algorithm Flow
Genetic Algorithm Selection
Genetic Algorithm Operators
Crossover Example
Mutation Example
Motivation
Self-Adaptive Genetic Algorithm Flow
Heuristic
Crossover
Mutation
Evaluation
Experimental Results
Conclusion
Populational Metaheuristics: Genetic Algorithm
2
Populational Metaheuristics: Genetic Algorithm
Populational
Evolutionary Computation
Genetic
Algorithms
Evolution
Strategies
Particle Swarm
Optimization
Ant Colony
Optimization
Simulated
Annealing
Non Populational
Tabu Search
GRASP
Variable
Neighborhood Search
3
Populational Metaheuristics: Genetic Algorithm
Natural Selection: “a natural process that results in the survival and reproductive success of individuals or groups best adjusted to their environment and that leads to the perpetuation of genetic qualities best suited to that particular environment.” [1]
References:
[1]-Meriam –Webster Online Enciclopédia. Availabe at: http://www.merriam-webster.com/dictionary/natural+selection
[2]-Source: http://www.genetic-programming.com/coursemainpage.html
4
Populational Metaheuristics: Genetic Algorithm
Optimization Concept Nature
Phenotype
Elements of the observable structure of a living organism.
Set of the decision variables (x)
Genotype
Blueprint for building and maintaining a living creature.
Encoded representation of the variables (s)
Phenotype min f ( x )
Genotype min g ( s ) g ( s )
f ( c ( s ))
5
Populational Metaheuristics: Genetic Algorithm
Chromosome:
Coded version of the state variables.
May represent infeasible solutions of the problem.
Gene: elementary elements of the chromosome – movable parts.
Alleles: values that the genes can take – differentiates genes.
Population
Gene
Alleles
N=1
N=2
1
1
0
0
1
1
1
1
0
0
1
1
0
0
N 1 0 1 1 0 1 0
References:
[1]-Handbook of Metaheuristics
[2]-Source: http://lams.slcusd.org/pages/teachers/saxby/wordpress/?attachment_id=521
6
Initializes
Population
Fitness
Assignment
Selection
Crossover
Mutation
Survival
Selection
Output
Populational Metaheuristics: Genetic Algorithm
1.
Coding and Initialization:
Encoding variables and generating chromosomes.
2.
Fitness Assignment:
Assess the fitness of the population according to a fitness function.
3.
Selection:
Selects the chromosomes more fitted to breed.
4.
Crossover:
Combines information from two parents.
5.
Mutation:
Introduces individual characteristics in the chromosomes.
6.
Survival Selection:
Assess the fitness of the offspring and selects N
elements to be included in the solutions Population.
7.
Output:
GA needs a stopping criteria. (computational time, number of evaluations…)
7
Initializes
Population
Fitness
Assignment
Selection
Crossover
Mutation
Survival
Selection
Populational Metaheuristics: Genetic Algorithm
1.
Coding and Initialization: a) Coding: i.
Choose the most adequate data type to obtain meaningful solutions .
ii.
Data types examples:
Bit strings (0011; 1101;….;0001)
Real numbers (12.5; 45.2;…;-33)
Discrete Elements (D1; D12;…;D23) b) Initialization: i.
Generation of chromosomes:
Can represent a feasible solution (not mandatory)
Helps in the convergence of the algorithm
2.
Fitness Assignment:
The fitness-function is problem dependent.
Output
8
Initializes
Population
Fitness
Assignment
Selection
Crossover
Mutation
Survival
Selection
Output
Populational Metaheuristics: Genetic Algorithm
Parents are chosen randomly amongst the most fitted.
Examples of selection methods:
Fitness-proportional selection.
Tournament selection.
Expected number of offspring generated by a parent i:
E( n i
) =
• f(i)/
f
Population size
Fitness
Value of i
Average fitness of the population
9
Initializes
Population
Fitness
Assignment
Selection
Crossover
Mutation
Survival
Selection
Output
Populational Metaheuristics: Genetic Algorithm
In the reproduction phase we have two operators.
Crossover (intensification agent):
Explores an area somewhere “in between” two parent areas in the solution space.
It combines information from two parents.
Tries to maintain the good characteristics of both parents.
Mutation (diversification agent ):
Introduces new or lost alleles.
Avoids falling into a local optimum.
10
Populational Metaheuristics: Genetic Algorithm
The user must specify also control parameters:
Population size:
May limit the genetic diversity, if it is too small.
Trade-off between efficiency and effectiveness.
Crossover/mutation probability:
How often the population crossover/mutation will be performed.
Both operators can have a probability smaller than one.
Choosing implementations methods:
Selection and deletion methods.
Crossover/mutations operators.
Termination criteria:
Number of evaluations, running time, fitness function value
11
Populational Metaheuristics: Genetic Algorithm
Procedure:
Pick t members randomly and select the best.
Repeat to select more individuals.
Selection pressure:
Increases with the size of the tournament.
Increases if the chromosomes are selected with replacement.
Pros:
Doesn’t need all the population available:
Allows distributed computing.
Cons:
Good solution might never enter in the tournament.
12
Populational Metaheuristics: Genetic Algorithm
P1
In nature:
P1 P1 P1
P2 P2
P2
P2
Two parents produce two offspring.
One-point crossover:
Given the parents P1 and P2, with crossover in position 3 the offspring will be the pair O1 and O2:
P1: 1 0 1 0 0 1 0 O1: 1 0 1 1 0 0 1
P2: 0 1 1 1 0 0 1 O2: 0 1 1 0 0 1 0
13
Populational Metaheuristics: Genetic Algorithm
P1 1 2 3 4 5 6 7 8 9 P1 1 2 3 4 5 6 7 8 9
P2 9 3 7 8 2 6 5 1 4
O2 4 5 6 7
P2 9 3 7 8 2 6 5 1 4
O2 4 5 6 7 8
P1 1 2 3 4 5 6 7 8 9
P2 9 3 7 8 2 6 5 1 4
O2 2 4 5 6 7 8
P1 1 2 3 4 5 6 7 8 9
P2 9 3 7 8 2 6 5 1 4
O2 9 3 2 4 5 6 7 1 8
14
Populational Metaheuristics: Genetic Algorithm
Adds new information to the chromosome.
A gene (or subset of genes) is chosen randomly and the ‘allele’ value of the chosen genes is changed:
By a swap with other gene.
Or by a new value, not present in parent.
Mutation with the genes 3 and 5:
P1: 1 0 1 1 0 0 1 mutation
O1: 1 0 0 1 1 0 1
15
Metaheuristics Classification
Basic Concepts
Genetic Algorithm Flow
Genetic Algorithm Selection
Genetic Algorithm Operators
Crossover Example
Mutation Example
Motivation
Self-Adaptive Genetic Algorithm Flow
Heuristic
Crossover
Mutation
Evaluation
Experimental Results
Conclusion
Populational Metaheuristics: Genetic Algorithm
16
Populational Metaheuristics: Genetic Algorithm
Applying Self-Adaptive Evolutionary Algorithms to Two-Dimensional Packing
Problems using a Four Corners’ Heuristic
Kevin J. Binkley, and Masafumi Hagiwara
European Journal of Operational Research
Volume 183, Pages 1230-1248, 16 June 2006.
17
Populational Metaheuristics: Genetic Algorithm
Study 2D-packing problems:
Objective: Use only one bin and minimize its trim loss.
Rotations are permited.
Compare Evolutionary Algorithms (EA):
Self-Adaptive Genetic Algorithm.
Self-Adaptive Parallel Recombinative Simulated Annealing (PRSA).
Use a Four Corners’ (FC) heuristic.
Example (Phenotype) of a Bottom-Left (BL) packing approach.
Numbers are the rectangles (genes) indexes (alleles).
Empty space represents the trim loss.
18
Initializes
Population
Evaluates
Population
Pre-Selection
Crossover
Mutation
Post-Selection
(Next Generation)
Output
Populational Metaheuristics: Genetic Algorithm
1.
Heuristic:
Four Corners’.
2.
Evaluation:
Fitness function.
3.
Pre-Selection:
Tournament selection with replacement.
4.
Crossover – 4 types:
PMX.
Cycle Crossover.
Partially Mapped Crossover Random Locations (PMXR).
Preserve Location Crossover (PLX).
5.
Mutation – 3 types:
Swap Mutation.
Rotation Mutation
Swap Corners’ Mutation.
6.
Post-Selection (with evaluation):
Non-elitist. All childern survive to the next generation.
19
Genome
4 8 2 9 0 5
Populational Metaheuristics: Genetic Algorithm
3 7 1 6
A B
A1 A2
Genome after FC heuristic division
4 8
Bottom-Left →
2 9
← Top-Right
0
B1
5 3
Bottom-Rigth →
7
B2
1
← Top-Left
6
Phenotype of the genome following FC heuristic packing indications
Trim space concentrates more in the center.
20
Populational Metaheuristics: Genetic Algorithm
PMX | Cyclic Crossover | PMRX | PLX
Each genome has a integer tag → [0, 3].
The tag mutates during mutation phase:
According to a crossover mutation rate.
Crossover operator evolves with the population.
if (parent0.crossover_type = parent1.crossover_type) do parent0.crossover_type
else if (rand(0,1) < 0.5) do parent0.crossover_type
else do parent1.crossover_type
endif
PMRX
P1 0 1 2 3 4 5 6 7 8 9
P2 1 4 2 7 3 8 5 6 9 0
X X X X
C1 4 1 2 3 7 5 9 6 8 0
C2 0 4 2 3 1 8 6 7 9 5 random
PLX Step 1 Step 2 Step 3
C1 0 1 2 3 7 8 5 6 9 4
C2 4 1 2 7 3 8 5 6 9 0
21
Populational Metaheuristics: Genetic Algorithm
Each of the children inherits the tag integer equivalent to the crossover operator used for their creation.
PMRX distinguishes from PMX because it creates mappings throughout the
genome.
PLX introduces a degree of randomness, but like the other crossover operators, the common parents are preserved in the same location.
22
Populational Metaheuristics: Genetic Algorithm
Swap Mutation | Rotation Mutation | Swap Corners’ Mutation
Swap Mutation:
Swaps two alleles and each of the existing has a chance of being mutated.
Rotation Mutation:
Rotates a allele and each of the existing has a chance of being mutated.
Swap Corners’ Mutation:
Swap corners’ between: BL↔BR, BR↔TL, BL↔TR, TL↔TR.
Each mutation operator has its own mutation rate:
Like the crossover operator, the mutation operators evolve with the GA.
Swap Mutation pseudo-code.
for pos = 0 to num_alleles – 1 if (rand(0,1) < swap_mutation_rate) swap_pos = (rand_int(0,num_alleles-1) + pos + 1 % num_alleles swap(pos, swap_pos) endif endfor
23
Populational Metaheuristics: Genetic Algorithm
Swap Mutation:
As the EA converge to an optimum, this mutation introduces new or lost gene building blocks.
Rotation Mutation:
This mutation is similar to the swap mutation, but expands its search space.
Swap Corners’ Mutation:
Comparing to the other two mutations, this introduces new individuals that are
more distant in the search space – new building blocks.
We can see that mutation is important in later stages of the EA to avoid sub-
optimal solutions.
24
Populational Metaheuristics: Genetic Algorithm
Fitness function implemented values more empty central space:
Trim loss remains are the primary evaluating parameter:
In a large population several genomes will have the same trim loss.
Central trim loss is more valued as differentiator parameter:
Fourth moment statistic implementation.
𝑍 𝑝𝑒𝑟𝑖𝑚𝑒𝑡𝑒𝑟
𝑍 𝑡𝑟𝑖𝑚 𝑙𝑜𝑠𝑠;
𝑍 𝑝𝑒𝑟𝑖𝑚𝑒𝑡𝑒𝑟
= 𝑍 𝑜𝑝𝑒𝑛
− 𝑍 𝑓𝑖𝑙𝑙𝑒𝑑
The left implementation is preferable because the empty space is more central.
The FC heuristic pack the genes moving the empty space to the center.
Favoring center empty space phenotypes is then better.
25
Populational Metaheuristics: Genetic Algorithm
Packing software developed in C++ / Windows XP.
31 problems published in the literature were used.
10 runs done for each problem and the average result is presented.
Fixed parameters (self-adaptive GA):
Population size = 400.
Tournament size = 4.
Number of fitness function evaluations = 1.000.000.
Caching of the fitness evaluations was done to speed up the computation.
When a perfect packing is reached the run is stopped.
Problems run with and without rotations allowed.
26
The average trim loss result is generally much less than 1% for both algorithms.
PRSA produced better results than
GA.
GA did better on 2 out of 3 of the
most difficult problems, both with and without rotations.
Populational Metaheuristics: Genetic Algorithm
27
In problems up to 97 rectangles perfect packing's were achieved when rotations were allowed.
Without rotations, perfect packing's were found only on
problems up to 30 rectangles.
Allowing for rotations increases the search space and clearly makes easy to achieve a perfect
packing.
Populational Metaheuristics: Genetic Algorithm
28
The GA quickly reached a trim loss of 0,0040 after 250.000
evaluations, before stagnation.
PRSA does not converge quickly, but gradually moves to an improved final trims loss of 0,0014.
With PRSA increase computational resources is straightforward.
GA is more complex and needs
much more tuning: population size, tournament size, detecting convergence and restarting the GA.
GA beats PRSA on larger problems or when the number of fitness functions evaluations is limited to
100.000.
Populational Metaheuristics: Genetic Algorithm
29
Big rectangles are packed first to the corners and sides.
The trim loss tends to accumulates
in the center.
The packing structure is intuitive.
Larger rectangles are placed first in the corners, the smaller ones are
moved around to find a better solution.
Populational Metaheuristics: Genetic Algorithm
30
Limited to 100.000 fitness function evaluations GA performed much better than PRSA.
After a typical run with self-adapting parameters, mutation rates decreased from their initial values.
Fixed settings performed better on smaller problems and fully adaptive much better on larger ones
GA results are quite sensitive to fixed
mutation rates, however finding the right parameters is time consuming.
Self adapting GA can perform well on a
wider range of problems and there are
fewer parameters to set.
Populational Metaheuristics: Genetic Algorithm
31
The results achieved are the best
found in literature until 2004.
In larger problems, resulting trim
losses of much less than 1% were achieved.
PRSA generally produces higher quality packing's when computational resources are
available.
GA produces better results when computational resources are
limited.
Self-adaptive GA outperform fixed parameter GAs on larger
problems.
Populational Metaheuristics: Genetic Algorithm
32