12 #ifndef _ga_population_h_
13 #define _ga_population_h_
15 #include <GAEvalData.h>
17 #include <GAScaling.h>
18 #include <GASelector.h>
68 GADefineIdentity(
"GAPopulation", GAID::Population);
107 int size()
const {
return n; }
108 int size(
unsigned int popsize);
109 int chunksize()
const {
return csz; }
110 int chunksize(
unsigned int csize) {
return csz = csize; }
115 rsorted = ssorted = selectready = divved = statted = scaled =
118 void statistics(
bool flag =
false)
const;
119 void diversity(
bool flag =
false)
const;
120 void scale(
bool flag =
false)
const;
121 void prepselect(
bool flag =
false)
const;
122 void sort(
bool flag =
false, SortBasis basis = RAW)
const;
180 float div(
unsigned int i,
unsigned int j)
const
186 return indDiv[i * n + j];
237 int nevals()
const {
return neval; }
238 void evaluate(
bool flag =
false)
240 if (evaluated ==
false || flag ==
true)
244 scaled = statted = divved = rsorted = ssorted =
false;
248 Evaluator evaluator()
const {
return eval; }
249 Evaluator evaluator(Evaluator e)
260 Initializer initializer()
const {
return init; }
261 Initializer initializer(Initializer i) {
return init = i; }
262 SortOrder order()
const {
return sortorder; }
263 SortOrder order(SortOrder flag);
270 return slct->select();
277 This->scaled =
false;
284 void *userData()
const {
return ud; }
285 void *userData(
void *u) {
return (ud = u); }
286 GAEvalData *evalData()
const {
return evaldata; }
290 evaldata = o.clone();
294 GAGenome &best(
unsigned int i = 0, SortBasis basis = RAW)
const
301 return ((basis == RAW) ? *(rind[i]) : *(sind[i]));
303 GAGenome &worst(
unsigned int i = 0, SortBasis basis = RAW)
const
310 return ((basis == RAW) ? *(rind[n - 1 - i]) : *(sind[n - 1 - i]));
312 GAGenome &individual(
unsigned int i, SortBasis basis = RAW)
const
314 return ((basis == RAW) ? *(rind[i]) : *(sind[i]));
319 GAGenome *remove(
int which = WORST, SortBasis basis = RAW);
323 void destroy(
int w = WORST, SortBasis b = RAW) {
delete remove(w, b); }
325 virtual void read(std::istream &) {}
326 virtual void write(std::ostream &os, SortBasis basis = RAW)
const;
340 float rawSum, rawAve;
341 float rawMax, rawMin;
342 float rawVar, rawDev;
347 float fitSum, fitAve;
348 float fitMax, fitMin;
349 float fitVar, fitDev;
358 int grow(
unsigned int);
360 static void QuickSortAscendingRaw(
GAGenome **,
int,
int);
361 static void QuickSortDescendingRaw(
GAGenome **,
int,
int);
362 static void QuickSortAscendingScaled(
GAGenome **,
int,
int);
363 static void QuickSortDescendingScaled(
GAGenome **,
int,
int);
366 inline std::ostream &operator<<(std::ostream &os,
const GAPopulation &arg)
371 inline std::istream &operator>>(std::istream &is,
GAPopulation &arg)
This is the basic interface for the object that contains evaluation data.
Definition: GAEvalData.h:15
The base GA class is virtual - it defines the core data elements and parts of the interface that are ...
Definition: GABaseGA.h:89
The base genome class just defines the genome interface - how to mutate, crossover,...
Definition: GAGenome.h:200
This defines the identifiers for polymorphic classes.
Definition: gaid.h:20
Definition: GAPopulation.h:66
Definition: GAScaling.h:46
Definition: GASelector.h:55