This file is indexed.

/usr/include/ga/GAScaling.h is in libga-dev 1:2.4.7-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
// $Header$
/* ----------------------------------------------------------------------------
  scaling.h
  mbwall 10aug94
  Copyright (c) 1995 Massachusetts Institute of Technology
                     all rights reserved

 DESCRIPTION:
  This is the GAScaling class.  It is used to do scaling on a population.  When
a genome is evaluated, the user's objective function provides an overall
rating for each genome.  The GA is concerned with fitness, not objective
score (unless you do no scaling).  So this object is the container for the
scaled values.
  Examples of scaling include linear scaling, sigma truncation, and power law.
Goldberg's sharing function is also a type of scaling, and it is implemented 
here as a unique class.
  The scaling class is designed to be used with a population.  It is stupid -
it does know how to update itself, but it must be told when.
---------------------------------------------------------------------------- */
#ifndef _ga_scaling_h_
#define _ga_scaling_h_

#include <ga/gaconfig.h>
#include <ga/gaid.h>
#include <ga/gatypes.h>
#include <ga/GAGenome.h>

class GAPopulation;

extern float gaDefLinearScalingMultiplier;
extern float gaDefSigmaTruncationMultiplier;
extern float gaDefPowerScalingFactor;
extern float gaDefSharingCutoff;


/* ----------------------------------------------------------------------------
Scaling

  The scaling object is used to scale the objective scores of a population to
avoid clustering and premature convergence (among other things).  See golberg
for more about the theory.  This is basically just a container for any data
that the scaling object might need to do its thing.  The simplest scalings
don't store any data.
---------------------------------------------------------------------------- */
class GAScalingScheme : public GAID {
public:
  GADefineIdentity("GAScalingScheme", GAID::Scaling);

  GAScalingScheme() {}
  GAScalingScheme(const GAScalingScheme& s) { copy(s); }
  GAScalingScheme& operator=(const GAScalingScheme& s) {copy(s); return *this;}
  virtual ~GAScalingScheme() { }
  virtual GAScalingScheme * clone() const=0;
  virtual void copy(const GAScalingScheme &) {}
  virtual void evaluate(const GAPopulation & p)=0;
};


/* ----------------------------------------------------------------------------
NoScaling
---------------------------------------------------------------------------- */
class GANoScaling : public GAScalingScheme {
public:
  GADefineIdentity("GANoScaling", GAID::NoScaling);

  GANoScaling() : GAScalingScheme() {}
  GANoScaling(const GANoScaling &) : GAScalingScheme() {}
  GANoScaling& operator=(const GAScalingScheme&){ return *this; }
  virtual ~GANoScaling(){}
  virtual GAScalingScheme * clone() const {return new GANoScaling(*this);}
  virtual void evaluate(const GAPopulation & p);
};


/* ----------------------------------------------------------------------------
LinearScaling

  This scaling object does linear scaling as described in goldberg pp 122-124.
---------------------------------------------------------------------------- */
#if USE_LINEAR_SCALING == 1
class GALinearScaling : public GAScalingScheme {
public:
  GADefineIdentity("GALinearScaling", GAID::LinearScaling);

  GALinearScaling(float fm=gaDefLinearScalingMultiplier) {multiplier(fm);}
  GALinearScaling(const GALinearScaling & arg) {copy(arg);}
  GALinearScaling & operator=(const GAScalingScheme & arg)
    {copy(arg); return(*this);}
  virtual ~GALinearScaling(){}
  virtual GAScalingScheme * clone() const {return new GALinearScaling(*this);}
  virtual void evaluate(const GAPopulation & p);
  virtual void copy(const GAScalingScheme & arg){
    if(&arg != this){
      GAScalingScheme::copy(arg);
      c=(DYN_CAST(const GALinearScaling&,arg)).c;
    }
  }

  float multiplier(float fm);
  float multiplier() const {return c;}

protected:
  float c;			// linear scaling multiplier
};
#endif



/* ----------------------------------------------------------------------------
SigmaTruncationScaling

  This scaling object does sigma truncation as defined in goldberg p124.
---------------------------------------------------------------------------- */
#if USE_SIGMA_TRUNC_SCALING == 1
class GASigmaTruncationScaling : public GAScalingScheme {
public:
  GADefineIdentity("GASigmaTruncationScaling", GAID::SigmaTruncationScaling);

  GASigmaTruncationScaling(float m=gaDefSigmaTruncationMultiplier)
    {multiplier(m);}
  GASigmaTruncationScaling(const GASigmaTruncationScaling & arg){copy(arg);}
  GASigmaTruncationScaling & operator=(const GAScalingScheme & arg)
    {copy(arg); return(*this);}
  virtual ~GASigmaTruncationScaling(){}
  virtual GAScalingScheme * clone() const 
    {return new GASigmaTruncationScaling(*this);}
  virtual void evaluate(const GAPopulation & p);
  virtual void copy(const GAScalingScheme & arg){
    if(&arg != this){
      GAScalingScheme::copy(arg);
      c=(DYN_CAST(const GASigmaTruncationScaling&,arg)).c;
    }
  }

  float multiplier(float fm);
  float multiplier() const {return c;}

protected:
  float c;			// std deviation multiplier
};
#endif



