public class WorkingMemory
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
protected class |
WorkingMemory.AVEntry |
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_HISTORY_SIZE
This constant defines maximal number of states stored in the
historyLog. |
| Constructor and Description |
|---|
WorkingMemory()
Default constructor for the working memory object.
|
| Modifier and Type | Method and Description |
|---|---|
State |
findHistoricalState(java.util.LinkedList<State> states,
RelativeTimestamp rt)
It returns the historical state from the point in time indicated by the #rt parameter.
|
Value |
findHistoricalValue(java.util.LinkedList<State> states,
java.lang.String attributeName,
RelativeTimestamp rt)
It returns the historical value of the attribute which name was passed as the parameter from
the point in time indicated by the #rt parameter.
|
java.util.LinkedList<Value> |
findHistoricalValues(java.util.LinkedList<State> states,
RelativeTimePeriod period,
java.lang.String attributeName)
The methods searches for values of an attribute given as a parameter in a specified time period.
|
AmbiguityResolver |
getAmbiguityResolver()
Returns ambiguity resolver that is currently set.
|
Attribute |
getAttribute(java.lang.String attributeName) |
Value |
getAttributeValue(Attribute attr)
The method return a value of an attribute of a given name.
|
Value |
getAttributeValue(java.lang.String attributeName)
The method return a value of an attribute of a given name.
|
State |
getCurrentState()
The method returns values of all registered attributes in a form of
State object. |
State |
getCurrentState(XTTModel model)
Returns the state of the system only for the registered attributes within the model
|
long |
getCurrentTimestamp() |
java.util.LinkedList<State> |
getHistoryLog()
It returns the entire history log with all the records made.
|
State |
getSnapshot(java.lang.String snapshotName)
It returns the state that represents the snapshot of a given name.
|
java.util.LinkedList<State> |
getSnapshots()
The method returns list of all snapshots made with the
makeSnapshot(String)
method. |
boolean |
isTimeLocked() |
void |
lockTime() |
void |
makeSnapshot(java.lang.String snapshotName)
The method makes a snapshot of a current system state, by saving all the values of the registered attributes.
|
void |
recordLog()
It saves the state of the system at the time of the method is being call
to the history log.
|
void |
registerAllAttributes(XTTModel model)
It registers all attributes from a given model
Registering and unregistering is based on attributes names, not object refferences.
|
void |
registerAttribute(Attribute attribute)
It registers the attribute that later will be accessible and will be included in snapshots and current state.
|
void |
registerAttribute(java.lang.String name,
XTTModel model)
It registers the attribute that later will be accessible and will be included in snapshots and current state.
|
void |
resolveAmbiguousAttributesValues()
A method that resolves all the ambiguous assignments that are present in the working memory.
|
void |
setAmbiguityResolver(AmbiguityResolver ar)
The method sets ambiguity resolver that resolves ambiguous assignments
of values to the same attribute.
|
void |
setAttributeValue(Attribute attribute,
Value value,
boolean autoregister)
The method sets a given value to the attribute which is passed as a parameter.
|
void |
setAttributeValue(java.lang.String attributeName,
Value value)
The method sets a given value to the attribute which name is passed as a parameter.
|
void |
setCurrentState(State state,
XTTModel model,
boolean autoregister)
The method sets values of the attributes defined by state parameter.
|
protected void |
setCurrentTimestamp(long currentTimestamp) |
void |
unlockTime() |
void |
unregisterAll(XTTModel model)
The method unregisters all the attribute from a model given as a parameter.
|
void |
unregisterAttribute(java.lang.String name)
It unregisters the attribute of a given name.
|
public static final int MAX_HISTORY_SIZE
historyLog.
This limit does not apply to snapshots.public WorkingMemory()
public void setCurrentState(State state, XTTModel model, boolean autoregister) throws NotInTheDomainException, AttributeNotRegisteredException
state - a state to be setmodel - the model from which the attributes values re to be setautoregister - the parameter indicating if the method should register all the attributes from the model (if true) or none (if false).NotInTheDomainExceptionAttributeNotRegisteredExceptionpublic State getCurrentState()
State object.public State getCurrentState(XTTModel model)
model - a model which attributes should be returned as a statepublic void registerAttribute(Attribute attribute)
attribute - an attribute to be registeredpublic void registerAttribute(java.lang.String name,
XTTModel model)
name - a name of the attribute to registermodel - a model where the attribute is locatedpublic void registerAllAttributes(XTTModel model)
model - a model from which the attributes have to be regiseredpublic void unregisterAttribute(java.lang.String name)
name - a name of the attribute to unregisterpublic void unregisterAll(XTTModel model)
model - a model with attributes to unregisterpublic Attribute getAttribute(java.lang.String attributeName)
public Value getAttributeValue(java.lang.String attributeName)
Null is returned.attributeName - the attribute name which value is neededNull id the attribute is not registeredpublic Value getAttributeValue(Attribute attr)
Null is returned.attr - the attribute which value is neededpublic Value findHistoricalValue(java.util.LinkedList<State> states, java.lang.String attributeName, RelativeTimestamp rt)
states - list of states where the value of the attribute is searchedattributeName - the name of the attribute which value should be foundrt - the number of states or milliseconds (counting backward from current state) where the search
should beginNull if such value does not existpublic State findHistoricalState(java.util.LinkedList<State> states, RelativeTimestamp rt)
states - list of states where the value of the attribute is searchedrt - the number of states or milliseconds (counting backward from current state) where the search
should beginpublic java.util.LinkedList<Value> findHistoricalValues(java.util.LinkedList<State> states, RelativeTimePeriod period, java.lang.String attributeName)
states - list of states where the value of the attribute is searchedperiod - relative time periodattributeName - name of the attribute which values has to be foundpublic void setAttributeValue(java.lang.String attributeName,
Value value)
throws AttributeNotRegisteredException,
NotInTheDomainException
AttributeNotRegisteredException is thrown.attributeName - name of the attribute which value has to be setvalue - the value to setAttributeNotRegisteredExceptionNotInTheDomainExceptionpublic void setAttributeValue(Attribute attribute, Value value, boolean autoregister) throws AttributeNotRegisteredException, NotInTheDomainException
AttributeNotRegisteredException is thrown in case
when autoregister is set to false. In case when autoregister is set to true, the Attribute will be automatically
registered in Working Memory registry.attribute - the attribute which value has to be setvalue - the value to setautoregister - the parameter indicating if the method should register the attribute (if true) or none (if false).AttributeNotRegisteredExceptionNotInTheDomainExceptionpublic void resolveAmbiguousAttributesValues()
InferenceAlgorithm.onPostExecute() method.
Before the reasoning, the ambiguity resolution is performed with the ambiguity resolver provided for the inference process.
This methods clears the ambiguous values list.public void setAmbiguityResolver(AmbiguityResolver ar)
isTimeLocked() returns true.
For other cases, calling setAttributeValue(String, Value)
would override current attribute value without making the assignment ambiguous,
even if called several times.ar - Ambiguity resolver to be used. By default it is DefaultAmbiguityResolverpublic AmbiguityResolver getAmbiguityResolver()
#setAmbiguityResolver(AmbiguityResolver)}public void makeSnapshot(java.lang.String snapshotName)
recordLog() method.snapshotName - the name of the snapshot.public State getSnapshot(java.lang.String snapshotName)
snapshotName - a name of the snapshot to returnpublic void recordLog()
makeSnapshot(String) method
as the logs are more anonymous, as they cannot have custom names, and what is more
logs may be recorded automatically be the logging mechanism, whereas snapshots
can only be made by the programmer explicitly with the makeSnapshot(String) call.public java.util.LinkedList<State> getHistoryLog()
recordLog() method.public java.util.LinkedList<State> getSnapshots()
makeSnapshot(String)
method.public long getCurrentTimestamp()
protected void setCurrentTimestamp(long currentTimestamp)
public void lockTime()
public void unlockTime()
public boolean isTimeLocked()