00001 #ifndef STATCALC_H_
00002 #define STATCALC_H_
00003
00004
00005 namespace ECF
00006 {
00007
00008
00009 enum stats
00010 { FIT_AVG, FIT_DEV, FIT_MAX, FIT_MIN, STAT_SIZE, STAT_TIME, STAT_EVAL, FIT_LOW, FIT_HIGH };
00011
00012 }
00013
00014
00019 class StatCalc : public Operator
00020 {
00021 private:
00022 uint statNo;
00023 std::vector<double> average_;
00024 std::vector<double> stdDev_;
00025 std::vector<double> max_;
00026 std::vector<double> min_;
00027 std::vector<uint> sampleSize_;
00028 std::vector<uint> time_;
00029 std::vector<uint> evaluations_;
00030 double lowest_;
00031 double highest_;
00032 uint nEvaluations_;
00033 StateP state_;
00034 std::string statsFileName_;
00035 std::ofstream statsFile_;
00036
00037 public:
00038 StatCalc();
00039
00040 bool operate(StateP)
00041 { return false; }
00042
00043 bool operate(const std::vector<IndividualP>&);
00044 void registerParameters(StateP);
00045 bool initialize(StateP);
00046 bool update(std::vector<double>);
00047 void log(int generation = -1);
00048 std::vector<double> getStats(int generation = -1);
00049 void output(uint step);
00050 void copyStats(StatCalcP);
00051
00052 double getFitnessMin(int generation = -1);
00053 double getFitnessMax(int generation = -1);
00054
00058 uint increaseEvaluations(uint eval = 1)
00059 {
00060 nEvaluations_ += eval;
00061 return nEvaluations_;
00062 }
00063
00067 void setEvaluations(uint eval)
00068 { nEvaluations_ = eval; }
00069
00073 uint getEvaluations()
00074 { return nEvaluations_; }
00075
00079 double getLowestFitness()
00080 { return lowest_; }
00081
00085 double getHighestFitness()
00086 { return highest_; }
00087
00088 };
00089 typedef boost::shared_ptr<StatCalc> StatCalcP;
00090
00091 #endif