Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Genetic Algorithms
One does not know where to look for the solution and
where to start
There are many methods for finding some suitable
solution (ie. not necessarily the best solution), for
example hill climbing, simulated annealing .. etc
The solution found by these methods is often
considered as a good solution, because it is not often
possible to prove what is the real optimum
1011101010
Methodology II
The evolution usually starts from a population of randomly generated
individuals, and is an iterative process, with the population in each iteration
called a generation
In each generation, the fitness of every individual in the population is
evaluated; the fitness is usually the value of the objective function in the
optimization problem being solved
The more fit individuals are stochastically selected from the current population,
and each individual's genome is modified (recombined and possibly randomly
mutated) to form a new generation
The new generation of candidate solutions is then used in the next iteration of
the algorithm
Commonly, the algorithm terminates when either a maximum number of
generations has been produced, or a satisfactory fitness level has been
reached for the population
These two items must be developed again, whenever a new problem is specified
Outline of the Basic Genetic
Algorithm
1- [Start] Generate random population of n chromosomes (suitable solutions for the
problem)
2- [Fitness] Evaluate the fitness f(x) of each chromosome x in the population
3- [New population] Create a new population by repeating following steps until the
new population is complete
[Selection] Select two parent chromosomes from a population according to their fitness
(the better fitness, the bigger chance to be selected)
[Crossover] With a crossover probability cross over the parents to form a new offspring
(children). If no crossover was performed, offspring is an exact copy of parents.
[Mutation] With a mutation probability mutate new offspring at each locus (position in
chromosome).
[Accepting] Place new offspring in a new population
4- [Replace] Use new generated population for a further run of algorithm
5- [Test] If the end condition is satisfied, stop, and return the best solution in
current population
6- [Loop] Go to step 2
Source: AI - Simple Genetic Algorithm (GA) to solve a card problem By Sacha Barber, 8 Nov 2006
Source: AI - Simple Genetic Algorithm (GA) to solve a card problem By Sacha Barber, 8 Nov 2006
The Problem Statement
The problem domain states that we have the
coordinates of 10 short line segments (dashes)
Five of these dashes form one dahsed line and
the other five form another dashed line
Dashed Line Segment
A set of line segments
Elements are approximately collinear (use of rc)
Every element of it has length of approximately
dl
No two elements of have a separation distance
of less than the minimum of ds
Please Cite this Paper
@InProceedings{SaSeSo-DRR12-ChemicalStructureRecognition-
ARuleBasedApproach,
author = {Sadawi, Noureddin M. and Sexton, Alan P. and Sorge, Volker},
title = {Chemical Structure Recognition: A Rule Based Approach},
booktitle = {19th Document Recognition and Retrieval Conference (DRR 2012)},
year = 2012,
editor = {Christian Viard-Gaudin and Richard Zanibbi},
month = {January},
doi = {10.1117/12.912185},
publisher = {SPIE},
}
Representation of the Solution
A solution will be a binary array of size 10:
e.g. [1,0,0,1,1,0,1,0,1,0]
The 1's represent five dashes & the 0's represent the other
five dashes
WE CONDITION that DAHSES are in ORDER
Remember: Five of the short line segments form one
dahsed line and the other five form another dashed line
How to do it!
We will create an array of size 10 to hold the coordinates of the
10 dashes dashes = [((x1,y1),(x2,y2)), ((x1,y1),(x2,y2)),...,((x1,y1),(x2,y2))]
We will create a chromosome matrix (30 by 10) .. The 30
represents a population size of 30 (It could be any size, but
should be big enough to allow some dominant solutions to
form)
Each member of this matrix represents a possible solution
(binary array of size 10)
e.g. [1,0,0,1,1,0,1,0,1,0] ---> [d1,d4,d5,d7,d9] [d2,d3,d6,d8,d10]
On the other hand, for this encoding it is often necessary to develop some
new crossover and mutation techniques specific for the problem
Example Value Encoding
Example of Problem: Finding weights for
neural network
The problem:
There is some neural network with given architecture
Find weights for inputs of neurons to train the
network for wanted output
Encoding: Real values in chromosomes
represent corresponding weights for inputs
Tree Encoding
Tree encoding is used mainly for evolving programs or expressions, for genetic
programming
In tree encoding every chromosome is a tree of some objects, such as functions or
commands in programming language
You can see in following picture, how the situation changes after
changing fitness to order number
12345 12321
54321 54345
Source: http://paginas.fe.up.pt/~mac/ensino/docs/OR/HowToSolveIt/Ch%206%20-%20An%20evolutionary%20approach.pdf
Partially Mapped Crossover
(PMX)
Informal procedure for parents P1 and P2:
1. Choose random segment and copy it from P1 to child
2. Starting from the first crossover point look for elements in that segment
of P2 that have not been copied
3. For each of these i look in the offspring to see what element j has been
copied in its place from P1
4. Place i into the position occupied by j in P2, since we know that we will
not be putting j there (as j is already in offspring)
5. If the place occupied by j in P2 has already been filled in the offspring
by k, put i in the position occupied by k in P2
6. Having dealt with the elements from the crossover segment, the rest of
the offspring can be filled from P2
Second child is created analogously
Step 1
i j
8 4
2 5
Step 2
i j k
2 5 7
Step 3