introduction to evolutionary algorithms lecture 2

31
Introduction to Evolutionary Algorithms Lecture 2 Jim Smith University of the West of England, UK May/June 2012

Upload: kordell

Post on 22-Mar-2016

38 views

Category:

Documents


2 download

DESCRIPTION

Introduction to Evolutionary Algorithms Lecture 2. Jim Smith University of the West of England, UK May/June 2012. Overview. Recap of EC metaphor Recap of basic behaviour Role of fitness function Dealing with constraints Representation as key to problem solving Integer Representations - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Introduction to Evolutionary  Algorithms Lecture 2

Introduction to Evolutionary AlgorithmsLecture 2

Jim SmithUniversity of the West of England, UKMay/June 2012

Page 2: Introduction to Evolutionary  Algorithms Lecture 2

Recap of EC metaphor Recap of basic behaviour Role of fitness function Dealing with constraints Representation as key to problem solving

– Integer Representations– Permutation Representations– Continuous Representations– Tree-based Representations

2

Overview

Page 3: Introduction to Evolutionary  Algorithms Lecture 2

Recap of EC metaphor

A population of individuals exists in an environment with limited resources

Competition for those resources causes selection of those fitter individuals that are better adapted to the environment

These individuals act as seeds for the generation of new individuals through recombination and mutation

The new individuals have their fitness evaluated and compete (possibly also with parents) for survival.

Over time Natural selection causes a rise in the fitness of the population

3

Page 4: Introduction to Evolutionary  Algorithms Lecture 2

General Scheme of EAs

4

Page 5: Introduction to Evolutionary  Algorithms Lecture 2

Typical behaviour of an EA

Early phase:quasi-random population

distributionMid-phase:population arranged around/on

hillsLate phase:population concentrated on high

hills

Phases in optimising on a 1-dimensional fitness landscape

Page 6: Introduction to Evolutionary  Algorithms Lecture 2

Typical run: progression of fitness

Typical run of an EA shows so-called “anytime behavior”

Bes

t fitn

ess

in p

opul

atio

n

Time (number of generations)

Page 7: Introduction to Evolutionary  Algorithms Lecture 2

Bes

t fitn

ess

in p

opul

atio

n

Time (number of generations)

Progress in 1st half

Progress in 2nd half

Are long runs beneficial?

• Answer: - how much do you want the last bit of progress? - it may be better to do more shorter runs

Page 8: Introduction to Evolutionary  Algorithms Lecture 2

Evolutionary Algorithms in Context

There are many views on the use of EAs as robust problem solving tools.

For most problems a problem-specific tool may:– perform better than a generic search algorithm on

most instances, – have limited utility, – not do well on all instances

Goal is to provide robust tools that provide:– evenly good performance – over a range of problems and instances

Page 9: Introduction to Evolutionary  Algorithms Lecture 2

What are the different types of EAs

Historically different flavours of EAs have been associated with different representations– Binary strings : Genetic Algorithms– Real-valued vectors : Evolution Strategies– Finite state Machines: Evolutionary Programming– LISP trees: Genetic Programming

These differences are largely irrelevant, best strategy – choose representation to suit problem– choose variation operators to suit representation

Selection operators only use fitness and so are independent of representation

9

Page 10: Introduction to Evolutionary  Algorithms Lecture 2

The more fitness levels you have available, the more information is potentially available to guide search

EAs can cope with fitness functions that are:– Noisy, – Time dependant, – Discontinuous– and have Multiple optima,

10

Role of fitness function

Page 11: Introduction to Evolutionary  Algorithms Lecture 2

“Constrained Optimisation Problems”– Some problems inherently have constraints as well

a fitness functions– Can incorporate into fitness functions (indirect)– Can also incorporate into representation (direct)

Constraint Satisfaction Problems– Seek solution which meets set of constraints– Transform to COP by minimising constraints

(indirect method), – Might be able to use good representations (direct)

11

Problems with Constraints

Page 12: Introduction to Evolutionary  Algorithms Lecture 2

Feasible & Unfeasible Regions

Space will be split into two disjoint sets of spaces:– F (the feasible regions) –may be connected– U (the unfeasible regions).

S

X

U

F

ns

Page 13: Introduction to Evolutionary  Algorithms Lecture 2

