Download Genetic Algorithms It is a Search Technique When changes occur

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

Mutation wikipedia , lookup

Designer baby wikipedia , lookup

Genetic engineering wikipedia , lookup

Behavioural genetics wikipedia , lookup

Genetic testing wikipedia , lookup

Public health genomics wikipedia , lookup

Epistasis wikipedia , lookup

Biology and consumer behaviour wikipedia , lookup

Genome (book) wikipedia , lookup

Human genetic variation wikipedia , lookup

Heritability of IQ wikipedia , lookup

Genetic drift wikipedia , lookup

Koinophilia wikipedia , lookup

Gene expression programming wikipedia , lookup

Microevolution wikipedia , lookup

Population genetics wikipedia , lookup

Transcript
When changes occur ...
Genetic Algorithms
22c: 145, Chapter 4
It is a Search Technique


Previously “fit” (well-adapted) individuals will
no longer be best-suited for their
environment
Some members of the population will have
genes that confer different characteristics
than “the norm”. Some of these
characteristics can make them more “fit” in
the changing environment.
Genetic Change in Individuals

Mutation in genes
may be due to various sources (e.g. UV
rays, chemicals, etc.)
Start:
1001001001001001001001

After Mutation:
1001000001001001001001
Natural Selection



Limited number of resources
Competition results in struggle for existence
Success depends on fitness -

fitness of an individual: how well-adapted an
individual is to their environment. This is
determined by their genes (blueprints for their
physical and other characteristics).
Location of Mutation
Genetic Change in Individuals

Recombination (Crossover)

occurs during reproduction -- sections of
genetic material exchanged between two
chromosomes
Successful individuals are able to reproduce
and pass on their genes
1
Recombination (Crossover)
Genetic Algorithms


Why Evolution Proves to be a Good Model
for Solving these Types of Problems


Possibilities -- all individuals
Best solution -- the most “fit” or well-adapted individual




Testing and changing of numerous species and individuals
occur at the same time (or, in parallel)
where the first 8 bits of the string
represent the X-coordinate and the
second 8 bits represent the Y-coordinate
Evolution can be seen as a method that designs
new (original) solutions to a changing
environment
The Metaphor
EVOLUTION
Individual
Fitness
Environment
Example: Looking for a new site which is
closest to several nearby cities.
Express the problem in terms of a bit string
z = (1001010101011100)
Evolution is a parallel process

A simulated population of randomly
selected individuals is generated then
allowed to evolve
Encoding the Problem
Evolution is a method of searching for an (almost)
optimal solution

Closely follows a biological approach to
problem solving
Basic Genetic Algorithm
PROBLEM SOLVING
Candidate Solution
Quality
Problem



Step 1. Generate a random population
of n individuals
Step 2. Assign a fitness value to each individual
Step 3. Repeat until n children have been
produced



Choose 2 parents based on fitness proportional
selection
Apply genetic operators to copies of the parents
Produce new chromosomes
2
Fitness Function


For each individual in the population,
evaluate its relative fitness
Sample Search Space

For a problem with m parameters, the fitness
can be plotted in an m+1 dimensional space
Genetic algorithms for 8-Queen
Problem
A randomly generated population of
individuals will be randomly distributed
throughout the search space
An Abstract Example
Distribution of Individuals in Generation 0
[6,7,2,4,7,5,8,8] + [7,5,2,5,1,4,4,7] = [6,7,2,5,1,4,4,7]
Distribution of Individuals in Generation N
Genetic algorithms



Fitness function: number of non-attacking pairs of
queens, the higher, the better (min = 0, max = 8 ×
7/2 = 28)
24/(24+23+20+11) = 31%
23/(24+23+20+11) = 29% etc
Genetic Operators

Cross-over

Mutation
3
Production of New
Chromosomes

Ultimate Goal
2 parents give rise to 2 children



After sufficient generations a near optimal
solution will be present in the population of
chromosomes
Example: Find the max value
of f(x1, …, x100).
Generations

Each subsequent generation will evolve
toward the global maximum (or minimum)
As each new generation of n individuals is
generated, they replace their parent
generation

To achieve the desired results, typically 500
to 5000 generations are required

