⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scale.sga

📁 Pascal Programs Printed in GENETIC ALGORITHMS IN SEARCH, OPTIMIZATION, AND MACHINE LEARNING by Da
💻 SGA
字号:
{ scale.sga: contains prescale, scale, scalepop for scaling fitnesses }procedure prescale(umax, uavg, umin:real; var a, b:real);{ Calculate scaling coefficients for linear scaling }const fmultiple = 2.0;     { Fitness multiple is 2 }var   delta:real;          { Divisor }begin if umin > (fmultiple*uavg - umax) / (fmultiple - 1.0) { Non-negative test }     then begin  { Normal Scaling }       delta := umax - uavg;       a := (fmultiple - 1.0) * uavg / delta;       b := uavg * (umax - fmultiple*uavg) / delta;      end else begin   { Scale as much as possible }        delta := uavg - umin;        a := uavg / delta;        b := -umin * uavg / delta;       end;end;function scale(u, a, b:real):real;{ Scale an objective function value }begin  scale := a * u + b end;procedure scalepop(popsize:integer; var max, avg, min, sumfitness:real;                   var pop:population);{ Scale entire population }var j:integer;    a, b:real;    { slope & intercept for linear equation }begin prescale(max, avg, min, a, b);  { Get slope and intercept for function } sumfitness := 0.0; for j := 1 to popsize do with pop[j] do begin   fitness := scale(objective, a, b);   sumfitness := sumfitness + fitness;  end;end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -