ECF 1.5
StatCalc.h
1#ifndef STATCALC_H_
2#define STATCALC_H_
3
4
5namespace ECF
6{
7
8// constants for statistic values reference
9enum stats
10 { FIT_MIN, FIT_MAX, FIT_AVG, FIT_DEV, STAT_SIZE, STAT_TIME, STAT_EVAL, FIT_LOW, FIT_HIGH };
11
12}
13
14
19class StatCalc : public Operator
20{
21private:
22 uint statNo;
23 std::vector<double> average_;
24 std::vector<double> stdDev_;
25 std::vector<double> max_;
26 std::vector<double> min_;
27 std::vector<uint> sampleSize_;
28 std::vector<uint> time_;
29 std::vector<uint> evaluations_;
30 double lowest_;
31 double highest_;
32 uint nEvaluations_;
33 StateP state_;
34 std::string statsFileName_;
35 std::ofstream statsFile_;
36
37public:
38 StatCalc();
39
40 bool operate(StateP)
41 { return false; }
42
43 bool operate(const std::vector<IndividualP>&);
44 void registerParameters(StateP);
45 bool initialize(StateP);
46 bool update(std::vector<double>);
47 void log(int generation = -1);
48 std::vector<double> getStats(int generation = -1);
49 void output(uint step);
50 void copyStats(StatCalcP);
51
52 double getFitnessMin(int generation = -1);
53 double getFitnessMax(int generation = -1);
54
58 uint increaseEvaluations(uint eval = 1)
59 {
60 nEvaluations_ += eval;
61 return nEvaluations_;
62 }
63
67 void setEvaluations(uint eval)
68 { nEvaluations_ = eval; }
69
74 { return nEvaluations_; }
75
80 { return lowest_; }
81
86 { return highest_; }
87
88};
89typedef boost::shared_ptr<StatCalc> StatCalcP;
90
91#endif /* STATCALC_H_ */
Abstract operator class.
Definition: Operator.h:11
Statistics calculation class.
Definition: StatCalc.h:20
uint getEvaluations()
Definition: StatCalc.h:73
bool initialize(StateP)
Perform initialization. Called before Operator::operate. By default, if the return value is false,...
Definition: StatCalc.cpp:19
double getHighestFitness()
Definition: StatCalc.h:85
double getFitnessMax(int generation=-1)
Definition: StatCalc.cpp:59
double getLowestFitness()
Definition: StatCalc.h:79
double getFitnessMin(int generation=-1)
Definition: StatCalc.cpp:48
void registerParameters(StateP)
Register parameters with the Registry. Called before Operator::initialize.
Definition: StatCalc.cpp:13
void log(int generation=-1)
Definition: StatCalc.cpp:228
void setEvaluations(uint eval)
Definition: StatCalc.h:67
bool update(std::vector< double >)
Definition: StatCalc.cpp:153
void copyStats(StatCalcP)
Definition: StatCalc.cpp:132
uint increaseEvaluations(uint eval=1)
Definition: StatCalc.h:58
std::vector< double > getStats(int generation=-1)
Definition: StatCalc.cpp:205
bool operate(StateP)
perform the designated operation
Definition: StatCalc.h:40