presage
0.8.7
|
#include <predictorActivator.h>
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 | |
Configuration * | config |
PredictorRegistry * | predictorRegistry |
ContextTracker * | contextTracker |
Logger< char > | logger |
Combiner * | combiner |
std::string | combinationPolicy |
int | max_partial_prediction_size |
std::vector< Prediction > | predictions |
int | predict_time |
Dispatcher< PredictorActivator > | dispatcher |
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.
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.
config | pointer to configuration |
registry | pointer to predictor registry |
contextTracker | pointer 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().
Destroy predictor activator.
Definition at line 52 of file predictorActivator.cpp.
References combiner.
void PredictorActivator::addPredictor | ( | const std::string & | predictorName | ) |
Adds a predictor to the active runtime predictors list.
predictorName | predictor 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.
Definition at line 146 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.
Definition at line 123 of file predictorActivator.cpp.
References predict_time.
void PredictorActivator::parse_internal_commands | ( | Prediction & | pred | ) |
Definition at line 166 of file predictorActivator.cpp.
References Prediction::addSuggestion(), contextTracker, ContextTracker::getToken(), and PACKAGE_STRING.
Referenced by predict().
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.
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().
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.
policy | combination policy |
Definition at line 129 of file predictorActivator.cpp.
References combinationPolicy, combiner, endl(), logger, and Utility::strtolower().
Referenced by PredictorActivator().
void PredictorActivator::setLogger | ( | const std::string & | level | ) |
Sets logger level.
level | logger level |
Definition at line 100 of file predictorActivator.cpp.
References endl(), logger, and setlevel().
Referenced by PredictorActivator().
void PredictorActivator::setMaxPartialPredictionSize | ( | const std::string & | size | ) |
Sets maximum partial prediction size.
size | maximum partial prediction size |
Definition at line 152 of file predictorActivator.cpp.
References endl(), logger, max_partial_prediction_size, and Utility::toInt().
Referenced by PredictorActivator().
void PredictorActivator::setPredictors | ( | const std::string & | predictorList | ) |
Set active predictors.
predictorList | space 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.
predictTime | expressed in milliseconds |
Definition at line 107 of file predictorActivator.cpp.
References endl(), logger, predict_time, and Utility::toInt().
Referenced by PredictorActivator().
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.
const char * PredictorActivator::COMBINATION_POLICY = "Presage.PredictorActivator.COMBINATION_POLICY" [static] |
Definition at line 176 of file predictorActivator.h.
Referenced by PredictorActivator().
std::string PredictorActivator::combinationPolicy [private] |
Definition at line 194 of file predictorActivator.h.
Referenced by getCombinationPolicy(), and setCombinationPolicy().
Combiner* PredictorActivator::combiner [private] |
Definition at line 193 of file predictorActivator.h.
Referenced by predict(), PredictorActivator(), setCombinationPolicy(), and ~PredictorActivator().
Configuration* PredictorActivator::config [private] |
Definition at line 187 of file predictorActivator.h.
Referenced by PredictorActivator().
ContextTracker* PredictorActivator::contextTracker [private] |
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().
Logger<char> PredictorActivator::logger [private] |
Definition at line 191 of file predictorActivator.h.
Referenced by predict(), setCombinationPolicy(), setLogger(), setMaxPartialPredictionSize(), setPredictTime(), and update().
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().
int PredictorActivator::max_partial_prediction_size [private] |
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().
int PredictorActivator::predict_time [private] |
Definition at line 200 of file predictorActivator.h.
Referenced by getPredictTime(), and setPredictTime().
std::vector<Prediction> PredictorActivator::predictions [private] |
Definition at line 198 of file predictorActivator.h.
Referenced by predict().
Definition at line 188 of file predictorActivator.h.
Referenced by predict().