Methods for constraint handling

In it ia lisa tio n a n d va ria t iono p e ra to rs

d e s ign e d so the y a lw a ysg ive va lid so lu tio ns

G e no typ e ->p he n otypeM a pp ing

e n su re s fe as ib ilityv ia de cod e r

O n ly Fe a s ib le S o lu t io nsA llo w ed

S o lu tio ns pe n a liseda cco rd in g to th e e xte n t o f

co n stra in tv io la tion

"B a ld w in ia n"in fe as ib le so lu tionke p t w ith fitn e sso f fea s ib le po in t

"L a m ark ia n""re p a ire d"

fe a sib le so lu tio n ke p tin po pu la tion

"R e p a ir" fu nc tio nsu sed to g en era tefe a sib le so lu t io ns

c lo se to in fea s ib le po in t

In fea s ib le S o lu tio nsA llo w ed

C o n stra in ed O p tim isa tionDirect Indirect

Page 14: Introduction to Evolutionary  Algorithms Lecture 2

Indirect (Penalty Functions) DirectConceptually simple, transparent it works well

reduces problem to ‘simple’ optimization except simply eliminating all infeasible solutions

Pros allows user to tune to his/her preferences by weights allows EA to tune fitness function by modifying weights during the searchproblem independent

Cons loss of info by packing everything in a single number

problem specific

said not to work well for sparse problems

no guidelines

14

Direct vs Indirect Handling

Page 15: Introduction to Evolutionary  Algorithms Lecture 2

Place N queens on a chess board so they cannot take each other

15

Example: N Queens

64*63*62*61*60*59*58*56 solutions for N=8

=64!/ (56! * 8!)= 4.4 * 109

Page 16: Introduction to Evolutionary  Algorithms Lecture 2

Fitness function: N – num_vulnerable_queens– Transforms CSP to COP

Population and Selection?– Whatever we like, e.g:– Population size100,– tournament selection of 2 parents– Replace two least fit from population if better

Representation?

16

Designing an EA

Page 17: Introduction to Evolutionary  Algorithms Lecture 2

Method 1: Based on the board– 64-bit Binary string: 0/1 empty /occupied– 264 possibilities –more than problem!– Introduces extra constraint that only 8 cells

occupied– Repair function or specialised operators?– Or fractional penalty function

Based on the pieces– More natural and problem focussed– Avoids extra constraint

17

Possible Representations

Page 18: Introduction to Evolutionary  Algorithms Lecture 2

BinaryRecombination

– One point, N-point– Uniform

Randomly choose parent 1 or 2 for each gene

Mutation– Independent flip 0 1 for each gene

18

Operators for binary representations

Page 19: Introduction to Evolutionary  Algorithms Lecture 2

Label cells 1-64 Method 2: one gene per piece encodes cell

– 64N = for 1.7 x 1014 for N=8 (potential duplicates)– 1pt crossover, extended random mutation– Ok, but huge space with only 9 fitness levels

Could make think about constraints– Rows, columns, diagonals– Indirect – penalise all– Direct – can we avoid some?

19

Integer Representations

Page 20: Introduction to Evolutionary  Algorithms Lecture 2

Integer representations

Some problems naturally have integer variables, e.g. image processing parameters

Others take categorical values from a fixed set e.g. {blue, green, yellow, pink}

N-point / uniform crossover operators work Extend bit-flipping mutation to make

– “creep” i.e. more likely to move to similar value– Random choice (esp. categorical variables)– For ordinal problems, it is hard to know correct range for

creep, so often use two mutation operators in tandem

20

Page 21: Introduction to Evolutionary  Algorithms Lecture 2

Method 3– Row constraint <=> each queen on different row– Let value off gene I = column of queen in row I– Solution space size 8N = 1.67x107

– One point crossover, extended randomised mutation Method 4

– As above but also meet column constraints– Permutation: N! = 40320– Now need specialised crossover and mutation

21

Partially direct representations

Page 22: Introduction to Evolutionary  Algorithms Lecture 2

Permutation Representations

Ordering/sequencing problems form a special type. Solution= arrangement objects in a certain order.

– Example: sort algorithm: important thing is which elements occur before others (order),

– Example: Travelling Salesman Problem (TSP) : important thing is which elements occur next to each other (adjacency),

