630 likes | 1.09k Views
Genetic Algorithms Revisited. Advantages and disadvantages of GAs Example of strategy evolution GAs and permutation based problems Evolver software Genetic programming Examples of GP utilization. Creation of a new population. Selection. Reproduction. Genetic algorithms.
E N D
Genetic Algorithms Revisited • Advantages and disadvantages of GAs • Example of strategy evolution • GAs and permutation based problems • Evolver software • Genetic programming • Examples of GP utilization
Creation of a new population Selection Reproduction Genetic algorithms New population Initial population
Advantages of GA • General tool applicable to a wide spectrum of problems • Very easy to understand • Very easy to implement and to customize • Robust and faul-tolerant • Minimal mathematical requirements on fitness function features
Disadvantages of GA • Too general – too many different encodings, operators, selection schemes, parameters to set up etc. • The quality of result cannot be guaranteed • Computationally intensive • Very popular and modern, considered as a tool suitable to tackle almost any problem • The underlying theory is missing
Strategy Evolution Game Playing very popular amongst AI community various approaches have been developed various games have been tackled simple rules huge search space the optimal (winning) strategy is known great opportunity to test new approaches
Game of NIM N (N>0) stones are placed on the table two players alternate to remove m stones in each step (m{1,..,k}) k>0 restricts the maximal number of stones to be taken in one step the player that takes the last stone looses the game
Game of NIM simple winning strategycan be easily found the last stone must be taken by our opponent he can take 1 up to k stones in one step it is easy for the second player to make sure that (k+1) stones will disappear in each run if there are (k+1)*r+1 stones on the table (r>0) it is the winning strategy for the second player
Number of stones (N) Number of strategies (k=4) Number of strategies (k=5) Number of strategies (k=6) 30 1,08E+17 3,58E+19 3,41E+21 40 1,13E+23 3,49E+26 2,06E+29 50 1,19E+29 3,41E+33 1,25E+37 Game of NIM size of the search space
GA Implementation chromosome consists of N genes i-th allele represents the relevant decision (number of stones to be taken) N=21, k = 5 optimal strategy for the second player: [1,1,2,3,4,5,#,1,2,3,4,5,#,1,2,3,4,5,#,1,2,3,4,5,#]
GA Implementation fitness clearly must depend on the ability of the individual to compete with others various approaches can be utilised entire population is used random sample “hall of fame” approach one/two-point crossover and random mutation
Improving Performance it worked, but it was slow various attempts to empower the algorithm “All is well that ends well” Amongst mediocre strategies the better ones are those where end-game is more developed.
Macromutation Operator Keep it as it is! Increase variability here! headless chicken crossover one parent from the population is crossed over with a randomly created individual the offspring is kept only if it is better than its parent
The number of generations needed to find optimal strategy(100 test runs) – GA without macromutation operator - GA empowered by the macromutation operator
Travelling Salesman Problem Definition of TSP • There are N cities and given distances between them. • Travelling salesman has to visit all of them. • It is impossible to visit any city twice. • Find a sequence of cities to minimise travelled distance.
Travelling Salesman Problem Order Based Encoding • chromosome expresses the order of cities in which salesman will visit them [Athens, Roma, Madrid, ..., Dublin] • if we assume the substitution Athens = 1, Brussels = 2, etc., we can simplify it to [1,5,8,14,2,4,6,11,8,9,10,12,7,13,15,3]
Travelling Salesman Problem Crossover Problem • in some cases “eligible” parents can produce “ineligible” offspring Parents Offspring [1,2,3,4, | 5,6] [1,2,3,4, | 1,2] [3,4,5,6, | 1,2] [3,4,5,6, | 5,6] • it has to be repaired - reordering operators
Travelling Salesman Problem Order Crossover (OX) Parent Offspring [1,2,3,4, | 5,6] [1,2,3,4, | 5,2] [1,_,_,_, | _,_] [1,_,_,_, | 5,2] [_,x,_,_, | _,_] [1,_,_,_, | 5,2] [_,_,3,_, | _,_] [1,3,_,_, | 5,2] [_,_,_,4, | _,_] [1,3,4,_, | 5,2] [_,_,_,_, | x,_] [1,3,4,_, | 5,2] [_,_,_,_, | _,6] [1,3,4,6, | 5,2]
Travelling Salesman Problem Mutation • exchange two randomly selected genes [ 1, 2, 3, 4, 5, 6] [ 1, 2, 5, 4, 3, 6] Inversion • reverse part of the chromosome [ 1, 2, | 3, 4, 5, | 6] [ 1, 2, | 5, 4, 3, | 6]
Evolver Genetic optimization package Add-in to MS Excel Easy to use Easy to customize www.palisade.com
Genetic Programming • Extension of genetic algorithms • Chromosomes are not fixed-length strings any more, but hierarchically structured computer programs that are candidate solutions to a given problem when executed • Computer programs are not represented as lines of code, but rather as the relevant parse tree
Encoding Example The parse tree for expression x*ln(x) - y*z [ -:2, *:2, x, ln:1, x, *:2, y, z]
Encoding Example The parse tree for expression x+IF(t>0,y,z) [ +:2, x, IF:3, >:2, t, 0, y, z]
Knowledge Discovery Symbolic regression • the goal is to find a function in a symbolic form that fits a given finite sample of data • such a function can be viewed as a computer program that takes the values of independent variables (as input) and produces the value of dependent variable (output)
Knowledge Discovery • Let us consider a circuit containing two resistors connected in parallel. • Using the Kirchhoff’s Current Law and Ohm’s Law we can easily obtain the formula for calculating the equivalent circuit resistance • Our aim is to rediscover the formula
Knowledge Discovery • Let us suppose that we did twelve different experiments combining miscellaneous resistors of known resistances
Fitness Definition • We have to execute each individual (program) on input data and to measure the difference between predicted output and the known result where e(i,j) is the value returned by i-th expression for the experiment number j and R(j) is the known result
Fitness Definition • As we assume that the better individual is the fitter one we have to adjust is as • It is clear that f(i) lies between 0 and 1
Results (R1 and R2 only) Statistics of generation number : 0 ----------------------------------------------------- The weakest chromosome : ((r1*r1)*(r2*r1)) : 6.63195200863091E-007 The best chromosome : ((r2+r1)/r2) : 3.24324324324324E-002 Average fitness : 9.44993469399948E-003 r13•r2 1+r1/r2
Results (R1 and R2 only) Statistics of generation number : 3 ----------------------------------------------------- The weakest chromosome : ((r2+r2)/(r2+r1)) : 2.11491011632006E-002 The best chromosome : ((r1/r2)+(r2/r1)) : 3.55450236966825E-002 Average fitness : 2.47651393151945E-002 2•r2/(r1+r2)