Genectic Algorithm Intro
Genectic Algorithm Intro
2
Definition
Ability of computer programs to operate in the same
way that human thought executes its learning and
recognition processes.
3
Definition
Depende del autor:
4
Definition
The automation of activities that we link to the human
thinking process, such as decision making, problem
solving, learning … (Bellman, 1987)
5
Objective
Build programs to solve "hard" problems:
Problems where does not exist a single solution.
They require enormous amounts of information.
They must deal with incomplete, confusing or even
contradictory information.
6
Problems addressed by AI
Common sense reasoning
Perception (vision, speech)
Natural language processing.
Medical Diagnosis
Chemical analysis.
Pattern recognition.
Optimization.
Robotics.
7
Heuristic Search
A trick or strategy that greatly limits the search for
solutions to large problem spaces. Therefore, when
faced with a problem, it helps us to select the
bifurcations, within a tree, with the most possibilities,
thereby restricting the search, although an adequate
solution is not always guaranteed. All that is necessary
for a heuristic to be adequate is that it provides us with
solutions that are good enough. In addition, by using
heuristics, it will not be necessary to restate a problem
each time it is faced, since if we have previously posed
it, it will suggest the way in which to proceed to solve it.
8
Heuristic Search
In finance, the use of this type of algorithms is
frequent in optimization problems, where it is
required to maximize/minimize one or several
variables, which depend on the problem being
analyzed.
9
Examples of heuristic methods
Genetic Algorithms (GA)
Particle Swarm Optimization (PSO)
Genetic Algorithms
By: Abraham Oceguera Gómez
Saúl Alonso Nuño Sánchez
Objective
Solve optimization problems using Genetic algorithms
Glossary
Algorithm: series of mathematical steps, especially in a computer program, which will
give you the answer to a particular kind of problem.
Heuristic: in the context of computer programs, this term refers to rules based on
previous experience in order to solve a problem, rather than using a mathematical
procedure.
Genotype: it refers to the genetic constitution (codification) of an individual or
organism.
Phenotype: in the context of programming, it refers to decodification
Introduction
Creator: John Holland (Adaptation in Natural and
Systems, 1975).
Imitate adaptative process of natural systems.
Design artificial systems (programs) that allow to retain
mechanisms of natural systems.
Are inspired in biologic evolution and natural selection.
Important people: K. DeJong y D. Goldberg (1989), Davis
(1991), Michalewicz (1992), Reeves (1993)
14
Introduction
Characteristics of Genetic Algorithms (GA):
Are probabilistic (The output of the algorithm could be
different each is applied to the same data).
Are Heuristics (Could achieve good solutions).
Are based on natural selection and genetic (Darwing
1859).
Widely used in discrete Optimization.
GA are not too fast.
GA allow to do parallel search.
15
Advantages
Are robust.
GA can be applied to non continuous functions.
With GA different kind of problems can be solved: with
big dimensions, lineal, no lineal, multi objective, with
noise or dependent on time.
GA work well with discrete variables.
16
Disadvantages
A wrong definition of the objective function leads to bad
results as well as a wrong codification.
Premature convergence produced by a super individual.
A bad selection of parameters could lead to bad solutions
(not as good as we expected).
AG provide slower solution than if the problem can be
tackled by an analytic way.
17
How to know when to use GA?
The search space (possible solutions) is limited by a finite
range.
The fitness function (how good or bad is the solution)
must be defined by an equation.
Solutions must be codified in a simple way in order to be
implemented in a computer code.
18
Applications
Optimization
Automatic programming
Machine learning
Economy and Finance
Immune systems
Ecology
Genetic of Population
Evolution and learning
Social systems
19
GA (How does it works?)
GA (Functioning)
1. Generate initial population.
2. Evaluate each member of the population
(individual).
3. Select progenitors.
4. Crossover progenitor to generate new individuals
(Sons).
5. Mutate sons (Randomly).
6. Create a new population with the selected
progenitors and their descendants.
7. Iterate step 2 to 6 until the stop criteria is reached.
GA components
Adequate Codification.
Initial population.
Fitness function.
Evolutionary operators.
Input parameters value.
22
GA
Let P(t) the population at time t and C(t) the set of new individuals, the general
structure of a GA could be:
23
GA representation
The solutions of a GA are called
string, structure o
chromosome.
Usually this solutions are codified
with binary numbers.
25
GA representation
Genotype is the codification of the individuals.
Phenotype: Decodification of the individuals
with
26
GA representation
The term individual denotes the set of information
genotype-phenotype-fitness.
The individual at time (generation) t is represented by
the tripled:
27
Initial population
Input parameter for a GA, which is a set of m individuals.
If the coding is binary, assign a random value between 0
and 1 to each gene in the chromosome.
Fitness function
It consists of evaluating the phenotype through the
objective function f of the problem being solved.
28
GA operator
1. Selection
2. Crossover
3. Mutation
29
Selection
Transmit and preserve the characteristics of value
solutions.
The individuals were no selected are eliminated.
Types:
Roulette (proportional selection)
By Ranking
By Tournament
28
Roulette
Probability
x f(x) p cumulative
5 55 0.55 0.55
2 5 0.05 0.6
7 25 0.25 0.85
0 15 0.15 1
Total 100
Crossovers
This operation allows to Exchange the genetic
information stored in the selected population
(parents) in order to create better individuals.
One point crossover
Two points and n points crossover
Uniform crossover
Arithmetic crossover
Permutation crossover
29
Mutation
Apply to each son the mutation operator
In a simple mutation, only one gen (bit) is changed
from 0 to 1, o viceversa with a probability pmut.
Some ideas:
Change one bit randomly
Exchange a pair of bits.
30
Generational Substitution
In a Simple GA the complete generational substitution
used. In this case the selected parents and their sons
replace to the previous generation.
34
Example
Determine the maximum value of the function y=x2
X=[0,255]
x∈X
32
Initial population
Initial Codification f(x) Value (Fitness
Population (Genotype) function)
(Phenotype)
1 18 00010010 324
2 78 01001110 6084
3 232 11101000 53824
4 186 10111010 34596
5 66 01000010 4356
6 9 00001001 81
7 27 00011011 729
8 126 01111110 15876
Sum 115870
Average 14483.75
The Best 53824
36
Selection
Initial Codification f(x) Value (Fitness
Population (Genotype) function)
(Phenotype)
1 18 00010010 324
2 78 01001110 6084
3 232 11101000 53824
4 186 10111010 34596
5 66 01000010 4356
6 9 00001001 81
7 27 00011011 729
8 126 01111110 15876
Sum 115870
Average 14483.75
The best 53824
37
One point Crossover
Initial Codification The sons
Population (Genotype)
(Phenotype)
3 232 11101000 11111010
4 186 10111010 10101000
8 126 011 11110 01101110
2 78 010 01110 01011110
38
Mutation
Initial Codification The sons
Population (Genotype)
(Phenotype)
3 232 11101000 11111010
4 186 10111010 10101000
8 126 011 11110 01101110
2 78 010 01110 11011110
39
New generation (sons+parents)
Initial Codification f(x) Value (Fitness
Population (Genotype) function)
(Phenotype)
1 232 11101000 53824
2 186 10111010 34596
3 126 011 11110 15876
4 78 010 01110 6084
5 250 11111010 62500
6 168 10101000 28224
7 110 01101110 12100
8 222 11011110 49284
Sum 262488
Average 32811
The best 62500
40
¿How to know if the GA is working
well?
The most common way is using the average
performance of the population to evaluate the
performance of the GA
41