10 #include <GAPopulation.h>
15 extern int gaDefNumBestGenomes;
16 extern int gaDefScoreFrequency1;
17 extern int gaDefScoreFrequency2;
18 extern int gaDefFlushFrequency;
19 extern std::string gaDefScoreFilename;
53 float online()
const {
return on; }
54 float offlineMax()
const {
return offmax; }
55 float offlineMin()
const {
return offmin; }
56 float initial(
int w = Maximum)
const;
57 float current(
int w = Maximum)
const;
58 float maxEver()
const {
return maxever; }
59 float minEver()
const {
return minever; }
61 int generation()
const {
return curgen; }
62 unsigned long int selections()
const {
return numsel; }
63 unsigned long int crossovers()
const {
return numcro; }
64 unsigned long int mutations()
const {
return nummut; }
65 unsigned long int replacements()
const {
return numrep; }
66 unsigned long int indEvals()
const {
return numeval; }
67 unsigned long int popEvals()
const {
return numpeval; }
68 float convergence()
const;
70 int nConvergence()
const {
return Nconv; }
71 int nConvergence(
unsigned int);
72 int nBestGenomes(
const GAGenome &,
unsigned int);
73 int nBestGenomes()
const {
return (
boa !=
nullptr ?
boa->size() : 0); }
74 int scoreFrequency(
unsigned int x) {
return (scoreFreq = x); }
75 int scoreFrequency()
const {
return scoreFreq; }
76 int flushFrequency(
unsigned int x);
77 int flushFrequency()
const {
return Nscrs; }
78 std::string scoreFilename(
const std::string &filename);
79 std::string scoreFilename()
const {
return scorefile; }
80 int selectScores(
int w) {
return which = w; }
81 int selectScores()
const {
return which; }
82 bool recordDiversity(
bool flag) {
return dodiv = flag; }
83 bool recordDiversity()
const {
return dodiv; }
89 const GAGenome &bestIndividual(
unsigned int n = 0)
const;
91 int scores(
const std::string &filename,
int which = NoScores);
92 int scores(std::ostream &os,
int which = NoScores);
93 int write(
const std::string &filename)
const;
94 int write(std::ostream &os)
const;
99 unsigned long int numsel;
100 unsigned long int numcro;
101 unsigned long int nummut;
102 unsigned long int numrep;
103 unsigned long int numeval;
104 unsigned long int numpeval;
108 unsigned int scoreFreq;
129 unsigned int nconv, Nconv;
153 void setConvergence(
float);
155 void updateBestIndividual(
const GAPopulation &,
bool flag =
false);
157 void resizeScores(
unsigned int);
162 inline std::string GAStatistics::scoreFilename(
const std::string &filename)
168 inline float GAStatistics::convergence()
const
171 if (nconv >= Nconv - 1 && cscore[nconv % Nconv] != 0) {
172 cnv =
static_cast<double>(cscore[(nconv + 1) % Nconv]) /
173 static_cast<double>(cscore[nconv % Nconv]);
175 return static_cast<float>(cnv);
178 inline float GAStatistics::initial(
int w)
const
204 inline float GAStatistics::current(
int w)
const
230 inline std::ostream &operator<<(std::ostream &os,
const GAStatistics &s)
The base genome class just defines the genome interface - how to mutate, crossover,...
Definition: GAGenome.h:200
Definition: GAPopulation.h:66
Statistics class.
Definition: GAStatistics.h:30
std::string scorefile
name of file to which scores get written
Definition: GAStatistics.h:147
GAPopulation * boa
keep a copy of the best genomes
Definition: GAStatistics.h:151
std::vector< float > aveScore
average scores of each generation
Definition: GAStatistics.h:137
unsigned int nscrs
how many scores do we have?
Definition: GAStatistics.h:133
std::vector< float > devScore
stddev of each generation
Definition: GAStatistics.h:143
std::vector< float > divScore
diversity of each generation
Definition: GAStatistics.h:145
std::vector< float > minScore
worst scores of each generation
Definition: GAStatistics.h:141
std::vector< int > gen
generation number corresponding to scores
Definition: GAStatistics.h:135
std::vector< float > maxScore
best scores of each generation
Definition: GAStatistics.h:139
int which
which data to write to file
Definition: GAStatistics.h:149