presage  0.8.8
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
PredictorActivator Class Reference

#include <predictorActivator.h>

Inheritance diagram for PredictorActivator:
Inheritance graph
Collaboration diagram for PredictorActivator:
Collaboration graph

List of all members.

Public Member Functions

 PredictorActivator (Configuration *config, PredictorRegistry *registry, ContextTracker *contextTracker)
 ~PredictorActivator ()
Prediction predict (unsigned int multiplier, const char **filter)
void setPredictors (const std::string &predictorList)
void addPredictor (const std::string &predictorName)
void removePredictors ()
int getPredictTime () const
void setPredictTime (const std::string &predictTime)
std::string getCombinationPolicy () const
void setCombinationPolicy (const std::string &policy)
void setMaxPartialPredictionSize (const std::string &size)
void setLogger (const std::string &level)
void parse_internal_commands (Prediction &pred)
virtual void update (const Observable *variable)
- Public Member Functions inherited from Observer
virtual ~Observer ()

Static Public Attributes

static const char * LOGGER = "Presage.PredictorActivator.LOGGER"
static const char * PREDICT_TIME = "Presage.PredictorActivator.PREDICT_TIME"
static const char * MAX_PARTIAL_PREDICTION_SIZE = "Presage.PredictorActivator.MAX_PARTIAL_PREDICTION_SIZE"
static const char * COMBINATION_POLICY = "Presage.PredictorActivator.COMBINATION_POLICY"

Private Member Functions

void * execute (void *)

Private Attributes

Configurationconfig
PredictorRegistrypredictorRegistry
ContextTrackercontextTracker
Logger< char > logger
Combinercombiner
std::string combinationPolicy
int max_partial_prediction_size
std::vector< Predictionpredictions
int predict_time
Dispatcher< PredictorActivatordispatcher

Additional Inherited Members

- Protected Member Functions inherited from Observer
 Observer ()

Detailed Description

PredictorActivator, the heart of Presage system, coordinates the execution of predictors and returns the combination of their predictions.

PredictorActivator starts the execution of the active predictors, monitors their execution and collects the predictions returned, or terminates a predictor's execution if it execedes its maximum prediction time.

