movavg_lib.h File Reference

Public interface for the Moving Average predictor. More...

#include <linux/aquosa/rres_config.h>
#include <linux/aquosa/qres_config.h>
#include <linux/aquosa/qos_debug.h>

Go to the source code of this file.


 Default sample size.
#define MOVAVG_DEF_FORGETF   1.0
 Default forgetting factor.


qos_rv movavg_set_defaults (void)
 Configures a Moving Average predictor with default parameters.
qos_rv movavg_set_sample_size (int sample_size)
 Sets the sample size for the Moving Average predictor.
qos_rv movavg_set_forget_f (float ff)
 Sets a forgetting factor lower than 1.
qos_rv movavg_register_lib (void)
 Registration of the submodule with the library.

Detailed Description

Public interface for the Moving Average predictor.

A Moving Average predictor computes the expected value of the next sample as a moving average on a fixed number of last execution times. The size of the moving window on the past samples sequence is expected to be provided by the application. Precisely, if N denotes the size of the moving window, and $ \left\{x_{k-1}, x_{k-2}, \dots, x_{k-N} \right\} $ are the N last observed samples at step k, then the expected value $ p_k $, returned by the get_exp_value() function, computes

\[ p_k = \frac{1}{N} \cdot \sum_{i=0}^{N-1} x_{k-1-i} \]

Actually, it is possible to specify more than 1 moving average to be used. This is possible by cascading the movavg predictor with the multipred predictor. See documentation for multipred_t for details.

Forgetting Factor

If a forgetting factor lower than 1 is used, then the samples are averaged by using exponentially reducing weights, with higher weights for recent samples and lower weights for older ones. Precisely, denoting with $ \alpha $ the forgetting factor and with N the sample size, the formula for prediction $p_k$ at step k is

\[ p = \frac{1-\alpha}{1-\alpha^N} \cdot \sum_{i=0}^{N-1} \alpha^j x_{k-1-i} \]

In the same example as above, with a factor of 0.5, the expected value for sample k is computed approximatively as (0.5714*x(k-2)+0.2857*x(k-4)+0.1429*x(k-6))/3. The used weights always sum to 1.

When using a forgetting factor of 1.0, the module uses functions optimized for a simple moving average, so to avoid the unuseful additional overhead.

Definition in file movavg_lib.h.

Function Documentation

qos_rv movavg_register_lib ( void   ) 

Registration of the submodule with the library.

Generated on Mon Aug 2 22:38:48 2010 for qosmgr by  doxygen 1.6.3