Go to the documentation of this file.00001
00013 #ifndef LGL_PURSUIT_STATS_HPP
00014 #define LGL_PURSUIT_STATS_HPP
00015
00016 #include <lgl/Stats.hpp>
00017 #include <lgl/PursuitGraph.hpp>
00018
00019 #include <ostream>
00020
00021 namespace jafar {
00022 namespace lgl {
00023
00024 class PursuitStats {
00026
00027 private :
00028
00029 unsigned int rounds ;
00030
00031
00032 Stats< unsigned int> horizon ;
00033
00034
00035 Stats< double > computationTime ;
00036
00037
00038 Stats< unsigned int > front ;
00039
00040
00041 Stats< unsigned int > risk ;
00042
00043
00044 Stats< unsigned int > danger ;
00045
00046
00047 unsigned int cntOK ;
00048 unsigned int cntRISK ;
00049 unsigned int cntDANGER ;
00050
00051 double rateOK ;
00052 double rateRISK ;
00053 double rateDANGER ;
00054
00055
00056 public :
00058 PursuitStats() : rounds(0)
00059 {
00060 cntOK = 0 ;
00061 cntRISK = 0 ;
00062 cntDANGER = 0 ;
00063 }
00064
00065 ~PursuitStats()
00066 { }
00067
00073 void update ( const PursuitGraph *myPG , double _computationTime)
00074 {
00075 rounds ++;
00076
00077
00078 horizon.update( myPG->gethorizon() );
00079
00080 computationTime.update( _computationTime );
00081
00082 front.update( myPG->getfront().size() );
00083 risk.update( myPG->getrisk().size() );
00084 danger.update( myPG->getdanger().size() );
00085
00086
00087 switch ( myPG->getroot()->risk )
00088 {
00089 case SEEN : cntOK++ ; break;
00090 case RISK : cntRISK++ ; break;
00091 case DANGER_HIDDEN :
00092 case DANGER_UNSEEN :
00093 case DANGER_LOST :
00094 case DANGER_DISAPPEARED : cntDANGER++ ; break;
00095 default : ;
00096 }
00097
00098 rateOK = ( cntOK / double(rounds) ) ;
00099 rateRISK = ( cntRISK / double(rounds) ) ;
00100 rateDANGER = ( cntDANGER / double(rounds) ) ;
00101
00102 }
00103
00107 void reset()
00108 {
00109
00110 rounds = 0 ;
00111
00112 cntOK = 0 ;
00113 cntRISK = 0 ;
00114 cntDANGER = 0 ;
00115
00116 }
00117
00120 unsigned int getrounds() const { return (rounds); }
00121
00122 const Stats< unsigned int> * gethorizon() const { return (&horizon); }
00123 const Stats< double > * getcomputationTime() const { return (&computationTime);}
00124
00125 const Stats< unsigned int > * getfront() const { return (&front); }
00126 const Stats< unsigned int > * getrisk() const { return (&risk); }
00127 const Stats< unsigned int > * getdanger() const { return (&danger); }
00128
00129 unsigned int getcntOK() const { return(cntOK); }
00130 unsigned int getcntRISK() const { return(cntRISK); }
00131 unsigned int getcntDANGER() const { return(cntDANGER); }
00132
00133 double getrateOK() const { return(rateOK); }
00134 double getrateRISK() const { return(rateRISK); }
00135 double getrateDANGER() const { return(rateDANGER); }
00136
00137 };
00138
00139
00140 std::ostream& operator<<(std::ostream& out, PursuitStats const &rhs);
00141
00142 }
00143 }
00144
00145 #endif