The predictions returned by the individual predictors are combined into a single prediction by the active Combiner. (please refer to my thesis for a list of possible conbination strategies.

Definition at line 62 of file predictorActivator.h.


Constructor & Destructor Documentation

PredictorActivator::PredictorActivator ( Configuration config,
PredictorRegistry registry,
ContextTracker contextTracker 
)

Construct a PredictorActivator object.

PredictorActivator needs a reference to the ContextTracker object to forward to the predictors for context retrieval and analysis.

Parameters:
configpointer to configuration
registrypointer to predictor registry
contextTrackerpointer to ContextTracker

Definition at line 33 of file predictorActivator.cpp.

References COMBINATION_POLICY, combiner, config, dispatcher, Configuration::find(), LOGGER, Dispatcher< class_t >::map(), MAX_PARTIAL_PREDICTION_SIZE, PREDICT_TIME, setCombinationPolicy(), setLogger(), setMaxPartialPredictionSize(), and setPredictTime().

Here is the call graph for this function:

PredictorActivator::~PredictorActivator ( )

Destroy predictor activator.

Definition at line 52 of file predictorActivator.cpp.

References combiner.


Member Function Documentation

void PredictorActivator::addPredictor ( const std::string &  predictorName)

Adds a predictor to the active runtime predictors list.

Parameters:
predictorNamepredictor name string
void* PredictorActivator::execute ( void *  )
private
std::string PredictorActivator::getCombinationPolicy ( ) const

Gets COMBINATION_METHOD option value.

Returns the active combination method used by predictor activator to combine predictions returned by the active predictors into one prediction.

Returns:
value of COMBINATION_METHOD

Definition at line 140 of file predictorActivator.cpp.

References combinationPolicy.

int PredictorActivator::getPredictTime ( ) const

Gets PREDICT_TIME option value.

Returns the maximum time predictors are allowed to execute before returning a prediction.

Returns:
value of PREDICT_TIME

Definition at line 117 of file predictorActivator.cpp.

References predict_time.

void PredictorActivator::parse_internal_commands ( Prediction pred)

Definition at line 160 of file predictorActivator.cpp.

References Prediction::addSuggestion(), contextTracker, ContextTracker::getToken(), and PACKAGE_STRING.

Referenced by predict().

Here is the call graph for this function:

Here is the caller graph for this function:

Prediction PredictorActivator::predict ( unsigned int  multiplier,
const char **  filter 
)

Runs the predictors, combine their predictions and return the resulting prediction.

This is the heart of Presage.

Plump will eventually provide the implementation of sequential or parallel execution of predictors.

Returns:
prediction produced by the active predictors and combined by the active combiner

Definition at line 57 of file predictorActivator.cpp.

References Combiner::combine(), combiner, endl(), Predictor::getName(), PredictorRegistry::Iterator::hasNext(), PredictorRegistry::iterator(), logger, max_partial_prediction_size, PredictorRegistry::Iterator::next(), parse_internal_commands(), Predictor::predict(), predictions, and predictorRegistry.

Referenced by Presage::predict().

Here is the call graph for this function:

Here is the caller graph for this function:

void PredictorActivator::removePredictors ( )

Removes all predictors from the active predictors list.

void PredictorActivator::setCombinationPolicy ( const std::string &  policy)

Sets combination policy.

Sets the combination policy used by predictor activator to combine predictions returned by the active predictors into one prediction.

The existing combiner object is first destroyed, then a new combiner object created.

Parameters:
policycombination policy

Definition at line 123 of file predictorActivator.cpp.

References combinationPolicy, combiner, endl(), logger, and Utility::strtolower().

Referenced by PredictorActivator().

Here is the call graph for this function:

Here is the caller graph for this function:

void PredictorActivator::setLogger ( const std::string &  level)

Sets logger level.

Parameters:
levellogger level

Definition at line 94 of file predictorActivator.cpp.

References endl(), logger, and setlevel().

Referenced by PredictorActivator().

Here is the call graph for this function:

Here is the caller graph for this function:

void PredictorActivator::setMaxPartialPredictionSize ( const std::string &  size)

Sets maximum partial prediction size.

Parameters:
sizemaximum partial prediction size

Definition at line 146 of file predictorActivator.cpp.

References endl(), logger, max_partial_prediction_size, and Utility::toInt().

Referenced by PredictorActivator().

Here is the call graph for this function:

Here is the caller graph for this function:

void PredictorActivator::setPredictors ( const std::string &  predictorList)

Set active predictors.

Parameters:
predictorListspace separated list of predictors
void PredictorActivator::setPredictTime ( const std::string &  predictTime)

Sets PREDICT_TIME option, the maximum time allowed for a predictor to return its prediction.

Parameters:
predictTimeexpressed in milliseconds
Returns:
true if the supplied value is valid, false otherwise

Definition at line 101 of file predictorActivator.cpp.

References endl(), logger, predict_time, and Utility::toInt().

Referenced by PredictorActivator().

Here is the call graph for this function:

Here is the caller graph for this function:

void PredictorActivator::update ( const Observable variable)
virtual

Implements Observer.

Definition at line 153 of file predictorActivator.cpp.

References Dispatcher< class_t >::dispatch(), dispatcher, endl(), Observable::get_name(), Observable::get_value(), and logger.

Here is the call graph for this function:


Member Data Documentation

const char * PredictorActivator::COMBINATION_POLICY = "Presage.PredictorActivator.COMBINATION_POLICY"
static

Definition at line 169 of file predictorActivator.h.

Referenced by PredictorActivator().

std::string PredictorActivator::combinationPolicy
private

Definition at line 183 of file predictorActivator.h.

Referenced by getCombinationPolicy(), and setCombinationPolicy().

Combiner* PredictorActivator::combiner
private
Configuration* PredictorActivator::config
private

Definition at line 176 of file predictorActivator.h.

Referenced by PredictorActivator().

ContextTracker* PredictorActivator::contextTracker
private

Definition at line 178 of file predictorActivator.h.

Referenced by parse_internal_commands().

Dispatcher<PredictorActivator> PredictorActivator::dispatcher
private

Definition at line 191 of file predictorActivator.h.

Referenced by PredictorActivator(), and update().

const char * PredictorActivator::LOGGER = "Presage.PredictorActivator.LOGGER"
static

Definition at line 166 of file predictorActivator.h.

Referenced by PredictorActivator().

Logger<char> PredictorActivator::logger
private
const char * PredictorActivator::MAX_PARTIAL_PREDICTION_SIZE = "Presage.PredictorActivator.MAX_PARTIAL_PREDICTION_SIZE"
static

Definition at line 168 of file predictorActivator.h.

Referenced by PredictorActivator().

int PredictorActivator::max_partial_prediction_size
private

Definition at line 185 of file predictorActivator.h.

Referenced by predict(), and setMaxPartialPredictionSize().

const char * PredictorActivator::PREDICT_TIME = "Presage.PredictorActivator.PREDICT_TIME"
static

Definition at line 167 of file predictorActivator.h.

Referenced by PredictorActivator().

int PredictorActivator::predict_time
private

Definition at line 189 of file predictorActivator.h.

Referenced by getPredictTime(), and setPredictTime().

std::vector<Prediction> PredictorActivator::predictions
private

Definition at line 187 of file predictorActivator.h.

Referenced by predict().

PredictorRegistry* PredictorActivator::predictorRegistry
private

Definition at line 177 of file predictorActivator.h.

Referenced by predict().


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