The Evolutionary Cycle

Population: real vectors of length 100.
Mutation: randomly replace a value in a
vector.
Combination: Take the average of two
vectors.
A Simple Example
Selection
Parents
The Traveling Salesman Problem:
Recombination
Find a tour of a given set of cities so that
Population
Mutation


each city is visited only once
the total distance traveled is minimized
Replacement
Offspring
4
Representation
TSP Example: 30 Cities
Representation is an ordered list of city
numbers known as an order-based GA.
120
100
3) Dunedin
4) Singapore
5) Beijing
7) Tokyo
6) Phoenix 8) Victoria
CityList1
(3 5 7 2 1 6 4 8)
CityList2
(2 5 7 6 8 1 3 4)
y
80
1) London
2) Venice
60
40
20
0
0
10
20
30
40
50
60
70
80
90
100
x
Crossover
Solution i (Distance = 941)
TSP30 (Performance = 941)
120
Crossover combines inversion and recombination:
Parent2
Child
(3 5 7 2 1 6 4 8)
(2 5 7 6 8 1 3 4)
(5 8 7 2 1 6 3 4)
80
y
Parent1
100
60
40
20
0
0
10
20
30
40
Copy a randomly selected portion of Parent1 to Child
(2) Fill the blanks in Child with those numbers in Parent2 from left to
right, as long as there are no duplication in Child.
This operator is called the Order1 crossover.
Mutation involves swapping two numbers
of the list:
Before:
After:
*
*
(5 8 7 2 1 6 3 4)
(5 8 6 2 1 7 3 4)
60
70
80
90
100
Solution j(Distance = 800)
44
62
69
67
78
64
62
54
42
50
40
40
38
21
35
67
60
60
40
42
50
99
TSP30 (Performance = 800)
120
100
80
y
Mutation
50
x
(1)
60
40
20
0
0
10
20
30
40
50
60
70
80
90
100
x
5
Solution k(Distance = 652)
Discrete Recombination
TSP30 (Performance = 652)
120

100
y
80

60
40
Similar to crossover of genetic
algorithms
Equal probability of receiving each
parameter from each parent
(8, 12, 31, … ,5) (2, 5, 23, … , 14)
20
0
0
10
20
30
40
50
60
70
80
90
(2, 12, 31, … , 14)
100
x
Best Solution (Distance = 420)
Intermediate Recombination
TSP30 Solution (Performance = 420)
120

100
80
y
42
38
35
26
21
35
32
7
38
46
44
58
60
69
76
78
71
69
67
62
84
94

60
40
(8, 12, 31, … ,5) (2, 5, 23, … , 14)
20
0
0
10
20
30
40
50
60
70
80
90
100
(5, 8.5, 27, … , 9.5)
x
Overview of Performance
Tuning a GA
TSP30 - Overview of Performance
1800

1600
Distance
Often used to adapt the strategy
parameters
Each child parameter is the mean value
of the corresponding parent parameters
“Typical” tuning parameters for a small problem
1400
Population size:
1200
Children per generation:
50 – 100
= population size
1000
Crossovers:
0–3
800
Mutations:
< 5%
600
Generations:
20 – 20,000
400

200
0
Best
1
3
5
7
9
11
13
15
17
19
Generations (1000)
21
23
25
27
29
31
Other concerns

Worst
Average



population diversity
ranking policies
removal policies
role of random bias
6
Domains of Application







Numerical, Combinatorial Optimization
System Modeling and Identification
Planning and Control
Engineering Design
Data Mining
Machine Learning
Artificial Life
When NOT to use a GA?


if global optimality is required
if problem insight can:


significantly impact algorithm performance
simplify problem representation

if the problem is highly constrained
if the problem is smooth and convex

if the search space is very small



use a gradient-based optimizer
use enumeration
Drawbacks of GA



Difficult to find an encoding for a
problem
Difficult to define a valid fitness
function
May not return the global maximum
Why use a GA?








requires little insight into the problem
the problem has a very large solution space
the problem is non-convex
does not require derivatives
objective function need not be smooth
variables do not need to be scaled
fitness function can be noisy (e.g. process data)
when the goal is a good solution
7