public abstract class PredictiveSensor extends CumulativeSensor implements Predicting
Extrapolation class and its daugther classes. Three keys are needed
to correctly adapt this class.
KEY_EXTRAPOLATE key must point to the class of the
extrapolator to use (resolvable class name). Currently,
LinearExtrapolation and
ParabolicExtrapolation are supported.#KEY_BASE key points to the number of past data points
to use for the prediction base. This number must not exceed the cumulative
power of the sensor. Smaller number gives you faster reaction,
but overreaction may be a problem. This base number should be normally be
higher for parabolic extrapolation. For linear extrapolation, a number
comparable to the number of data points to predict is probably
sufficient.KEY_FUTURE key points to the time in the future (in ms)
this sensor should predict its value. The number of data points to predict
is hidden from the user, but it is this number the extrapolator needs.
Therefore, the predictive sensor calculates the number of data points to
predict by dividing this time span by its respawn intervall. The default
value for this long is DEFFUTURE which is shortly longer than
the closing time of the roof.KEY_CHI key should point to a value that allows the
prediciting sensor to judge the reliability of the prediction. If the
residuals to the values used in the extrapolator is above this value, the
predicition is treated unreliable. This is useful if the predictor should
only be used to find certain, rather well-predictable events. If this
key points to zero, the extrapolation is considered always reliable.KEY_PREDICTADVISE key may be used to allow only advisory
function of the predictive behaviour. In this case, the weather sensor
will never produce bad weather events from its predictive edge, bad
weather will only show up as a remark in the syslog.Extrapolation.shiftForward(double) method, greatly reducing CPU-overhead.
Shelf,
ExtrapolationTimerTaskSensor.SensorReadPropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
private SortedSet<Integer> |
bases
The list of extrapolator bases.
|
private static double |
DEFCHI
The default reliability measure, meaning always reliable.
|
private static long |
DEFFUTURE
The default prediction time span.
|
private static boolean |
DEFPREDICTADVISE
The default advisory behaviour.
|
private List<Extrapolation> |
extrapolate
The extrapolating algorithms to use.
|
private int |
fut
The number of steps to extrapolate.
|
static String |
KEY_CHI
The key to juding the reliability of the prediction.
|
static String |
KEY_EXTRAPOLATE
The key mapping to the extrapolating class, followed by ":" and base.
|
static String |
KEY_FUTURE
The key to the time span to extrapolate.
|
static String |
KEY_PREDICTADVISE
The key defining only advisory functionality if set to true.
|
private int |
maxbase
The maximum base size.
|
private int |
minbase
The minimum base size.
|
protected Shelf<Double> |
predict
Stores the predicted values, i.e.
|
KEY_AVERAGE, KEY_MEMORY, KEY_PACKDEFRAWFORMAT, DEFREPORT, DEFSIGMAFORMAT, KEY_RAWFORMAT, KEY_REPORT, KEY_SIGMAFORMATKEY_LOGRAWABOVE, KEY_LOGRAWBELOW, KEY_LOGREADLAG, KEY_RESPAWNKEY_BIND, KEY_BINDNAME, KEY_CONVERT, KEY_DESCRIPTION, KEY_SENSORNAMEALTERNATEHOST, ALTERNATEPORT, KEY_EXPORTPORT, KEY_REGISTRYHOST, KEY_REGISTRYPORTKEY_NOINITONCREATE, POSTFIX_ALPHABET, POSTFIX_BYTES, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_MODTIME, POSTFIX_URLKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORNAMING_EXTENSIONCONFIG, KEY_CLASSKEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME| Modifier | Constructor and Description |
|---|---|
protected |
PredictiveSensor(Map<String,String> qualify)
Constructs a fully-qualified predictive sensor.
|
| Modifier and Type | Method and Description |
|---|---|
protected DataEvent |
generateDataEvent()
Takes the last sensor predictions and add it to the
CumulativeDataEvent produced by the parental method. |
List<Extrapolation> |
getExtrapolation()
Returns the extrapolating instance used.
|
List<Double> |
getLastPredict(int nr)
The interface method for retrieving the last nr predicted raw
values.
|
String |
getPredictToggleInfo()
Returns extra info on a smooth toggle event.
|
void |
init()
Does some initialization immediately after the construction phase.
|
boolean |
isPredictAdvise()
Returns true if the predictive functionality of this sensor is only
meant for advisory behaviour.
|
boolean |
isPredicting()
Returns true if the
extrapolate object is non-null and enough
measurements are already made. |
boolean |
isReliable()
Returns a measure if this prediction is trustable.
|
protected void |
newData(double raw,
Date time)
Conducts a single measure by calling this class's super method.
|
void |
predictFrom(double lastraw)
Predicts from the actual data point to the near future.
|
double |
regetPredict()
Returns the most-recently added predicted raw value as a primitive
double.
|
cumulateOne, getLastRaw, getLastTime, getMaxSize, getMemory, getSizeaddDataListener, addRmiDataListener, conductOneMeasure, exit, getRawFormat, getSigmaFormat, removeDataListener, removeRmiDataListener, reportcancel, equals, getRawToggleInfo, getReading, getRespawn, getTimeOfRead, hashCode, initSensorTimerTask, isReady, readSensor, regetRaw, setTimeOfRead, validReadingaddRmiErrorListener, createSensor, getBindName, getConvert, getSensorDescription, getSensorInitInfo, getSensorName, notifyErrorListener, removeRmiErrorListener, setConvert, status, toStringbindToRegistry, bindToRegistry, bindToRegistry, bindToRegistry, bindToRegistry, bindToRegistry, casterExit, casterExit, getBindName, isValid, unbindFromRegistry, unbindFromRegistrycontainsRemoteProperty, getRemoteProperties, getRemoteProperty, setRemotePropertyclone, createFrom, createFrom, createFrom, createInstance, getApplet, getAsResources, getLocate, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, hasLocalURLs, initProperties, keyCreate, keyCreate, reload, setAppletaugment, augment, augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, parseObject, reload, removeProperty, requires, rescanned, setObject, setProperties, setProperty, stringPropertiesfinalize, getClass, notify, notifyAll, wait, wait, waitcumulateOne, getLastRaw, getLastTime, getMaxSize, getSize, getTimeOfRead, regetRawbindToRegistry, isValid, unbindFromRegistryvalidReadingdefaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringPropertiespublic static final String KEY_EXTRAPOLATE
public static final String KEY_FUTURE
public static final String KEY_CHI
public static final String KEY_PREDICTADVISE
private static final long DEFFUTURE
private static final double DEFCHI
private static final boolean DEFPREDICTADVISE
protected Shelf<Double> predict
private int minbase
private int maxbase
private List<Extrapolation> extrapolate
private int fut
protected PredictiveSensor(Map<String,String> qualify)
KEY_FUTURE and the #KEY_BASE are
set. Additionally, the extrapolating instance is constructed, if the
KEY_EXTRAPOLATE is present and names a valid
Extrapolation class. In the latter case, fut is
assigned.public void init()
throws InitException
AbstractSensorinit in interface Initializableinit in class AbstractSensorInitExceptionprotected void newData(double raw,
Date time)
newData in class CumulativeSensorpublic void predictFrom(double lastraw)
#KEY_BASE has been made.predictFrom in interface Predictinglastraw - The current raw measurementpublic double regetPredict()
regetPredict in interface Predictingpublic List<Double> getLastPredict(int nr)
getLastPredict in interface Predictingnr - The number of predicted values to be retrieved.Predictingpublic List<Extrapolation> getExtrapolation()
public boolean isPredicting()
extrapolate object is non-null and enough
measurements are already made.isPredicting in interface Predictingpublic boolean isPredictAdvise()
public boolean isReliable()
KEY_CHI key. If this
key points to zero, the sensor is trusted always, otherwise the
χ² per data point must lie below this value for
trustworthyness.isReliable in interface Predictingpublic String getPredictToggleInfo()
protected DataEvent generateDataEvent()
CumulativeDataEvent produced by the parental method. If no
extrapolators are specified, the undisturbed data event, a
CumulativeDataEvent is returned.
If the CumulativeSensor.KEY_PACK property
points to a value greater than one, the data event produced carries the
average of the last predictions.generateDataEvent in class CumulativeSensorPredictiveDataEvent