Heuristic Class Reference

The base class of all heuristics. More...

#include <Heuristic.h>

Inheritance diagram for Heuristic:
Inheritance graph
[legend]

List of all members.

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

Heuristicoperator= (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.

Detailed Description

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.


Constructor & Destructor Documentation

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.

Parameters:
[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.


Member Function Documentation

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.

Returns:
A human readable name associated with this heuristic.

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.

Returns:
The number of times this heuristic was called.

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).

Returns:
The number of times calls to this heuristic succeeded -- that is, the number of times the heuristic reported that two ESTs are related.

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.

Note:
Derived classes must override this method.
Returns:
If the initialization process was sucessful, then this method returns 0. Otherwise this method returns with a non-zero error code.

Implemented in NewUVHeuristic, TVHeuristic, and UVSampleHeuristic.

Heuristic& Heuristic::operator= ( const Heuristic src  )  [private]

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.

Parameters:
[in] src The source object from where data is to be copied. Currently this value is ignored.
Returns:
Reference to this.
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.

Note:
Derived heuristic classes must override this method to process any command line arguments that are custom to their operation. When this method is overridden don't forget to call the corresponding base class implementation to display common options.
Parameters:
[in,out] argc The number of command line arguments to be processed.
[in,out] argv The array of command line arguments.
Returns:
This method returns 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.

Note:
Derived heuristic classes may override this method to display additional statistics. However, the additional information must be displayed after the base class method has completed its task.
Parameters:
[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.

Note:
Derived heuristic classes must override this method and provide a proper implementation.
Parameters:
[in] otherEST The index (zero based) of the EST with which the reference EST is to be compared.
Returns:
This method must return 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.

Note:
This method must be called only after the initialize() method is called.
Returns:
If the initialization process was sucessful, then this method returns 0. Otherwise this method returns an error code.

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.

Parameters:
[in] otherEST The index (zero based) of the EST with which the reference EST is to be compared.
Returns:
This method returns true if the heuristic says the EST pair should be analyzed, and false if it should not.

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.

Note:
Derived heuristic classes must override this method to display help for their custom command line arguments. When this method is overridden don't forget to call the corresponding base class implementation to display common options.
Parameters:
[out] os The output stream to which the valid command line arguments must be written.

Implemented in NewUVHeuristic, TVHeuristic, and UVSampleHeuristic.


Member Data Documentation

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().


The documentation for this class was generated from the following files:

Generated on 19 Mar 2010 for PEACE by  doxygen 1.6.1