/* ----------------------------------------------------------------------------
PowerLawScaling

  This scaling object does power law scaling as defined in goldberg p124.
---------------------------------------------------------------------------- */
#if USE_POWER_LAW_SCALING == 1
class GAPowerLawScaling : public GAScalingScheme {
public:
  GADefineIdentity("GAPowerLawScaling", GAID::PowerLawScaling);

  GAPowerLawScaling(float f=gaDefPowerScalingFactor) {k = f;}
  GAPowerLawScaling(const GAPowerLawScaling & arg) {copy(arg);}
  GAPowerLawScaling & operator=(const GAScalingScheme & arg)
    {copy(arg); return(*this);}
  virtual ~GAPowerLawScaling(){}
  virtual GAScalingScheme * clone() const 
    {return new GAPowerLawScaling(*this);}
  virtual void evaluate(const GAPopulation & p);
  virtual void copy(const GAScalingScheme & arg){
    if(&arg != this){
      GAScalingScheme::copy(arg);
      k=(DYN_CAST(const GAPowerLawScaling&,arg)).k;
    }
  }

  float power(float p){return k=p;}
  float power() const {return k;}

protected:
  float k;			// power scaling factor
};
#endif



/* ----------------------------------------------------------------------------
Sharing

  This scaling object does sharing as described in goldberg p 192.  This 
implementation does triangular sharing with the (optional) alpha parameter for
changing the curvature of the sharing range and the (required) sigma parameter
for controlling the range of influence.  If you want a different type of 
sharing function, then derive from this class and define a new (virtual)
evaluate method and add whatever member data you need to specify the shape
of your sharing function.
  We use the distance function to scale the objective scores of the 
genomes so that if there are many similar genomes in a population 
their scores will be decreased, thus giving sub-species a greater chance to 
reproduce.
  This sharing function is defined as follows:

                     /
                    |  1 - (d(i,j)/sigma) ^ alpha       d(i,j) < sigma
        s(d(i,j)) = |
                    |  0                                d(i,j) >= sigma
                     \

  where d is the distance between any two individuals and is defined such 
that d(i,j) = 0 means that individuals i and j are identical.  d() has no
upper bound, but it is never negative.
  The alpha controls the shape of the sharing function.  When alpha=1 then
the 'curve' is a straight line.  If alpha is < 1 then the curves are concave,
if alpha is > 1 then the curves are convex.
  If you decide to use this type of sharing, be careful of the sigma value 
that you use.  It can make a HUGE difference, depending upon the objective.
  Distance functions are independent of the sharing functions (as defined in
Goldberg, that is).
  A similarity (distance) function is used with the sharing object.  It is a 
type of speciation (similar in functionality to DeJong crowding, but this uses
fitness scaling rather than replacement strategy to affect the speciation).
If the genomes are identical, the similarity function should return a value of
0.0, if completely different then return a value of 1.0.  0 means less 
diversity means all genomes are the same.
  You can specify whether the scaling should be maximize or minimize based.
If you are maximizing, the scaling will divide the raw score by the scaling 
factor.  If you are minimizing, the scaling will multiply the score by the
scaling factor.  (By definition, the scaling factor will always be >= 1.0)
  By default, the scaling object uses the max/min settings that it contains
(so you can set the scaling independently of the GA).  If the scaling's min/max
was not set, then it tries to use the min/max settings in the GA that owns
the population to which the scaling object is attached.  If there is no GA, 
then it bases its min/max on the sort order of the population.
  You can set the minimaxi to:

    GA::MINIMIZE - scale by multiplying the raw scores
    GA::MAXIMIZE - scale by dividing the raw scores
    0            - minimize or maximize based upon the GA's settings

*** This should be called TriangularSharing rather than simply Sharing.
---------------------------------------------------------------------------- */
#if USE_SHARING == 1
class GASharing : public GAScalingScheme {
public:
  GADefineIdentity("GASharing", GAID::Sharing);

  GASharing(GAGenome::Comparator func, 
	    float cut=gaDefSharingCutoff, float a=1.0)
    { N=0; d=(float*)0; df=func; _sigma = cut; _alpha = a; _minmax = 0; }
  GASharing(float cut=gaDefSharingCutoff, float a=1.0)
    { N=0; d=(float*)0; df=0; _sigma = cut; _alpha = a; _minmax = 0; }
  GASharing(const GASharing & arg) { N=0; d=(float*)0; copy(arg); }
  GASharing & operator=(const GAScalingScheme & arg){copy(arg); return(*this);}
  virtual ~GASharing(){ delete [] d;}
  virtual GAScalingScheme * clone() const {return new GASharing(*this);}
  virtual void copy(const GAScalingScheme & arg);
  virtual void evaluate(const GAPopulation & p);

  GAGenome::Comparator distanceFunction(GAGenome::Comparator f){return df=f;}
  GAGenome::Comparator distanceFunction() const {return df;}

  float sigma(float);
  float sigma() const { return _sigma; }

  float alpha(float c) { return _alpha = c; }
  float alpha() const { return _alpha; }

  int minimaxi(int i);
  int minimaxi() const { return _minmax; }

protected:
  GAGenome::Comparator df;		// the user-defined distance function
  unsigned int N;			// how many do we have? (n of n-by-n)
  float *d;				// the distances for each genome pair
  float _sigma;				// absolute cutoff from central point
  float _alpha;				// controls the curvature of sharing f
  int _minmax;				// should we minimize or maximize?
};
#endif


#endif