Sushil J. Louis
Dept. of Computer Science
University of Nevada, Reno
We want to maintain an even selection pressure throughout the genetic algorithm's processing.
Neither is desirable. Thus we may want to scale the fitness so that selection pressure remains the same throughout the run. Let us formulate the problem in the following way:
where is the scaled maximum fitness, is the average fitness of the population, and is a scaling constant that specifies the expected number of copies of the best individual in the next generation. Increasing will increase selection ``pressure'' (bias towards best individual and quicker convergence), decreasing will decrease selection pressure.
We can calculate the linear coefficients and from the constraint equations above. However, it is possible for the scaled fitness to go below . What do we do? We map to . The pascal code for doing this is given in the book on page 79.
#include "type.h" void FindCoeffs(IPTR pop, Population *p); void Scalepop(IPTR pop, Population *p) { /* linearly scale the population */ IPTR pj; int i; FindCoeffs(pop, p); p->scaledSumFitness = 0.0; for(i = 0; i < p->popsize; i++){ pj = &pop[i]; pj->scaledFitness = p->scaleConstA * pj->fitness + p->scaleConstB; p->scaledSumFitness += pj->scaledFitness; } } void FindCoeffs(IPTR pop, Population *p) { /* find coeffs scale_constA and scale_constB for linear scaling according to f_scaled = scale_constA * f_raw + scale_constB */ double d; if(p->min > (p->scaleFactor * p->avg - p->max)/ (p->scaleFactor - 1.0)) { /* if nonnegative smin */ d = p->max - p->avg; p->scaleConstA = (p->scaleFactor - 1.0) * p->avg / d; p->scaleConstB = p->avg * (p->max - (p->scaleFactor * p->avg))/d; } else { /* if smin becomes negative on scaling */ d = p->avg - p->min; p->scaleConstA = p->avg/d; p->scaleConstB = -p->min * p->avg/d; } if(d < 0.00001 && d > -0.00001) { /* if converged */ p->scaleConstA = 1.0; p->scaleConstB = 0.0; } }
This document was generated using the LaTeX2HTML translator Version 2002-2-1 (1.71)
Copyright © 1993, 1994, 1995, 1996,
Nikos Drakos,
Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999,
Ross Moore,
Mathematics Department, Macquarie University, Sydney.
The command line arguments were:
latex2html -split 1 scaling.tex
The translation was initiated by Sushil Louis on 2004-09-22