presage
0.9.2~beta
|
#include <predictorActivator.h>
Public Member Functions | |
PredictorActivator (Configuration *config, PredictorRegistry *registry, ContextTracker *contextTracker) | |
~PredictorActivator () | |
Prediction | predict (unsigned int multiplier, const char **filter) |
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 | |
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 |
Additional Inherited Members | |
Protected Member Functions inherited from Observer | |
Observer () | |
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.
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().
PredictorActivator::~PredictorActivator | ( | ) |
Destroy predictor activator.
Definition at line 52 of file predictorActivator.cpp.
References combiner.
|
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 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.
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().
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::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 123 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 94 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 146 of file predictorActivator.cpp.
References endl(), logger, max_partial_prediction_size, and Utility::toInt().
Referenced by PredictorActivator().
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 101 of file predictorActivator.cpp.
References endl(), logger, predict_time, and Utility::toInt().
Referenced by PredictorActivator().
|
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.
|
static |
Definition at line 152 of file predictorActivator.h.
Referenced by PredictorActivator().
|
private |
Definition at line 166 of file predictorActivator.h.
Referenced by getCombinationPolicy(), and setCombinationPolicy().
|
private |
Definition at line 165 of file predictorActivator.h.
Referenced by predict(), PredictorActivator(), setCombinationPolicy(), and ~PredictorActivator().
|
private |
Definition at line 159 of file predictorActivator.h.
Referenced by PredictorActivator().
|
private |
Definition at line 161 of file predictorActivator.h.
Referenced by parse_internal_commands().
|
private |
Definition at line 174 of file predictorActivator.h.
Referenced by PredictorActivator(), and update().
|
static |
Definition at line 149 of file predictorActivator.h.
Referenced by PredictorActivator().
|
private |
Definition at line 163 of file predictorActivator.h.
Referenced by predict(), setCombinationPolicy(), setLogger(), setMaxPartialPredictionSize(), setPredictTime(), and update().
|
static |
Definition at line 151 of file predictorActivator.h.
Referenced by PredictorActivator().
|
private |
Definition at line 168 of file predictorActivator.h.
Referenced by predict(), and setMaxPartialPredictionSize().
|
static |
Definition at line 150 of file predictorActivator.h.
Referenced by PredictorActivator().
|
private |
Definition at line 172 of file predictorActivator.h.
Referenced by getPredictTime(), and setPredictTime().
|
private |
Definition at line 170 of file predictorActivator.h.
Referenced by predict().
|
private |
Definition at line 160 of file predictorActivator.h.
Referenced by predict().