The base class of all heuristics. More...
#include <Heuristic.h>
Public Member Functions | |
virtual void | showArguments (std::ostream &os)=0 |
Display valid command line arguments for this heuristic. | |
virtual bool | parseArguments (int &argc, char **argv)=0 |
Process command line arguments. | |
virtual int | initialize ()=0 |
Method to begin heuristic analysis (if any). | |
virtual int | setReferenceEST (const int estIdx)=0 |
Set the reference EST id for analysis. | |
bool | shouldAnalyze (const int otherEST) |
Determine whether the analyzer should analyze, according to this heuristic. | |
const std::string & | getName () const |
Obtain human-readable name for this heuristic. | |
virtual | ~Heuristic () |
The destructor. | |
virtual void | printStats (std::ostream &os) const |
Method to display statistics regarding operation of this heuristic. | |
int | getRunCount () |
Method to obtain the count of times this heuristic was run. | |
int | getSuccessCount () |
Method to obtain the count of times this heuristic was successful (i.e. | |
Protected Member Functions | |
Heuristic (const std::string &heuristicName) | |
The default constructor. | |
virtual bool | runHeuristic (const int otherEST)=0 |
Determine whether the analyzer should analyze, according to this heuristic. | |
Protected Attributes | |
int | refESTidx |
The index of the reference EST in a given file. | |
const std::string | heuristicName |
The name of this heuristic. | |
Private Member Functions | |
Heuristic & | operator= (const Heuristic &src) |
A dummy operator=. | |
Private Attributes | |
int | runCount |
Variable to track the number of times this heuristic was run. | |
int | successCount |
Variable to track the number of times this heuristic passed. |
The base class of all heuristics.
This class must be the base class of all heuristics in the system. This class provides some default functionality that can be readily used by the heuristics. This class enables the HeuristicChain to manage a list of heuristics and dispatch method calls to various heuristics.
Definition at line 47 of file Heuristic.h.
Heuristic::~Heuristic | ( | ) | [virtual] |
The destructor.
The destructor frees memory allocated for holding any dynamic data in the base class.
Definition at line 45 of file Heuristic.cpp.
Heuristic::Heuristic | ( | const std::string & | heuristicName | ) | [protected] |
The default constructor.
The constructor has been made protected to ensure that this class is never directly instantiated. Instead one of the derived Heuristic classes must be instantiated via the HeuristicFactory API methods.
[in] | heuristicName | The human readable name for this heuristic. This name is used when generating errors, warnings, and other output messages for this heuristic. |
Definition at line 40 of file Heuristic.cpp.
const std::string& Heuristic::getName | ( | ) | const [inline] |
Obtain human-readable name for this heuristic.
This method must be used to obtain the human readable name set for this heuristic. This method essentially returns the value set when this heuristic class was instantiated.
Definition at line 149 of file Heuristic.h.
References heuristicName.
Referenced by printStats().
int Heuristic::getRunCount | ( | ) | [inline] |
Method to obtain the count of times this heuristic was run.
Definition at line 191 of file Heuristic.h.
References runCount.
int Heuristic::getSuccessCount | ( | ) | [inline] |
Method to obtain the count of times this heuristic was successful (i.e.
result indicated that heavy weight analysis should be undertaken).
Definition at line 203 of file Heuristic.h.
References successCount.
Referenced by PMSTClusterMaker::makeClusters().
virtual int Heuristic::initialize | ( | ) | [pure virtual] |
Method to begin heuristic analysis (if any).
This method is invoked just before commencement of EST analysis. This method typically loads additional information that may be necessary for a given heuristic from data files. In addition, it may perform any pre-processing as the case may be.
Implemented in NewUVHeuristic, TVHeuristic, and UVSampleHeuristic.
A dummy operator=.
The operator=() is supressed for this class as it has constant members whose value is set when the object is created. These values cannot be changed during the lifetime of this object.
[in] | src | The source object from where data is to be copied. Currently this value is ignored. |
virtual bool Heuristic::parseArguments | ( | int & | argc, | |
char ** | argv | |||
) | [pure virtual] |
Process command line arguments.
This method is used to process command line arguments specific to this heuristic. This method is typically used from the main method just after the heuristic has been instantiated. This method consumes all valid command line arguments. If the command line arguments were valid and successfully processed, then this method returns true
.
[in,out] | argc | The number of command line arguments to be processed. |
[in,out] | argv | The array of command line arguments. |
true
if the command line arguments were successfully processed. Otherwise this method returns false
. Implemented in NewUVHeuristic, TVHeuristic, and UVSampleHeuristic.
void Heuristic::printStats | ( | std::ostream & | os | ) | const [virtual] |
Method to display statistics regarding operation of this heuristic.
This method can be used to obtain a dump of the statistics gathered regarding the operation of this heuristic. The typical statistic generated by heuristics includes:
The number of times the heuristic was called. More specifically this value indicates the number of times the shouldAnalyze()
method was invoked.
The number of successful matches reported by this heuristic. This number indirectly indicates the number of times other heuristics or the actual heavy weight algorithm was invoked.
[out] | os | The output stream to which the statistics regarding the heuristic is to be dumped. |
Reimplemented in TVHeuristic.
Definition at line 64 of file Heuristic.cpp.
References getName(), runCount, and successCount.
virtual bool Heuristic::runHeuristic | ( | const int | otherEST | ) | [protected, pure virtual] |
Determine whether the analyzer should analyze, according to this heuristic.
This method is invoked from the shouldAnalyze() method to perform the actual heuristic analysis. The analysis is performed between the refESTidx (set via earlier call to setReferenceEST) and otherEST.
[in] | otherEST | The index (zero based) of the EST with which the reference EST is to be compared. |
true
if the heuristic says the EST pair should be analyzed, and false
otherwise. Implemented in NewUVHeuristic, TVHeuristic, and UVSampleHeuristic.
Referenced by shouldAnalyze().
virtual int Heuristic::setReferenceEST | ( | const int | estIdx | ) | [pure virtual] |
Set the reference EST id for analysis.
This method is invoked just before a batch of ESTs are analyzed via a call to the analyze(EST *) method. Setting the reference EST provides heuristics an opportunity to optimize certain operations, if possible.
Implemented in NewUVHeuristic, TVHeuristic, and UVSampleHeuristic.
bool Heuristic::shouldAnalyze | ( | const int | otherEST | ) |
Determine whether the analyzer should analyze, according to this heuristic.
This method can be used to compare a given EST with the reference EST (set via the call to the setReferenceEST()) method.
[in] | otherEST | The index (zero based) of the EST with which the reference EST is to be compared. |
Definition at line 50 of file Heuristic.cpp.
References runCount, runHeuristic(), and successCount.
virtual void Heuristic::showArguments | ( | std::ostream & | os | ) | [pure virtual] |
Display valid command line arguments for this heuristic.
This method must be used to display all valid command line options that are supported by this heuristic. Note that derived classes may override this method to display additional command line options that are applicable to it. This method is typically used in the main() method when displaying usage information.
[out] | os | The output stream to which the valid command line arguments must be written. |
Implemented in NewUVHeuristic, TVHeuristic, and UVSampleHeuristic.
const std::string Heuristic::heuristicName [protected] |
The name of this heuristic.
This instance variable contains the human recognizable name for this heuristic. This value is set when the heuristic is instantiated (in the constructor) and is never changed during the life time of this heuristic. This information is used when generating errors, warnings, and other output messages.
Definition at line 257 of file Heuristic.h.
Referenced by getName(), UVSampleHeuristic::parseArguments(), TVHeuristic::parseArguments(), and NewUVHeuristic::parseArguments().
int Heuristic::refESTidx [protected] |
The index of the reference EST in a given file.
This member object is used to hold the index of a reference EST in a given file. The index values begin from 0 (zero). This member is initialized in the constructor and is changed by the setReferenceEST() id.
Definition at line 247 of file Heuristic.h.
Referenced by UVSampleHeuristic::runHeuristic(), NewUVHeuristic::runHeuristic(), UVSampleHeuristic::setReferenceEST(), TVHeuristic::setReferenceEST(), and NewUVHeuristic::setReferenceEST().
int Heuristic::runCount [private] |
Variable to track the number of times this heuristic was run.
This instance variable is used to track the number of times this heuristic was run. This variable is initialized to zero in the constructor. It is incremented each time the shouldAnalyze() method is invoked to run the the heuristic.
Definition at line 267 of file Heuristic.h.
Referenced by getRunCount(), printStats(), and shouldAnalyze().
int Heuristic::successCount [private] |
Variable to track the number of times this heuristic passed.
This instance vairable tracks the number of times the heuristic passed. This number indirectly indicates the number of times other heuristics or the actual heavy weight algorithm was invoked. This value is incremented in the shouldAnalyze()
method each time the runHeuristic method returns a true
value.
Definition at line 278 of file Heuristic.h.
Referenced by getSuccessCount(), printStats(), and shouldAnalyze().