derivative-free optimization: genetic algorithms dan simon cleveland state university 1

30
Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Post on 15-Jan-2016

219 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Derivative-Free Optimization:Genetic Algorithms

Dan SimonCleveland State University

1

Page 2: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Outline

1. Biological Genetics2. Genetic Algorithm: A Short History3. Genetic Algorithm Example: Robot Design4. Genetic Algorithm Options5. Genetic Algorithm Example: Ackley Function6. Continuous Genetic Algorithm7. GA Code Walk-Through

2

Page 3: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Charles Darwin

• Born in England, 1809• “You care for nothing but

shooting, dogs, and rat-catching; and you will be a disgrace to yourself and all your family.”

• Medicine?• Theology?• Biology?

3

Page 4: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Charles Darwin

• H. M. S. Beagle: 1831–1836• The Origin of Species: 1836–…• Paper from Alfred Wallace: 1858• Presentation of both papers by

Darwin: 1858• The Origin of Species: 1859

“Only” 500 pagesThe first printing (1,250 copies) sold out the first day

4

Page 5: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Darwin’s Theory of Natural Selection

• Survival of the fittest• Controversial

– Anti-Christian?– How are traits passed to children?

• Misconceptions– Traits of parents could be blended in children– Acquired traits could be passed to children

5

Page 6: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Gregor Mendel

• Born in 1822 in Czech.• Poor farming family• Joined Augustinian monastery

at age 21• Studied botany (peas)• Discovered the idea of genes, heredity, and

dominance• His publication (1865) was ignored at the time

6

Page 7: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Genetic Algorithms

• Princeton, John von Neumann• Nils Barricelli (mathematician),

1953, artificial life• 1954: “Esempi numerici di

processi di evoluzione” (Numerical models of evolutionary processes)

7

Page 8: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Genetic Algorithms

• Alexander Fraser (biologist) – England, Hong Kong, New Zealand, Scotland, Australia – 1957: “Simulation of genetic systems by automatic digital computers”

• Hans-Joachim Bremermann – University of Washington, UC Berkeley – 1958: “The evolution of intelligence”

8

Page 9: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Genetic Algorithms

• George Box (statistician) – Imperial Chemical Industries (England) – 1957: “Evolutionary operation: A method for increasing industrial productivity”“Essentially, all models are wrong, but some are useful” (1987)

• George Friedman, UCLA – 1956: “Selective Feedback Computers for Engineering Synthesis and Nervous System Analogy” (Master’s thesis)

9

Page 10: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

GA for Robot Design

000 = 5-volt stepper001 = 9-volt stepper010 = 12-volt stepper011 = 24-volt stepper100 = 5-volt servo101 = 9-volt serv110 = 12-volt serv111 = 24-volt servo

000 = 12-volt NiCd battery001 = 24-volt NiCd battery010 = 12-volt Li-ion battery011 = 24-volt Li-ion battery100 = 12-volt solar panel101 = 24-volt solar panel110 = 12-volt fusion reactor111 = 24-volt fusion reactor

encoding for motor spec encoding for power spec10

Page 11: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

GA for Robot Design

Fitness = Range (hrs) + Power (W) – Weight (kg)• Experiment or simulationWe are combining incompatible unitsRandomly create initial population:Individual 1 12-volt step motor , 24-volt solar panel

Individual 2 9-volt servo motor010 101

101 1

,24-volt NiCad battery

01

Each individual is represented with a chromosome which has two genes 11

Page 12: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

GA for Robot Design

Individual 1 chromosome = 010 101 Individual 1’s motor genotype is 010, and its

motor phenotype is “12-V stepper”

0 1 0 1 0 1

1 0 1 0 0 1

crossover point

0 1 1 0 0 1

1 0 0 1 0 1

Two Parents Two Children

12

Page 13: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

GA for Robot DesignHow do we decide which individuals to mate?Fitness proportional selection, AKA roulette-wheel selectionExample: four individuals with fitness values 10, 20, 30, and 40

Individual 1

Individual 2Individual 4

Individual 3

1020

30

40

13

Page 14: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

A Simple Genetic AlgorithmParents {randomly generated population}While not (termination criterion)

Calculate the fitness of each parent in the populationChildren = While |Children| < |Parents|

Use fitnesses to select a pair of parents for matingMate parents to create children c1 and c2

Children Children { c1, c2}

