genetic algorithms: an introduction - curaj.ac.in algorithm introduction.pdf · what are genetic...

25
Genetic Algorithms: An Introduction Rao Vemuri UC Davis

Upload: tranhuong

Post on 07-Jul-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

Genetic Algorithms: An Introduction

Rao Vemuri

UC Davis

Page 2: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

Outline

Motivation

Running Example

Examples from Dissertations

– DNA Sequencing

– Groundwater Remediation

– Atomic Stabilization

Genetic Programming

Page 3: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

What are Genetic Algorithms

Inspired by Biological Evolution

Search and Optimization Procedures

Good in Rugged Search Spaces

Good for Multimodal Environments

Page 4: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

Characteristics of GA’s

Can solve “hard” problems

Easy to interface with existing models

Rely on very little domain knowledge

Page 5: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

Adaptive Search Using GAs

Figure goes here

Page 6: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

The Central Idea

Start with a population of individual solutions

Represent individual solutions by bit strings

Call each bit string a chromosome

Evaluate each individual for fitness

Select those with high fitness

Mate them using Crossover (Exploitation)

Mutate (Exploration)

Page 7: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

Genetic Operators

Selection:

– Survival of the Fittest

Crossover:

– Unite individuals as parents to generate new

combinations of partial solutions

Mutation:

– Introduce new features not present in the parents

Page 8: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

Selection Operator

Calculate the fitness of all members

Select a subset with better fitness scores

– Roulette wheel selection (or FPR: fitness

proportionate reproduction)

– Tournament selection

– Etc.

Page 9: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

Crossover Operation

Parent 1: 100 111 00

Parent 2: 010 001 10

Child 1: 100 001 00

Child 2: 010 111 10

Page 10: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

Mutation Operation

Mutation is an important genetic operator.

It takes a single candidate and randomly

changes some aspect of it.

Parent: 100 111 00

Child: 100 011 00

Page 11: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

A Running Example

A Franchiser wants a profit-making strategy

in running a restaurant

Options are:

– Affordable Vs Fancy

– Hot Dogs Vs Crepes

– Soft Drinks Vs Wine

Data on costs and sales available to estimate

profits

Page 12: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

Encoding the Problem

Define 3-bit chromosome

Encode as follows

Bit 1: 0 Soft drink 1 Wine

Bit 2: 0 Hot dogs 1 Crepes

Bit 3: 0 Cheap 1 Expensive

Bit 1 Bit 2 Bit 3

Page 13: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

Fitness Evaluation

Each option is a 3-bit sequence

There are only 2^3 = 8 options

Assume that Profit =

Decimal value of the 3-bit sequence

A peek at the correct optimum by exhaustive

enumeration

– 000, 001, 010, 011, 100, 101, 110, 111

Page 14: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

Exhaustive Enumeration is Impractical

Consider a Travelling Salesman Problem

For N cities, there are (N-1)!/2 solutions

Assume

– A 20-city problem takes 1 hour

Then

– 21-city problem takes 20*1 hours = 20 hours

– 22-city problem takes 21*20*1 hours = 17.5 days

– 25-city problem takes ~ 6 Centuries !!!

Page 15: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

Let us Try a GA

Try, say, 4 randomly selected strategies at 4

different outlets

Compare their profits

Pick those that are doing well: Mating Pool

Using X-over and Mutation, generate

offspring strategies

Go back and repeat until a good strategy is

found

Page 16: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

One Simulation Run

X(i) F(i) MP F(i) X(i) F(i)

001 3 011 3 111 7

001 1 110 6 010 2

110 6 110 6 110 6

010 2 010 2 010 2

Total F 12 17 17

Worst 1 2 2

Ave 3 4.25 4.25

Best 6 6 7

Page 17: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

What Did the Franchiser Learn?

Lesson 1: $3 is an estimate of the average

profit (estimate based on 4 samples)

Lesson 2:

– 110 is 200% better than average strategy

– 010 is 2/3 as good as average strategy

– 001 is 1/3 as good as average strategy

Page 18: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

What Do We Do Next?

Option 1: Brute Force Method

– Continue Searching for better solutions

Option 2: Greedy Method

– Because 110 is 200% better than the average,

grab it. Do not worry about searching for better

solutions.

Page 19: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

Another Lesson Learned

Cost of exploring for a better solution

– Current profit – Average profit = $6 - $3 = $3

Cost of NOT exploring further

– Max. profit possible – Current profit + $7 - $6 = $1

This is Exploration Vs Exploitation

Page 20: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

A general form of the genetic algorithm:

Page 21: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

Useful References

• John Holland, Adaption in Natural and Artificial Systems, 1975.

• David E. Goldberg, Genetic Algorithms in Search, Optimization, and Machine Learning, Addison Wesley

• Zbigniew Michalewicz, Genetic Algorithms + Data Structures = Evolution Programs,Third Edition, Springer, 1996, ISBN: 3-540-60676-9,

• Evolutionary computing (EC) was introduced in the 1960s by I. Rechenberg in his work "Evolution strategies" (Evolutionsstrategie in original).

• In 1992 John Koza has used genetic algorithm to evolve programs to perform certain tasks. He called his method "genetic programming" (GP). LISP programs were used, because programs in this language can expressed in the form of a "parse tree", which is the object the GA works on.

Page 22: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

An Example

• Consider f(x)=100x2(1–x)2–x,

which has local minima x1 near 0 and x2

near 1:

Plot

Page 23: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

Code for Plotting

ezplot('100*x^2*(1-x)^2 - x',[-0.2,1.2])

ylabel('f(x)')

hold on

plot([0 0],[-1.7 0],'r--')

plot([1 1],[-1.7 -1],'r--')

annotation('textbox',[0.25 0.1 0.07 0.1],...

'String',{'x1'},'EdgeColor','none');

annotation('textbox',[0.8 0.1 0.07 0.1],...

'String',{'x2'},'EdgeColor','none');

hold off

Page 24: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

Output of Matlab

The minima are located at:

x1 = fminsearch(@(x)(100*x^2*(x - 1)^2 - x),0)

x1 =

0.0051

x2 = fminsearch(@(x)(100*x^2*(x - 1)^2 - x),1)

x2 =

1.0049

Page 25: Genetic Algorithms: An Introduction - curaj.ac.in Algorithm Introduction.pdf · What are Genetic Algorithms Inspired by Biological Evolution Search and Optimization Procedures Good

Plot