presage  0.9.2~beta
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
PredictorActivator Class Reference

#include <predictorActivator.h>

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

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

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::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::~PredictorActivator ( )

Destroy predictor activator.

Definition at line 52 of file predictorActivator.cpp.

References combiner.

Member Function Documentation

◆ execute()

void* PredictorActivator::execute ( void *  )
private

◆ getCombinationPolicy()

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.

◆ getPredictTime()

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.

◆ parse_internal_commands()

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:

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

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:

◆ setCombinationPolicy()

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:

◆ setLogger()

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:

◆ setMaxPartialPredictionSize()

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:

◆ setPredictTime()

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:

◆ update()

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

◆ COMBINATION_POLICY

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

Definition at line 152 of file predictorActivator.h.

Referenced by PredictorActivator().

◆ combinationPolicy

std::string PredictorActivator::combinationPolicy
private

Definition at line 166 of file predictorActivator.h.

Referenced by getCombinationPolicy(), and setCombinationPolicy().

◆ combiner

Combiner* PredictorActivator::combiner
private

◆ config

Configuration* PredictorActivator::config
private

Definition at line 159 of file predictorActivator.h.

Referenced by PredictorActivator().

◆ contextTracker

ContextTracker* PredictorActivator::contextTracker
private

Definition at line 161 of file predictorActivator.h.

Referenced by parse_internal_commands().

◆ dispatcher

Dispatcher<PredictorActivator> PredictorActivator::dispatcher
private

Definition at line 174 of file predictorActivator.h.

Referenced by PredictorActivator(), and update().

◆ LOGGER

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

Definition at line 149 of file predictorActivator.h.

Referenced by PredictorActivator().

◆ logger

Logger<char> PredictorActivator::logger
private

◆ MAX_PARTIAL_PREDICTION_SIZE

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

Definition at line 151 of file predictorActivator.h.

Referenced by PredictorActivator().

◆ max_partial_prediction_size

int PredictorActivator::max_partial_prediction_size
private

Definition at line 168 of file predictorActivator.h.

Referenced by predict(), and setMaxPartialPredictionSize().

◆ PREDICT_TIME

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

Definition at line 150 of file predictorActivator.h.

Referenced by PredictorActivator().

◆ predict_time

int PredictorActivator::predict_time
private

Definition at line 172 of file predictorActivator.h.

Referenced by getPredictTime(), and setPredictTime().

◆ predictions

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

Definition at line 170 of file predictorActivator.h.

Referenced by predict().

◆ predictorRegistry

PredictorRegistry* PredictorActivator::predictorRegistry
private

Definition at line 160 of file predictorActivator.h.

Referenced by predict().


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