LoopRandomly mutate some of the childrenParents Children

Next generation

14

Page 15: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

GA Termination Criteria

1. Generation count2. Fitness threshold3. Fitness improvement threshold

15

Page 16: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Critical GA Design Parameters

1. Elitism2. Encoding scheme3. Fitness function and scaling4. Population size5. Selection method (tournament, rank, …)6. Mutation rate7. Crossover type8. Speciation / incest

16

Page 17: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

GA Schematic

10010110

01100010

10100100

10011001

01111101

---

---

---

---

SelectionSelection CrossoverCrossover MutationMutation

Currentgeneration

Nextgeneration

Elitism10010110

01100010

10100100

10111100

11001011

---

---

---

---

17

Page 18: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Encoding

Binary: Neighboring phenotypes have dissimilar genotypes, and vice versa

Gray: Neighboring phenotypes have similar genotypes

000 001 010 011 100 101 110 111

000 001 011 010 110 111 101 100

x = -5 : 0.1 : 2plot(x, x.^4 + 5*x.^3 + 4*x.^2 – 4*x + 1);

18

Page 19: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Gray Codes

Bell Labs researcher Frank Gray introduced the term reflected binary code in his 1947 patent application.

19

Page 20: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Ackley Function2 2 cos(2 ) cos(2 )

( , ) 20 20exp 0.2 exp2 2

genotype [0,63]

10 phenotype 5 [ 5,5]

63 genotype [0,63]

10 phenotype 5 [ 5,5]

63

g

g

g

g

x y x yf x y e

x x

xx

y y

yy

Minimization problem; global minimum = 0 (at x = y = 0)Can be generalized to any number of dimensions

20

Page 21: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Ackley Function

• 100 Monte Carlo simulations• Population size = 50• Mutation rate = 2%• Crossover probability = 100%• Single point crossover• Encoding: binary or gray• Elitism: 0 or 2

21

Page 22: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Ackley Function

-5

0

5

-5

0

5-20

-15

-10

-5

xy

Ack

ley

fun

ctio

n

22

Page 23: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Ackley Function

0 10 20 30 40 501

1.5

2

2.5

3

3.5

4

4.5

Generation

Min

imu

m C

ost

Binary Coding without ElitismBinary Coding with ElitismGray Coding without ElitisimGray Coding with Elitism

Average of 100 Monte Carlo simulations 23

Page 24: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Ackley Function

0th generation-5 0 5

-5

0

5

5th generation-5 0 5

-5

0

5

10th generation-5 0 5

-5

0

5

15th generation-5 0 5

-5

0

5

24

Page 25: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Continuous Genetic Algorithms

Parents crossover:[1.23, 4.76, 2.19, 7.63] [9.73, 1.09, 4.87, 8.28]

Children:[1.23, 1.09, 4.87, 8.28] [9.73, 4.76, 2.19, 7.63]

crossover point

Usually, GAs for continuous problems are implemented as continuous GAs

25

Page 26: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Continuous Genetic Algorithms

Blended crossover:Select a random number r [0, 1]Genotype operation: c = p1 + r(p2—p1)

Parent 1

Parent 2

Child

26

Page 27: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Continuous Genetic Algorithms

Mutation: Suppose x = [9.73, 1.09, 4.87, 8.28]Problem dimension = 4r random number [0, 1]If r < pm then

i random integer [1, 4]r random number [0, 1]x(i) xmin + r(xmax – xmin)

end if

Aggressive Mutation

27

Page 28: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Continuous Genetic Algorithms

Mutation: Suppose x = [9.73, 1.09, 4.87, 8.28]Problem dimension = 4r random number [0, 1]If r < pm then

i random integer [1, 4]r Gaussian random number N(0, )x(i) x(i) + r

end if

Gentle Mutation

28

Page 29: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Rastrigin Benchmark Function

Global minimum f(x) = 0 at xi = 0 for all i

2

1

10co( ) 1 s 20p

i ii

f p xx x

p dimensions

Lots of local minima

29

Page 30: Derivative-Free Optimization: Genetic Algorithms Dan Simon Cleveland State University 1

Rastrigin Benchmark Function

Population size = 50Mutation rate = 1%Crossover prob. = 100%Single point crossoverElitism = 215 dimensions

0 10 20 30 40 500

50

100

150

200

250

300

Generation

Co

st

Average CostMinimum Cost

30

GA.m