-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathscaling.m
48 lines (43 loc) · 1.18 KB
/
scaling.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
% SCALING.m - linear fitness scaling
%
% This function implements a linear fitness scaling algorithm as described
% by Goldberg in "Genetic Algorithms in Search, Optimization and Machine
% Learning", Addison Wesley, 1989. It use is not recommended when fitness
% functions produce negative results as the scaling will become unreliable.
% It is included in this version of the GA Toolbox only for the sake of
% completeness.
%
% Syntax: FitnV = scaling(ObjV, Smul)
%
% Input parameters:
%
% Objv - A vector containing the values of individuals
% fitness.
%
% Smul - Optional scaling parameter (default 2).
%
% Output parameters:
%
% FitnV - A vector containing the individual fitnesses
% for the current population.
%
% Author: Andrew Chipperfield
% Date: 24-Feb-94
function FitnV = scaling( ObjV, Smul )
if nargin == 1
Smul = 2 ;
end
[Nind, Nobj] = size( ObjV ) ;
Oave = sum( ObjV ) / Nind ;
Omin = min( ObjV ) ;
Omax = max( ObjV ) ;
if (Omin > ( Smul * Oave - Omax ) / ( Smul - 1.0 ))
delta = Omax - Oave
a = ( Smul - 1.0 ) * Oave / delta
b = Oave * ( Omax - Smul * Oave ) / delta
else
delta = Oave - Omin ;
a = Oave / delta ;
b = -Omin * Oave / delta ;
end
FitnV = ObjV.*a + b ;