26
GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

Embed Size (px)

Citation preview

Page 1: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

GENETIC ALGORITHMS AND GENETIC

PROGRAMMING

Ehsan Khoddam Mohammadi

Page 2: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

DEFINITION OF THE GENETIC ALGORITHM (GA)

The genetic algorithm is a probabilistic search algorithm that iteratively transforms a set (called a population) of mathematical objects (typically fixed-length binary character strings), each with an associated fitness value, into a new population of offspring objects using the Darwinian principle of natural selection and using operations that are patterned after naturally occurring genetic operations, such as crossover (sexual recombination) and mutation.

Page 3: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

Biological Background

• Chromosome (Genome)• Genes• Proteins (A T G C)• Trait• Allele• Natural Selection (survival of fittest)

Page 4: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

GA FLOWCHART

Page 5: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

Which problems could be solved by GA?

• Nonlinear dynamical systems - predicting, data analysis • Designing neural networks, both architecture and

weights • Robot trajectory • Evolving LISP programs (genetic programming) • Strategy planning • Finding shape of protein molecules • TSP and sequence scheduling • َ�All Optimization Problems (Knapsack,Graph coloring,

…)

Page 6: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

GA Operations

• Encodings• Initiate Population• Selection• Reproduction• Crossover (sexual reproduction)• Mutation

Page 7: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

GA Operations (Cont.)ENCODING(1/3)

• Fixed-Length encoding– 1D encoding: arrays, lists, strings,…– 2D encoding: matrices,graphs

• Variable-Length encoding– Tree encoding: binary parser trees like

postfix,infix,…

Page 8: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

GA Operations (Cont.)ENCODING (2/3)

• Permutation Encoding :– Map Coloring problem , TSP,…– Array in size of regions, each cell has an integer

corresponding to available colors.R=1 G=2 B=3 W=4

• Binary Encoding:– Knapsack problem, equation solving ()

Chromosome A 101100101100101011100101 Chromosome B 111111100000110000011111

Page 9: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

GA Operations (Cont.)ENCODING (3/3)

• Tree encoding– Genetic programming, finding function of given

values (elementry system identification)

( + x ( / 5 y ) ) ( do_until step wall )

Page 10: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

GA Operations (Cont.)SELECTION (1/3)

• In GA ,the object is to Maximizing or Minimizing fitness values of population of Chromes.

• Fitness Function should be applicable to any Chromes (bounded).

• Mostly a positive number, showing a distance between present state to goal state.

• In NP-Complete or partially defined problems should relatively be computed .

• Two important parameters :– Population diversity (exploring new areas)– Selective pressure ( degree to which better individuals

are favoured)

Page 11: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

GA Operations (Cont.)SELECTION (2/3)

• Roulette Wheel Selection (improved by Ranking) – [Sum] Calculate sum of all chromosome fitnesses in population - sum S. – [Select] Generate random number from interval (0,S) - r. – [Loop] Go through the population and sum fitnesses from 0 - sum s. When the

sum s is greater then r, stop and return the chromosome where you are

• Not suitable for highly variance populations• Using RANK Selection

– The worst will have fitness 1, second worst 2 etc. and the best will have fitness N (number of chromosomes in population).

– Converge Slowly

1 2

Page 12: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

GA Operations (Cont.)SELECTION (3/3)

• Steady-state Selection (threshold)– Fittest just survived

• Elitism– Fittest selected, for others we use other selection

manners• Boltzmann Selection

– P(E)=exp(-E/kT), like SA. Number of selections reduces in order of growing of age

• Tournament Selection

Page 13: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

F.Nitzche

Page 14: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

GA Operations (Cont.)REPRODUCTION(1/1)

• Reproduction rate• Selected gene transfers directly to new

Generation without any change.

Page 15: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

GA Operations (Cont.)CROSSOVER(1/1)

• CROSSOVER rate• Single Child

– Single-Point11001011+11011111 = 11001111

– Multi-Point

– Uniform– Arithmetic

11001011 + 11011111 = 11001001 (AND)

• Multi Children

Page 16: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

GA Operations (Cont.)MUTATION(1/1)

• Mutation rate• Inversion

• Deletion and Regeneration• …

For TSP is proved that some kind of mutation causes to most efficient solution

11001001 => 10001001

Page 17: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

GA EXTENTIONS (part 1)

• GENETIC PROGRAMMING– solve a problem without explicitly programming– Writing program to compute X^2+X+1

Page 18: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

GENETIC PROGRAMMING

Page 19: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

Genetic Programming (1/4)PREPARATORY STEPS

Objective: Find a computer program with one input (independent variable X) whose output equals the given data

1 Terminal set: T = {X, Random-Constants}

2 Function set: F = {+, -, *, %}

3 Fitness: The sum of the absolute value of the differences between the candidate program’s output and the given data (computed over numerous values of the independent variable x from –1.0 to +1.0)

4 Parameters: Population size M = 4

5 Termination: An individual emerges whose sum of absolute errors is less than 0.1

Page 20: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

Genetic Programming (2/4)initial population

Page 21: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

Genetic Programming (3/4)FITNESS OF THE 4 INDIVIDUALS IN GEN 0

x + 1 x2 + 1 2 x

0.67 1.00 1.70 2.67

Page 22: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

GENETIC PROGRAMMING (4/4)

Copy of (a)

Mutant of (c) picking “2” as mutation point

First offspring of crossover of (a) and (b) picking “+” of parent (a) and left-most “x” of parent (b) as crossover points

Second offspring of crossover of (a) and (b) picking “+” of parent (a) and left-most “x” of parent (b) as crossover points

Page 23: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

REPRESENTATIONS

• Decision trees• If-then production

rules• Horn clauses• Neural nets• Bayesian

networks• Frames• Propositional logic

• Binary decision diagrams

• Formal grammars • Coefficients for

polynomials• Reinforcement

learning tables• Conceptual clusters • Classifier systems

Page 24: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

GA EXTENTIONS (part 2)

• Multi Modal GA• SOCIAL MODEL: religion based• Hybrid Methods ( associate with FL and ANN)• …

Page 25: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

REFRENCES• Neural Networks, Fuzzy Logic and Genetic

Algorithms ,Synthesis and ApplicationsS.RajasekaranG.A.Vijayalakshmi PaiPSG College of Technology,Coimbatore

• http://www.smi.stanford.edu/people/kozaDoctor John R. Koza Department of Electrical EngineeringSchool of EngineeringStanford UniversityStanford California 94305

• http://cs.felk.cvut.cz/~xobitko/ga/Marek Obitko, [email protected]

Page 26: GENETIC ALGORITHMS AND GENETIC PROGRAMMING Ehsan Khoddam Mohammadi

دارند حیات ادامه حق افراد !غالب

تشکر با