Vous êtes sur la page 1sur 3

Artificial Intelligence & Internal Representation Chapter 7

COMPUTER IMPLEMENTATION OF A GENETIC ALGORITHM It is disturbing initially. Due to o Coding o Population not individuals. o Randomness giving direction.

GENETIC ALGORITHM IMPLEMENTATION Data Structure o Strings by arrays, o Specify o Population size o String size o Probability of mutation o Probability of crossover Reproduction o Through roulette wheel selection method. o Take a partial sum of the fitness values. o Generate a random number to specify the location where the wheel has stopped. o Correspondingly select that string to be in the population. Crossover o Take two parents randomly. o Generate a random number between 1 and l-1. o This is crossover site. o Exchange bits from that site onwards. o Two off-springs are generated. Mutation o Generate a random number to select a string for mutation. o Generate a random number to select a bit for mutation. o Change the bit of that position. o Generating a new offspring. Fitness Function o Choose a proper fitness function. o A strings suitability in the next population is judged based on this. GOOD GENETIC ALGORITHM: EXPERIMENTS SHOW Choose high crossover probability. Choose low mutation probability. Choose moderate population size say 30. GENETIC ALGORITHM DRAWBACK: PREMATURE CONVERGENCE Procedure may optimize. But not globally. Resulting in converging points prematurely. MAPPING OBJECTIVE FUNCTION TO FITNESS FUNCTION Objective of some problems is to minimize a function say cost g(x).
Lecture Notes By Prof. Siby Abraham Page 1 of 3

Artificial Intelligence & Internal Representation Chapter 7

Then take f(x) = Cmax g(x) where g(x) < Cmax is the largest cost observed till then. For maximization function, take f(x) = u(x) + Cmin

FITNESS SCALING At start of Genetic Algorithm: some better fitter strings among inferiors. Within a few generations, the superior ones will become dominant. This may lead to premature convergence. Later though diverse, almost all may have almost same fitness. This may lead to average and superior ones get same copies in the next population. Survival of the fittest becomes a random walk, which needs to be avoided. Strategy to avoid scaling. LINEAR SCALING f = a f + b (a & b are to be found) Always take: o favg = favg o fmin = fmin o 2 * favg = fmax o fmax = Cmult . favg Where Cmult = expected number of copies of best in the next population. BECAUSE OF SCALING Number of extraordinary best ones is restricted. Number of lowly ones increases. In mature run, a few bad strings may have below population average. If scaling is applied here, the low fitness values can go negative, which is undesired. In that case, take fmin = fmin = 0. Scaling helps to prevent early dominance of a few best ones and encourages healthy competition among equals. CODING IN GENETIC ALGORITHM Different methods. Which to select ? Two guidelines o Principle of meaningful building blocks The user should select a coding so that short order schemata are relevant to the underlying problem and relatively unrelated to schemata over other fixed positions. o Principle of minimal alphabets The user should select the smallest alphabet that permits a natural expression of the problem. CODING: BINARY VS. NON-BINARY E.g. f(x) = maximize x2 on [0, 31] Binary Representation 01101 11000 01001 10011
Lecture Notes By Prof. Siby Abraham

32-Alphabet Representation N Y I T
Page 2 of 3

Artificial Intelligence & Internal Representation Chapter 7

There are non coding similarities to be exploited in non-binary.

DISCRETIZATION OF CONTINUM Many optimization problems require functions over a continum. This can be converted into a finite collection of discrete problems which can then be solved using Genetic Algorithm. CONSTRAINTS Genetic Algorithm generally used for unconstrained problems. Genetic Algorithm can be used for constrained problems too. This can be done by incorporating a penalty in the objective function as and when the constraints are violated.

Lecture Notes By Prof. Siby Abraham

Page 3 of 3

Vous aimerez peut-être aussi