These problems are generally expressed as a permutation:– if there are n variables then the representation is as a list of n

integers, each of which occurs exactly once

22

Page 23: Introduction to Evolutionary  Algorithms Lecture 2

Variation operators for permutations

Normal mutation operators don’t work:– e.g. bit-wise mutation : let gene i have value j– changing to some other value k would mean that k

occurred twice and j no longer occurred Therefore must change at least two values Various mechanisms exist (swap, invert, ...). Similar arguments mean specialised

crossovers are needed.

23

Page 24: Introduction to Evolutionary  Algorithms Lecture 2

24

Example mutation operators

Page 25: Introduction to Evolutionary  Algorithms Lecture 2

“Normal” crossover operators will often lead to inadmissible solutions

Many specialised operators have been devised which focus on combining order or adjacency information from the two parents

Crossover operators for permutations

1 2 3 4 5

5 4 3 2 1

1 2 3 2 1

5 4 3 4 5

Page 26: Introduction to Evolutionary  Algorithms Lecture 2

Many successful Machine Learning / Data Mining algorithms use greedy search:– Decision trees add most informative nodes– Rule Induction: add most useful next rule– Bayesian networks: to identify co-related features

Distance-based methods measure difference along each axis All these can be improved by using global search in the feature

selection process Use a binary coded GA: 0/1 : use/don’t use feature

– M. Tahir and J.E. Smith. Creating Diverse Nearest Neighbour Ensembles using Simultaneous Metaheuristic Feature Selection. 2010. Pattern Recognition Letters, 31(11):1470--1480.

– Smith, M. & Bull, L. (2005) Genetic Programming with a Genetic Algorithm for Feature Construction and Selection. Genetic Programming and Evolvable Machines 6(3): 265-281.

26

Another Example of Binary Encoding: Feature Selection for Machine Learning

Page 27: Introduction to Evolutionary  Algorithms Lecture 2

Binary string representing choice of features

Full Data Set

Reduced Data Set

Machine Learning Algorithm builds and evaluates model on

reduced dataFitness = accuracy

EA

27

Schemata for Feature Selection

Page 28: Introduction to Evolutionary  Algorithms Lecture 2

Protein Structure Prediction:– Proteins are created as strings of amino acid “residues”– Behaviour of a protein is determined by its 3-D structure– Proteins naturally “fold” to lowest energy structure

Model as a fixed-length path through a 3D grid– Representation: sequence of “up/down/L/R/forward” to specify a path– Fitness based on pairwise interactions between residues

N. Krasnogor and W. Hart and J.E. Smith and D. Pelta . Protein Structure Prediction With Evolutionary Algorithms. Proc. GECCO 1999 , pages 1596--1601. Morgan Kaufmann.

R. Santana, P. Larrañaga, and J. A. Lozano. Protein folding in simplified models with  estimation of distribution algorithms.   IEEE Transactions on Evolutionary Computation. Vol. 12. No. 4. Pp. 418-438. 

28

Example of Integer Encoding

Page 29: Introduction to Evolutionary  Algorithms Lecture 2

29

Example of 2D HP model

Dark boxes represent hydrophobic residues (H): H-H contacts add +1 to fitness

Page 30: Introduction to Evolutionary  Algorithms Lecture 2

Need to “drive” processor into a variety of states– to make sure it does the right thing in each.– Test = sequence of assembly code instructions– Traditional methods generate millions of random tests, weren’t

reaching all states UWE solution: evolve sequences of tests

– Integer encoding (fixed number of instructions)– Specialised mutation: group instruction in classes,

more likely to move to similar type of instruction– J.E. Smith and M. Bartley and T.C. Fogarty. Microprocessor Design

Verification by Two-Phase Evolution of Variable Length Tests. Proc. 1997 IEEE Conference on Evolutionary Computation, pages 453--458. IEEE Press

30

Example 2: Microprocessor Design Verification

Page 31: Introduction to Evolutionary  Algorithms Lecture 2

Fitness function should provide as much information as possible– Could penalise infeasible solutions– Selection / Population management is independent

of representation Representation should suit the problem

– Can take constraints into account (direct)– Recombination/Mutation defined by representation– Could be problem specific (direct constraint handling)

31

Summary