Download Genetic Algorithms (GA)

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Tag SNP wikipedia , lookup

Quantitative trait locus wikipedia , lookup

Pharmacogenomics wikipedia , lookup

Genome evolution wikipedia , lookup

Medical genetics wikipedia , lookup

Designer baby wikipedia , lookup

Genetic code wikipedia , lookup

Polymorphism (biology) wikipedia , lookup

Behavioural genetics wikipedia , lookup

Heritability of IQ wikipedia , lookup

Koinophilia wikipedia , lookup

Mutation wikipedia , lookup

Epistasis wikipedia , lookup

History of genetic engineering wikipedia , lookup

Genetic engineering wikipedia , lookup

Public health genomics wikipedia , lookup

Frameshift mutation wikipedia , lookup

Point mutation wikipedia , lookup

Human genetic variation wikipedia , lookup

Genetic testing wikipedia , lookup

Genetic drift wikipedia , lookup

Genetic engineering in science fiction wikipedia , lookup

Genome (book) wikipedia , lookup

Gene expression programming wikipedia , lookup

Population genetics wikipedia , lookup

Microevolution wikipedia , lookup

Transcript
Populational Metaheuristics
Genetic Algorithm
FEUP | PDEEC | Decision Support
Group 1:
Clara Gouveia
Daniel Oliveira [Presenter]
Fabrício Sperandio
Filipe Sousa
January 17th, 2011
Populational Metaheuristics: Genetic Algorithm
FEUP | PDEEC | Decision Support
Outline





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
2
Populational Metaheuristics: Genetic Algorithm
Metaheuristics Classification
Populational
Evolutionary Computation
FEUP | PDEEC | Decision Support
Nature Inspired
Genetic
Algorithms
Evolution
Strategies
Particle Swarm
Optimization
Ant Colony
Optimization
Non Populational
Simulated
Annealing
Tabu Search
GRASP
Variable
Neighborhood Search
3
Populational Metaheuristics: Genetic Algorithm
FEUP | PDEEC | Decision Support
Nature Inspiration
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
Basic Concepts
Nature vs Optimization
FEUP | PDEEC | Decision Support
Concept
Nature
Optimization
Phenotype
Elements of the observable Set of the
structure of a living organism. variables (x)
Genotype
Blueprint for building and Encoded representation
maintaining a living creature.
of the variables (s)
Phenotype
min f ( x )
decision
Genotype
min g ( s )
g ( s )  f (c( s ))
5
Populational Metaheuristics: Genetic Algorithm
Basic Concepts
Genotype – Phenotype Mapping
 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.
Gene
Alleles
0
1
1
0
1
0
N=2
1
0
1
1
0
1
0
N
1
0
1
0
1
1
References:
[1]-Handbook of Metaheuristics
[2]-Source: http://lams.slcusd.org/pages/teachers/saxby/wordpress/?attachment_id=521
…
1
…
N=1
…
FEUP | PDEEC | Decision Support
Population
0
6
Populational Metaheuristics: Genetic Algorithm
Initializes
Population
Genetic Algorithm Flow
1. Coding and Initialization:
 Encoding variables and generating chromosomes.
Fitness
Assignment
FEUP | PDEEC | Decision Support
Reproduction
Selection
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:
Crossover
 Combines information from two parents.
5. Mutation:
Mutation
 Introduces
individual
chromosomes.
characteristics
in
the
6. Survival Selection:
Survival
Selection
 Assess the fitness of the offspring and selects N
elements to be included in the solutions Population.
7. Output:
Output
 GA needs a stopping criteria. (computational time,
number of evaluations…)
7
Populational Metaheuristics: Genetic Algorithm
Genetic Algorithm Flow
Initializes
Population
Fitness
Assignment
Selection
Crossover
FEUP | PDEEC | Decision Support
Mutation
Survival
Selection
Coding and Initialization
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
Populational Metaheuristics: Genetic Algorithm
Genetic Algorithm Flow
Initializes
Population
Fitness
Assignment
Selection
Crossover
FEUP | PDEEC | Decision Support
Mutation
Survival
Selection
Parent Selection
 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( ni ) =  • f(i)/ f
Population
size
Fitness
Value of i
Average fitness
of the
population
Output
9
Populational Metaheuristics: Genetic Algorithm
Initializes
Population
Fitness
Assignment
Genetic Algorithm Flow
Crossover and Mutation
 In the reproduction phase we have two operators.
 Crossover (intensification agent):
Selection
Crossover
FEUP | PDEEC | Decision Support
Mutation
Survival
Selection
 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.
Output
10
Populational Metaheuristics: Genetic Algorithm
Genetic Algorithm Operators
Control Parameters
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.
FEUP | PDEEC | Decision Support
 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
Genetic Algorithm Selection
Tournament Selection
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.
FEUP | PDEEC | Decision Support
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
Genetic Algorithm Operators
Crossover: One-Point Crossover
In nature:
P1
P1
P1
P1
Crossover: Two parents produce two offspring.
P2
P2
P2
P2
One-point crossover:
FEUP | PDEEC | Decision Support
 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
