HOG2
|
The StatCollection class is for collecting stats across different parts of the simulation. More...
#include <StatCollection.h>
Public Member Functions | |
StatCollection () | |
~StatCollection () | |
void | AddStat (const char *category, const char *owner, double value) |
Add a new stat entry for the given category, owner and value. More... | |
void | AddStat (const char *category, const char *owner, long value) |
Add a new stat entry for the given category, owner and value. More... | |
void | SumStat (const char *category, const char *owner, double value) |
Given stats for the category and owner, find an existing stat (chronologically backwards search) with the same category and owner, and add this stat to the existing value. More... | |
void | SumStat (const char *category, const char *owner, long value) |
Given stats for the category and owner, find an existing stat (chronologically backwards search) with the same category and owner, and add this stat to the existing value. More... | |
void | ClearAllStats () |
Remove all stat entries from the collection. More... | |
int | GetNumStats () const |
The number of stats collected so far. More... | |
const statistics * | GetStatNum (int which) const |
Return the nth stat which has been collected. More... | |
int | LookupCategory (const char *category) const |
Given a category, look up the ID. More... | |
int | LookupOwner (const char *owner) const |
Given an owner, look up the ID. More... | |
const char * | lookupCategoryID (int id) const |
Given a category ID, return the text description. More... | |
const char * | LookupOwnerID (int id) const |
Given a owner ID, return the text description. More... | |
bool | LookupStat (const char *category, const char *owner, statValue &) const |
Find the last stat entered that matches the category and owner. More... | |
bool | LookupStat (unsigned int index, statValue &) const |
void | AddFilter (const char *category) |
Adding a filter will cause only stats of the given category to be collected. More... | |
void | AddIncludeFilter (const char *category) |
void | AddExcludeFilter (const char *category) |
void | ClearFilters () |
Clear any filters being used for stat entry. More... | |
void | EnablePrintOutput (bool pO) |
int | FindNextStat (const char *category, const char *owner, int startIndex=0) const |
Find the next stat entry that matches the given category and owner name. More... | |
int | FindPrevStat (const char *category, const char *owner, int startIndex=-1) const |
Find the previous stat entry that matches the given category and owner name. More... | |
int | FindNextStat (const char *what, bool findCategory, int startIndex=0) const |
Find the next stat entry that matches the category if findCategory is true, otherwise look to match the owner name. More... | |
int | FindPrevStat (const char *what, bool findCategory, int startIndex=-1) const |
Find the next stat entry that matches the category if findCategory is true, otherwise look to match the owner name. More... | |
void | PrintStatsTable () const |
Private Member Functions | |
int | addCategory (const char *category) |
Add a new category to the category list. More... | |
int | addOwner (const char *owner) |
Add a new owner to the owner list. More... | |
bool | passFilter (const char *category) const |
Check to see if the category stats should be saved. More... | |
statValue * | getLastStat (const char *category, const char *owner) |
Find the last stat entered that matches the category and owner. More... | |
Private Attributes | |
std::vector< std::string > | categories |
std::vector< std::string > | owners |
std::vector< std::string > | includeFilters |
std::vector< std::string > | excludeFilters |
std::vector< statistics > | stats |
bool | printOutput |
The StatCollection class is for collecting stats across different parts of the simulation.
This class aggregates results and allows access to the collected information.
Definition at line 34 of file StatCollection.h.
StatCollection::StatCollection | ( | ) |
Definition at line 29 of file StatCollection.cpp.
References printOutput.
StatCollection::~StatCollection | ( | ) |
Definition at line 35 of file StatCollection.cpp.
|
private |
Add a new category to the category list.
If the category exists, returns the id. Otherwise creates the category and returns the id.
Definition at line 258 of file StatCollection.cpp.
References categories, and LookupCategory().
Referenced by AddStat().
void StatCollection::AddExcludeFilter | ( | const char * | category | ) |
Definition at line 207 of file StatCollection.cpp.
References excludeFilters.
void StatCollection::AddFilter | ( | const char * | category | ) |
Adding a filter will cause only stats of the given category to be collected.
All other stats added will be ignored. As many categories can be added as needed.
Definition at line 192 of file StatCollection.cpp.
References AddIncludeFilter().
void StatCollection::AddIncludeFilter | ( | const char * | category | ) |
Definition at line 197 of file StatCollection.cpp.
References includeFilters.
Referenced by AddFilter(), and setupAverageRatio().
|
private |
Add a new owner to the owner list.
If the owner exists, returns the id. Otherwise creates the owner and returns the id.
Definition at line 289 of file StatCollection.cpp.
References LookupOwner(), and owners.
Referenced by AddStat().
void StatCollection::AddStat | ( | const char * | category, |
const char * | owner, | ||
double | value | ||
) |
Add a new stat entry for the given category, owner and value.
Definition at line 67 of file StatCollection.cpp.
References addCategory(), addOwner(), floatStored, passFilter(), printOutput, and stats.
Referenced by EpisodicSimulation< state, action, environment >::DoPreTimestepCalc(), GenericPatrolUnit< state, action, environment >::LogFinalStats(), LRTAStar< state, action, environment >::LogFinalStats(), LearningUnit< state, action, environment >::LogFinalStats(), MPLRTA::MPLRTAStar::LogFinalStats(), HLRTA::HLRTAStar< state, action, environment >::LogFinalStats(), DALRTA::daLRTAStar< state, action, environment >::LogFinalStats(), LSSLRTAStar< state, action, environment >::LogFinalStats(), gLSSLRTAStar< state, action, environment >::LogFinalStats(), FLRTA::FLRTAStar< state, action, environment >::LogFinalStats(), GenericPatrolUnit< state, action, environment >::LogStats(), patrolUnit::LogStats(), SearchUnit::LogStats(), GenericSearchUnit< state, action, environment >::LogStats(), LearningUnit< state, action, environment >::StartNewTrial(), SharedAMapGroup::StartNewTrial(), and SumStat().
void StatCollection::AddStat | ( | const char * | category, |
const char * | owner, | ||
long | value | ||
) |
Add a new stat entry for the given category, owner and value.
Definition at line 87 of file StatCollection.cpp.
References addCategory(), addOwner(), longStored, passFilter(), printOutput, and stats.
void StatCollection::ClearAllStats | ( | ) |
Remove all stat entries from the collection.
Definition at line 148 of file StatCollection.cpp.
References stats.
Referenced by setupAverageRatio().
void StatCollection::ClearFilters | ( | ) |
Clear any filters being used for stat entry.
Definition at line 220 of file StatCollection.cpp.
References excludeFilters, and includeFilters.
Referenced by setupAverageRatio().
|
inline |
Definition at line 61 of file StatCollection.h.
References printOutput.
int StatCollection::FindNextStat | ( | const char * | category, |
const char * | owner, | ||
int | startIndex = 0 |
||
) | const |
Find the next stat entry that matches the given category and owner name.
If error occurs, return -1; otherwise, return the found index.
Definition at line 388 of file StatCollection.cpp.
References LookupCategory(), LookupOwner(), passFilter(), and stats.
int StatCollection::FindNextStat | ( | const char * | what, |
bool | findCategory, | ||
int | startIndex = 0 |
||
) | const |
Find the next stat entry that matches the category if findCategory is true, otherwise look to match the owner name.
If error occurs, return -1; otherwise, return the found index.
Definition at line 444 of file StatCollection.cpp.
References LookupCategory(), LookupOwner(), passFilter(), and stats.
int StatCollection::FindPrevStat | ( | const char * | category, |
const char * | owner, | ||
int | startIndex = -1 |
||
) | const |
Find the previous stat entry that matches the given category and owner name.
If error occurs, return -1; otherwise, return the found index.
Definition at line 415 of file StatCollection.cpp.
References LookupCategory(), LookupOwner(), passFilter(), and stats.
int StatCollection::FindPrevStat | ( | const char * | what, |
bool | findCategory, | ||
int | startIndex = -1 |
||
) | const |
Find the next stat entry that matches the category if findCategory is true, otherwise look to match the owner name.
If error occurs, return -1; otherwise, return the found index.
Definition at line 475 of file StatCollection.cpp.
References LookupCategory(), LookupOwner(), passFilter(), and stats.
|
private |
Find the last stat entered that matches the category and owner.
Returns pointer to entry.
Definition at line 341 of file StatCollection.cpp.
References LookupCategory(), LookupOwner(), passFilter(), and stats.
Referenced by SumStat().
int StatCollection::GetNumStats | ( | ) | const |
The number of stats collected so far.
Definition at line 158 of file StatCollection.cpp.
References stats.
Referenced by averageStatEntries(), countStatEntries(), maxStatEntries(), measureAverageRatio(), stdevStatEntries(), and SumStatEntries().
const statistics * StatCollection::GetStatNum | ( | int | which | ) | const |
Return the nth stat which has been collected.
Definition at line 166 of file StatCollection.cpp.
References stats.
Referenced by averageStatEntries(), countStatEntries(), maxStatEntries(), measureAverageRatio(), stdevStatEntries(), and SumStatEntries().
int StatCollection::LookupCategory | ( | const char * | category | ) | const |
Given a category, look up the ID.
O(# categories) operation. If not found, returns -1.
Definition at line 241 of file StatCollection.cpp.
References categories.
Referenced by addCategory(), averageStatEntries(), countStatEntries(), FindNextStat(), FindPrevStat(), getLastStat(), LookupStat(), maxStatEntries(), stdevStatEntries(), and SumStatEntries().
const char * StatCollection::lookupCategoryID | ( | int | id | ) | const |
Given a category ID, return the text description.
Definition at line 174 of file StatCollection.cpp.
References categories.
Referenced by measureAverageRatio().
int StatCollection::LookupOwner | ( | const char * | owner | ) | const |
Given an owner, look up the ID.
O(# owners) operation. If not found, returns -1.
Definition at line 275 of file StatCollection.cpp.
References owners.
Referenced by addOwner(), averageStatEntries(), countStatEntries(), FindNextStat(), FindPrevStat(), getLastStat(), LookupStat(), maxStatEntries(), measureAverageRatio(), stdevStatEntries(), and SumStatEntries().
const char * StatCollection::LookupOwnerID | ( | int | id | ) | const |
Given a owner ID, return the text description.
Definition at line 182 of file StatCollection.cpp.
References owners.
Referenced by measureAverageRatio().
bool StatCollection::LookupStat | ( | const char * | category, |
const char * | owner, | ||
statValue & | v | ||
) | const |
Find the last stat entered that matches the category and owner.
Returns copy of stat entry. Returns true if a stat was found and false otherwise.
Definition at line 307 of file StatCollection.cpp.
References LookupCategory(), LookupOwner(), passFilter(), and stats.
bool StatCollection::LookupStat | ( | unsigned int | index, |
statValue & | v | ||
) | const |
Definition at line 327 of file StatCollection.cpp.
References stats.
|
private |
Check to see if the category stats should be saved.
Definition at line 359 of file StatCollection.cpp.
References excludeFilters, and includeFilters.
Referenced by AddStat(), FindNextStat(), FindPrevStat(), getLastStat(), and LookupStat().
void StatCollection::PrintStatsTable | ( | ) | const |
Definition at line 506 of file StatCollection.cpp.
References categories, floatStored, owners, and stats.
void StatCollection::SumStat | ( | const char * | category, |
const char * | owner, | ||
double | value | ||
) |
Given stats for the category and owner, find an existing stat (chronologically backwards search) with the same category and owner, and add this stat to the existing value.
If the stat doesn't exist with the same category and owner doesn't exist, a new one will be initialized with the given value.
Definition at line 109 of file StatCollection.cpp.
References AddStat(), statValue::fval, getLastStat(), and printOutput.
Referenced by GenericPatrolUnit< state, action, environment >::LogStats(), and SharedAMapGroup::LogStats().
void StatCollection::SumStat | ( | const char * | category, |
const char * | owner, | ||
long | value | ||
) |
Given stats for the category and owner, find an existing stat (chronologically backwards search) with the same category and owner, and add this stat to the existing value.
If the stat doesn't exist with the same category and owner doesn't exist, a new one will be initialized with the given value.
Definition at line 130 of file StatCollection.cpp.
References AddStat(), getLastStat(), statValue::lval, and printOutput.
|
private |
Definition at line 76 of file StatCollection.h.
Referenced by addCategory(), LookupCategory(), lookupCategoryID(), and PrintStatsTable().
|
private |
Definition at line 79 of file StatCollection.h.
Referenced by AddExcludeFilter(), ClearFilters(), and passFilter().
|
private |
Definition at line 78 of file StatCollection.h.
Referenced by AddIncludeFilter(), ClearFilters(), and passFilter().
|
private |
Definition at line 77 of file StatCollection.h.
Referenced by addOwner(), LookupOwner(), LookupOwnerID(), and PrintStatsTable().
|
private |
Definition at line 81 of file StatCollection.h.
Referenced by AddStat(), EnablePrintOutput(), StatCollection(), and SumStat().
|
private |
Definition at line 80 of file StatCollection.h.
Referenced by AddStat(), ClearAllStats(), FindNextStat(), FindPrevStat(), getLastStat(), GetNumStats(), GetStatNum(), LookupStat(), and PrintStatsTable().