FEUP | PDEEC | Decision Support

33
FEUP | PDEEC | Decision Support January 17 th , 2011 Populational Metaheuristics Genetic Algorithm Group 1: Clara Gouveia Daniel Oliveira [Presenter] Fabrício Sperandio Filipe Sousa

description

Populational Metaheuristics Genetic Algorithm. Group 1: Clara Gouveia Daniel Oliveira [Presenter ] Fabrício Sperandio Filipe Sousa. FEUP | PDEEC | Decision Support. January 17 th , 2011. Populational Metaheuristics: Genetic Algorithm. Outline. - PowerPoint PPT Presentation

Transcript of FEUP | PDEEC | Decision Support

Page 1: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

January 17th, 2011

Populational MetaheuristicsGenetic Algorithm

Group 1:Clara GouveiaDaniel Oliveira [Presenter]Fabrício SperandioFilipe Sousa

Page 2: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

2

Part One: Introduction to Genetic Algorithm

Part Two: Paper Presentation Motivation Self-Adaptive Genetic Algorithm Flow Heuristic Crossover Mutation Evaluation Experimental Results Conclusion

Outline

Metaheuristics Classification Basic Concepts Genetic Algorithm Flow Genetic Algorithm Selection Genetic Algorithm Operators

Crossover Example Mutation Example

Page 3: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

3

Particle Swarm Optimization

GRASP

Ant Colony Optimization

Tabu Search

Simulated Annealing

Variable Neighborhood Search

Genetic Algorithms

Evolution Strategies

Evolutionary Computation

Populational

Non PopulationalNat

ure

Insp

ired

Metaheuristics Classification

Page 4: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

4

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

Page 5: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

5

Basic Concepts

Concept Nature Optimization

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)

)(min xf))(()(

)(minscfsg

sg

Phenotype Genotype

Nature vs Optimization

Page 6: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

6

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.

References: [1]-Handbook of Metaheuristics[2]-Source: http://lams.slcusd.org/pages/teachers/saxby/wordpress/?attachment_id=521

1 0 1 1 0 1 0

Gene Alleles

1 0 1 1 0 1 0

1 0 1 1 0 1 0

N=1

N=2

N

… … …

Population

Basic ConceptsGenotype – Phenotype Mapping

Page 7: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

7

Genetic Algorithm Flow1. 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…)

Initializes Population

Fitness Assignment

Selection

Crossover

Mutation

Output

Repr

oduc

tion

Survival Selection

Page 8: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

8

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.

Initializes Population

Fitness Assignment

Selection

Crossover

Mutation

Output

Survival Selection

Genetic Algorithm FlowCoding and Initialization

Page 9: FEUP | PDEEC | Decision Support

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

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

Population size

Fitness Value of i

Average fitness of the

population

Selection

Crossover

Mutation

Output

Survival Selection

Initializes Population

Fitness Assignment

9

Parent SelectionGenetic Algorithm Flow

Page 10: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

10

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.

Selection

Crossover

Mutation

Output

Survival Selection

Initializes Population

Fitness Assignment

Crossover and MutationGenetic Algorithm Flow

Page 11: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

11

Genetic Algorithm Operators

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

Control Parameters

Page 12: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

12

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.

Tournament SelectionGenetic Algorithm Selection

Page 13: FEUP | PDEEC | Decision Support

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

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

13

Genetic Algorithm Operators

In nature:P1

P2

P1

P2

P1

P2

P1

P2

Crossover: Two parents produce two offspring.

Crossover: One-Point Crossover

Page 14: FEUP | PDEEC | Decision Support

1 2 3 4 5 6 7 8 9

9 3 7 8 2 6 5 1 4

4 5 6 7

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

14

Genetic Algorithm Operators

1 2 3 4 5 6 7 8 9

9 3 7 8 2 6 5 1 4

4 5 6 7 8

1 2 3 4 5 6 7 8 9

9 3 7 8 2 6 5 1 4

2 4 5 6 7 8

1 2 3 4 5 6 7 8 9

9 3 7 8 2 6 5 1 4

9 3 2 4 5 6 7 1 8

P1

P2

O2

P1

P2

O2

P1

P2

O2

P1

P2

O2

Crossover: Partially Mapped Crossover (PMX)

Page 15: FEUP | PDEEC | Decision Support

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:

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

15

Genetic Algorithm Operators

mutationP1: 1 0 1 1 0 0 1 O1: 1 0 0 1 1 0 1

Mutation: Adds new information to the chromosome.

Mutation: Swap Mutation

Page 16: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

16

OutlinePart One: Introduction to Genetic Algorithm

Part Two: Paper Presentation Motivation Self-Adaptive Genetic Algorithm Flow Heuristic Crossover Mutation Evaluation Experimental Results Conclusion

Metaheuristics Classification Basic Concepts Genetic Algorithm Flow Genetic Algorithm Selection Genetic Algorithm Operators

Crossover Example Mutation Example

Page 17: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

17

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

European Journal of Operational ResearchVolume 183, Pages 1230-1248, 16 June 2006.

Page 18: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

18

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).

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.

Page 19: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

19

Self-Adaptive Genetic Algorithm FlowInitializes Population

EvaluatesPopulation

Pre-Selection

Crossover

Mutation

Output

Post-Selection(Next Generation)

Whi

le S

top

Crite

ria N

ot S

atisfi

ed

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.

Page 20: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

20

HeuristicFour Corners’ Heuristic

4 8 2 9 0 5 3 7 1 6

Bottom-Left → ← Top-Right Bottom-Rigth → ← Top-Left

4 8 2 9 0 5 3 7 1 6Genome

Genome after FC heuristic division

A1 A2

A B

B1 B2

Phenotype of the genome following FC heuristic packing indications

Trim space concentrates more in the center.

Page 21: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

21

CrossoverOperators

if (parent0.crossover_type = parent1.crossover_type) do parent0.crossover_typeelse if (rand(0,1) < 0.5) do parent0.crossover_typeelse do parent1.crossover_typeendif

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.

PMX | Cyclic Crossover | PMRX | PLX

P1 0 1 2 3 4 5 6 7 8 9

P2 1 4 2 7 3 8 5 6 9 0

C1 4 1 2 3 7 5 9 6 8 0

C2 0 4 2 3 1 8 6 7 9 5

X X X X random

Step 1 Step 2 Step 3

PMRX

C1 0 1 2 3 7 8 5 6 9 4

C2 4 1 2 7 3 8 5 6 9 0

PLX

Page 22: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

22

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.

CrossoverOperators

Page 23: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

23

MutationOperators

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) endifendfor

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 | Rotation Mutation | Swap Corners’ Mutation

Swap Mutation pseudo-code.

Page 24: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

24

MutationOperators

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.

Page 25: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

25

EvaluationFitness 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.

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.

Page 26: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

26

Experimental Results

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.

Settings

Page 27: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

27

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.

Experimental Results

Page 28: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

28

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.

Experimental Results

Page 29: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

29

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.

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.

Page 30: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

30

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.

Experimental resultsFour Corners’ Packing

Page 31: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

31

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.

Experimental results

Page 32: FEUP | PDEEC | Decision Support

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Populational Metaheuristics: Genetic Algorithm

32

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.

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.

Page 33: FEUP | PDEEC | Decision Support

Populational MetaheuristicsGenetic Algorithm

FEU

P |

PDEE

C |

Deci

sion

Sup

port

Thank you for your attention!!!

Questions?