Genetic Algorithm Operators
Crossover: Partially Mapped Crossover (PMX)
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
P2
9 3 7 8 2 6 5 1 4
FEUP | PDEEC | Decision Support
O2
4 5 6 7
O2
4 5 6 7
8
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
P2
9 3 7 8 2 6 5 1 4
O2
2 4 5 6 7
O2
9 3 2 4 5 6 7 1 8
8
14
Populational Metaheuristics: Genetic Algorithm
Genetic Algorithm Operators
Mutation: Swap Mutation
Mutation: 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.
FEUP | PDEEC | Decision Support
Mutation with the genes 3 and 5:
P1: 1 0 1 1 0 0 1
O1: 1 0 0 1 1 0 1
mutation
15
Populational Metaheuristics: Genetic Algorithm
FEUP | PDEEC | Decision Support
Outline





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
16
Populational Metaheuristics: Genetic Algorithm
Part Two: Paper Presentation
Applying Self-Adaptive Evolutionary Algorithms to Two-Dimensional Packing
Problems using a Four Corners’ Heuristic
Kevin J. Binkley, and Masafumi Hagiwara
FEUP | PDEEC | Decision Support
European Journal of Operational Research
Volume 183, Pages 1230-1248, 16 June 2006.
17
Populational Metaheuristics: Genetic Algorithm
Motivation
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).
FEUP | PDEEC | Decision Support
 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
Populational Metaheuristics: Genetic Algorithm
Self-Adaptive Genetic Algorithm Flow
Initializes
Population
1. Heuristic:
 Four Corners’.
2. Evaluation:
 Fitness function.
Evaluates
Population
3. Pre-Selection:
 Tournament selection with replacement.
FEUP | PDEEC | Decision Support
Crossover
Mutation
Post-Selection
(Next Generation)
Output
While Stop Criteria Not Satisfied
Pre-Selection
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
Populational Metaheuristics: Genetic Algorithm
Heuristic
Four Corners’ Heuristic
Genome
4
8
2
9
0
5
3
A
7
1
6
B
A1
A2
B1
B2
Genome after FC heuristic division
4
8
FEUP | PDEEC | Decision Support
Bottom-Left →
2
9
0
← Top-Right
5
3
Bottom-Rigth →
7
1
6
← Top-Left
Phenotype of the genome following FC heuristic packing
indications
Trim space concentrates more in the center.
20
Populational Metaheuristics: Genetic Algorithm
Crossover
PMX | Cyclic Crossover | PMRX | PLX
Operators
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
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.
PMRX
P1
0
1
2
3
4
5
6
7
8
9
P2
1
4
2
7
3
8
5
6
9
0
FEUP | PDEEC | Decision Support
X
X
X
X
random
C1
4
1
2
3
7
5
9
6
8
0
C2
0
4
2
3
1
8
6
7
9
5
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
Crossover
Operators
 Each of the children inherits the tag integer equivalent to the crossover
operator used for their creation.
FEUP | PDEEC | Decision Support
 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
Mutation
Operators
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:
FEUP | PDEEC | Decision Support
 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
Mutation
Operators
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:
FEUP | PDEEC | Decision Support
 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 suboptimal solutions.
24
Populational Metaheuristics: Genetic Algorithm
Evaluation
Fitness Function
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.
𝑡𝑟𝑖𝑚 𝑙𝑜𝑠𝑠;
FEUP | PDEEC | Decision Support
𝑍𝑝𝑒𝑟𝑖𝑚𝑒𝑡𝑒𝑟
𝑍
𝑍𝑝𝑒𝑟𝑖𝑚𝑒𝑡𝑒𝑟
= 𝑍𝑜𝑝𝑒𝑛 − 𝑍𝑓𝑖𝑙𝑙𝑒𝑑
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
Experimental Results
Settings
 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.
FEUP | PDEEC | Decision Support
 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
Populational Metaheuristics: Genetic Algorithm
Experimental Results
 The average trim loss result is
generally much less than 1% for
both algorithms.
FEUP | PDEEC | Decision Support
 PRSA produced better results than
GA.
 GA did better on 2 out of 3 of the
most difficult problems, both with
and without rotations.
27
Populational Metaheuristics: Genetic Algorithm
Experimental Results
 In problems up to 97 rectangles
perfect packing's were achieved
when rotations were allowed.
FEUP | PDEEC | Decision Support
 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.
28
Populational Metaheuristics: Genetic Algorithm
Experimental results
 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.
FEUP | PDEEC | Decision Support
 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.
29
Populational Metaheuristics: Genetic Algorithm
Experimental results
Four Corners’ Packing
 Big rectangles are packed first to
the corners and sides.
 The trim loss tends to accumulates
in the center.
FEUP | PDEEC | Decision Support
 The packing structure is intuitive.
 Larger rectangles are placed first in
the corners, the smaller ones are
moved around to find a better
solution.
30
Populational Metaheuristics: Genetic Algorithm
Experimental results
 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.
FEUP | PDEEC | Decision Support
 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.
31
Populational Metaheuristics: Genetic Algorithm
Conclusions
 The results achieved are the best
found in literature until 2004.
 In larger problems, resulting trim
losses of much less than 1% were
achieved.
FEUP | PDEEC | Decision Support
 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.
32
Populational Metaheuristics
Genetic Algorithm
FEUP | PDEEC | Decision Support
Thank you for your attention!!!
Questions?