1 ? Massachusetts Institute of Technology - Prof. de Weck and Prof. Willcox
Engineering Systems Division and Dept. of Aeronautics and Astronautics
Heuristic Techniques:
A Basic Introduction to Genetic Algorithms
Lecture 11
March 8, 2004
Olivier de Weck
Multidisciplinary System Design Optimization
2 ? Massachusetts Institute of Technology - Prof. de Weck and Prof. Willcox
Engineering Systems Division and Dept. of Aeronautics and Astronautics
Heuristic Search Techniques
Main Motivation for Heuristic Techniques:
(1) To deal with local optima and not get trapped in
them
(2) To allow optimization for systems, where the
design variables are not only continuous, but discrete,
integer or even Boolean
These techniques do not guarantee that
global optimum can be found. Generally
Karush-Kuhn-Tucker conditions do not apply.
i
x ? x
i
={1,2,3,4,5}, x
i
={‘A’,’B’,’C’} x
i
={true, false}
x
J
3 ? Massachusetts Institute of Technology - Prof. de Weck and Prof. Willcox
Engineering Systems Division and Dept. of Aeronautics and Astronautics
Principal Heuristic Algorithms
Genetic Algorithms (Holland – 1975)
– Inspired by genetics and natural selection
Simulated Annealing (Kirkpatrick – 1983)
– Inspired by molecular dynamics – energy minimization
Particle Swarm Optimization (Eberhart and
Kennedy - 1995)
– Inspired by the social behavior of swarms of insects or
flocks of birds
These techniques all use a combination of
randomness and heuristic “rules” to guide
the search for global maxima or minima
4 ? Massachusetts Institute of Technology - Prof. de Weck and Prof. Willcox
Engineering Systems Division and Dept. of Aeronautics and Astronautics
Today: Genetic Algorithms
Genetics and Natural Selection
A simple genetic algorithm (SGA)
“The Genetic Algorithm Game”
Encoding - Decoding (Representation)
Fitness Function - Selection
Crossover – Insertion - Termination
Part 1 - Introduction
5 ? Massachusetts Institute of Technology - Prof. de Weck and Prof. Willcox
Engineering Systems Division and Dept. of Aeronautics and Astronautics
Premise of GAs
Natural Selection is a very successful organizing
principle for optimizing individuals and populations of
individuals
If we can mimic natural selection, then we will be able
to optimize more successfully
A possible design of a system – as represented by its
design vector x - can be considered as an individual
who is fighting for survival within a larger population.
Only the fittest survive – Fitness is assessed via
objective function J.
6 ? Massachusetts Institute of Technology - Prof. de Weck and Prof. Willcox
Engineering Systems Division and Dept. of Aeronautics and Astronautics
Matlab GA demo (“peaks”)
Maximize “peaks” function
Population size: 40
Generations: 20
Mutation Rate: 0.002
-Observe convergence
-Notice “mutants”
-Compare to gradient search
7 ? Massachusetts Institute of Technology - Prof. de Weck and Prof. Willcox
Engineering Systems Division and Dept. of Aeronautics and Astronautics
Natural Selection
Charles Darwin (1809-1882)
Extremely controversial and influential book (1859)
On the origin of species by means of natural
selection, or the preservation of favoured races
in the struggle for life
Observations:
Species are continually developing
Homo sapiens sapiens comes from ape-like stock
Variations between species are enormous
Huge potential for production of offspring, but only
a small percentage survives to adulthood
Evolution = natural selection of inheritable variations
8 ? Massachusetts Institute of Technology - Prof. de Weck and Prof. Willcox
Engineering Systems Division and Dept. of Aeronautics and Astronautics
Inheritance of Characteristics
Gregor Mendel (1822-1884)
Investigated the inheritance of characteristics (“traits”)
Conducted extensive experiments with pea plants
Examined hybrids from different strains of plant
tall tall
tall
tall
tall
short short
short
short
Character (gene) for tallness is dominant
Character (gene) for shortness is recessive
9 ? Massachusetts Institute of Technology - Prof. de Weck and Prof. Willcox
Engineering Systems Division and Dept. of Aeronautics and Astronautics
Genetics
… the great unknown …. Walter Sutton (1877-1916)
Discovered that genes are part of the chromosomes
inside the nucleus of cells
… still unexplained … Darwin predicted continuous
variation within species. In nature we often observe
discontinuous variations
… strinkingly different, unexpected variants sometimes
appear, how to explain ???
Hugo de Varis (1848-1935) developed a theory of
mutation - at first seemingly at odds with Darwinism
How has this dilemma been resolved?
11 ? Massachusetts Institute of Technology - Prof. de Weck and Prof. Willcox
Engineering Systems Division and Dept. of Aeronautics and Astronautics
GA Terminology
chromosome
gene
population
Generation n Generation n+1
selection
crossover
insertion
mutation
genetic
operators
individuals
12 ? Massachusetts Institute of Technology - Prof. de Weck and Prof. Willcox
Engineering Systems Division and Dept. of Aeronautics and Astronautics
Chromosomes
Chromosome (string)
gene
0 1 0 1 1 1 1 0 1 0 0 1 ….. 0 1
alleles
Each chromosome represents a solution, often
using strings of 0’s and 1’s. Each bit typically
corresponds to a gene. This is called binary
encoding.
The values for a given gene are the alleles.
A chromosome in isolation is meaningless -
need decoding of the chromosome into phenotypic values
13 ? Massachusetts Institute of Technology - Prof. de Weck and Prof. Willcox
Engineering Systems Division and Dept. of Aeronautics and Astronautics
GA over several generations
Initialize Population (initialization)
Select individual for mating (selection)
Mate individuals and produce children (crossover)
Mutate children (mutation)
Insert children into population (insertion)
Are stopping criteria satisfied ?
Finish
y
n
next
gen
e
r
ati
on
Ref: Goldberg
14 ? Massachusetts Institute of Technology - Prof. de Weck and Prof. Willcox
Engineering Systems Division and Dept. of Aeronautics and Astronautics
“The GA Game”
Ca. 15 minutes
111
212
313
4520
584
695
7642
83
9327
10 3 30
1100
200
40 6.075
GA Game Initial Population
0
2
4
6
8
10
12345678910112
Fitness Value
N
u
m
b
e
r
of
I
ndi
v
i
du
a
l
s
Generation 1:
Population size: N=40
Mean Fitness: F=6.075
(Fitness F = total number of 1’s in chromosome)
0 <= F <= 12
Goal: Maximize Number of “1”s
15 ? Massachusetts Institute of Technology - Prof. de Weck and Prof. Willcox
Engineering Systems Division and Dept. of Aeronautics and Astronautics
Creating a GA on Computer
(1) define the representation (encoding-decoding)
(2) define “fitness” function F
- incorporate feasibility (constraints) and objectives
(3) define the genetic operators
- initialization, selection, crossover, mutation, insertion
(4) execute initial algorithm run
- monitor average population fitness
- identify best individual
(5) tune algorithm
- adjust selection, insertion strategy, mutation rate
16 ? Massachusetts Institute of Technology - Prof. de Weck and Prof. Willcox
Engineering Systems Division and Dept. of Aeronautics and Astronautics
Encoding - Decoding
phenotype
genotype
Biology
Design
“blue eye”
UGCAACCGU
(“DNA” blocks)
10010011110
expression
(chromosome)
decoding
encoding
Radius R=2.57 [m]
H
sequencing
coded domain decision domain
Genetic Code: (U,C,G,A are the four bases of the nucleotide
building blocks of messenger-RNA): Uracil-Cytosin-
Adenin-Guanin - A triplet leads to a particular aminoacid (for protein
synthesis) e.g. UGG-tryptophane
17 ? Massachusetts Institute of Technology - Prof. de Weck and Prof. Willcox
Engineering Systems Division and Dept. of Aeronautics and Astronautics
Decoding
0 1 0 1 1 1 1 0 1 0 0 1 ….. 0 1
Radius (genotype)
Height
Coding and decoding MATLAB functions available:
decode.m, encode.m
E.g. binary encoding of integers:
10100011
(1*2
7
+0*2
6
+1*2
5
+0*2
4
+0*2
3
+0*2
2
+1*2
1
+1*2
0
)
128 + 0 + 32 + 0 + 0 + 0 + 2 + 1 = 163
Material
x
1
x
2
x
n
18 ? Massachusetts Institute of Technology - Prof. de Weck and Prof. Willcox
Engineering Systems Division and Dept. of Aeronautics and Astronautics
Binary Encoding Issues
Number of bits dedicated to a particular design
variable is very important.
Resolution depends on:
- upper and lower bounds x
LB
, x
UB
- number of bits
x
LB
x
UB
?x=(x
UB-
x
LB
)/2
nbits
[G]=encode(137.56,50,150,8)
G = 1 1 0 1 1 1 1 1
[X]=decode(G,50,150,8);
X = 137.4510
x∈ So ?x= (150-50)/2
8
= 0.39
Example
Loss in precision !!!
Number of bits needed:
ln
ln 2
UB LB
xx
x
nbits
a ? o
§