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

#include <predictorActivator.h>

Inheritance diagram for PredictorActivator:
Inheritance graph
[legend]
Collaboration diagram for PredictorActivator:
Collaboration graph
[legend]

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)

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

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 69 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:

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]

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 146 of file predictorActivator.cpp.

References combinationPolicy.

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 123 of file predictorActivator.cpp.

References predict_time.

Definition at line 166 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:

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 129 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 100 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 152 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 107 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 159 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 176 of file predictorActivator.h.

Referenced by PredictorActivator().

Definition at line 194 of file predictorActivator.h.

Referenced by getCombinationPolicy(), and setCombinationPolicy().

Definition at line 187 of file predictorActivator.h.

Referenced by PredictorActivator().

Definition at line 189 of file predictorActivator.h.

Referenced by parse_internal_commands().

Definition at line 202 of file predictorActivator.h.

Referenced by PredictorActivator(), and update().

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

Definition at line 173 of file predictorActivator.h.

Referenced by PredictorActivator().

const char * PredictorActivator::MAX_PARTIAL_PREDICTION_SIZE = "Presage.PredictorActivator.MAX_PARTIAL_PREDICTION_SIZE" [static]

Definition at line 175 of file predictorActivator.h.

Referenced by PredictorActivator().

Definition at line 196 of file predictorActivator.h.

Referenced by predict(), and setMaxPartialPredictionSize().

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

Definition at line 174 of file predictorActivator.h.

Referenced by PredictorActivator().

Definition at line 200 of file predictorActivator.h.

Referenced by getPredictTime(), and setPredictTime().

Definition at line 198 of file predictorActivator.h.

Referenced by predict().

Definition at line 188 of file predictorActivator.h.

Referenced by predict().


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