uk.co.agena.minerva.model.scenario
Class Observation

java.lang.Object
  extended by uk.co.agena.minerva.model.scenario.Observation
All Implemented Interfaces:
Identifiable, Writable

public class Observation
extends java.lang.Object
implements Identifiable, Writable

An Observation stores evidence that has been entered on a node in a BN. This evidence can either be a single selected state or a likelihood distribution across multiple states. Observations can be created by answering Questions or by entering numerical values (for nodes that are either absolute or interval).


Field Summary
static int DEFAULT_CERTAINTY
          The value representing certainty an ExtendedState that has been observed with certainty.
static int OBSERVATION_TYPE_EXPRESSION_VARIABLE
           
static int OBSERVATION_TYPE_LONG_ANSWER
          Represents an Observation that has been made using the long name of an Answer.
static int OBSERVATION_TYPE_NUMERIC
          Represents an Observation that has been made using a numerical value.
static int OBSERVATION_TYPE_SHORT_ANSWER
          Represents an Observation that has been made using the short name of an Answer.
static double version
           
 
Fields inherited from interface uk.co.agena.minerva.util.model.Writable
FIELD_SEPARATOR
 
Constructor Summary
Observation()
          Default constructor.
Observation(int connExtendedBNId, int connExtendedNodeId, int connQuestionnaireId, DataSet dataset, int userEnteredAnswerMapping, java.lang.String userEnteredAnswer)
          Creates a fully specified Observation.
Observation(int connExtendedBNId, int connExtendedNodeId, int connQuestionnaireId, DataSet dataset, int userEnteredAnswerMapping, java.lang.String userEnteredAnswer, java.lang.String uniqueExNodeIdWhenCreated, int numExNodeStatesWhenCreated)
          Creates a fully specified Observation including unique ID of connected node and number of states of connected node.
 
Method Summary
 java.lang.Object clone()
          This method will clone the observation, and return the new;y cloned object
 int getConnExtendedBNId()
          Returns the ID of the ExtendedBN to which the Observation is connected.
 int getConnExtendedNodeId()
          Returns the ID of the ExtendedNode to which the Observation is connected.
 int getConnQuestionnaireId()
          Returns the ID of the Questionnaire to which the Observation is connected.
 DataSet getDataSet()
          Returns the DataSet containing the actual observation data.
 int getDirectObservation()
          Returns the ID of the selected ExtendedState state associated with this Observation.
 java.lang.String getExpressionVariableName()
           
 int getId()
          Returns the unique ID of the Observation.
 int getNumExNodeStatesWhenCreated()
           
 java.lang.String getUniqueExNodeIdWhenCreated()
           
 java.lang.String getUserEnteredAnswer()
          Returns the answer entered by the user if one exists.
 int getUserEnteredAnswerMapping()
          Returns the mapping that is used to interpret the user-entered answer.
 double getVersion()
          Returns the version of the class.
 boolean isDirectObservation()
          Determines whether there is a direct Observation i.e.
 int read(java.util.List strings, int currentLineNumber)
           
 void setConnExtendedBNId(int id)
          Sets the ID of the ExtendedBN to which the Observation is connected.
 void setConnExtendedNodeId(int id)
          Sets the ID of the ExtendedNode to which the Observation is connected.
 void setConnQuestionnaireId(int id)
          Sets the ID of the Questionnaire to which the Observation is connected.
 void setDataSet(DataSet dataSet)
          Sets the DataSet containing the actual observation data.
 void setExpressionVariableName(java.lang.String expressionVariableName)
           
 void setId(int id)
          Sets the unique ID of the Observation to the ID specified.
 void setNumExNodeStatesWhenCreated(int numExNodeStatesWhenCreated)
           
 void setUniqueExNodeIdWhenCreated(java.lang.String uniqueExNodeIdWhenCreated)
           
 void setUserEnteredAnswer(java.lang.String userEnteredAnswer)
          Sets the user-entered answer for this Observation.
 void setUserEnteredAnswerMapping(int userEnteredAnswerMapping)
          Sets the mapping that is used to interpret the user-entered answer.
 void setVersion(double version)
          Sets the version number of the class.
 java.util.List write()
          Writes the object in question to a List of Strings.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static double version

DEFAULT_CERTAINTY

public static final int DEFAULT_CERTAINTY
The value representing certainty an ExtendedState that has been observed with certainty.

See Also:
Constant Field Values

OBSERVATION_TYPE_SHORT_ANSWER

public static int OBSERVATION_TYPE_SHORT_ANSWER
Represents an Observation that has been made using the short name of an Answer.


OBSERVATION_TYPE_LONG_ANSWER

public static int OBSERVATION_TYPE_LONG_ANSWER
Represents an Observation that has been made using the long name of an Answer.


OBSERVATION_TYPE_NUMERIC

public static int OBSERVATION_TYPE_NUMERIC
Represents an Observation that has been made using a numerical value.


OBSERVATION_TYPE_EXPRESSION_VARIABLE

public static int OBSERVATION_TYPE_EXPRESSION_VARIABLE
Constructor Detail

Observation

public Observation()
Default constructor.


Observation

public Observation(int connExtendedBNId,
                   int connExtendedNodeId,
                   int connQuestionnaireId,
                   DataSet dataset,
                   int userEnteredAnswerMapping,
                   java.lang.String userEnteredAnswer)
Creates a fully specified Observation.

Parameters:
connExtendedBNId - the ID of the connected ExtendedBN
connExtendedNodeId - the ID of the connected ExtendedNode
connQuestionnaireId - the ID of the connected Questionnaire
dataset - the DataSet containing the Observation data
userEnteredAnswerMapping - indicates how the userEnteredAnswer parameter should be interpreted
userEnteredAnswer - the actual answer information entered by the user

Observation

public Observation(int connExtendedBNId,
                   int connExtendedNodeId,
                   int connQuestionnaireId,
                   DataSet dataset,
                   int userEnteredAnswerMapping,
                   java.lang.String userEnteredAnswer,
                   java.lang.String uniqueExNodeIdWhenCreated,
                   int numExNodeStatesWhenCreated)
Creates a fully specified Observation including unique ID of connected node and number of states of connected node.

Parameters:
connExtendedBNId - the ID of the connected ExtendedBN
connExtendedNodeId - the ID of the connected ExtendedNode
connQuestionnaireId - the ID of the connected Questionnaire
dataset - the DataSet containing the Observation data
userEnteredAnswerMapping - indicates how the userEnteredAnswer parameter should be interpreted
userEnteredAnswer - the actual answer information entered by the user
uniqueExNodeIdWhenCreated - the unique ID of the connected node as it stands when the Observation is created.
numExNodeStatesWhenCreated - the number of states in the connected node as it stands when the Observation is created.
Method Detail

getNumExNodeStatesWhenCreated

public int getNumExNodeStatesWhenCreated()

setNumExNodeStatesWhenCreated

public void setNumExNodeStatesWhenCreated(int numExNodeStatesWhenCreated)

getUniqueExNodeIdWhenCreated

public java.lang.String getUniqueExNodeIdWhenCreated()

setUniqueExNodeIdWhenCreated

public void setUniqueExNodeIdWhenCreated(java.lang.String uniqueExNodeIdWhenCreated)

getVersion

public double getVersion()
Description copied from interface: Writable
Returns the version of the class. Used to ensure backward compatibility.

Specified by:
getVersion in interface Writable
Returns:
the version number

setVersion

public void setVersion(double version)
Description copied from interface: Writable
Sets the version number of the class. Used to ensure backward compatibility.

Specified by:
setVersion in interface Writable
Parameters:
version - the version number

getId

public int getId()
Returns the unique ID of the Observation.

Specified by:
getId in interface Identifiable
Returns:
the unique ID of the Observation

setId

public void setId(int id)
Sets the unique ID of the Observation to the ID specified.

Parameters:
id - the new ID for the Observation

getConnExtendedBNId

public int getConnExtendedBNId()
Returns the ID of the ExtendedBN to which the Observation is connected.

Returns:
the associated ExtendedBN ID

setConnExtendedBNId

public void setConnExtendedBNId(int id)
Sets the ID of the ExtendedBN to which the Observation is connected.

Parameters:
id - the associated ExtendedBN ID

getConnExtendedNodeId

public int getConnExtendedNodeId()
Returns the ID of the ExtendedNode to which the Observation is connected.

Returns:
the associated ExtendedNode ID

setConnExtendedNodeId

public void setConnExtendedNodeId(int id)
Sets the ID of the ExtendedNode to which the Observation is connected.

Parameters:
id - the associated ExtendedNode ID

getConnQuestionnaireId

public int getConnQuestionnaireId()
Returns the ID of the Questionnaire to which the Observation is connected.

Returns:
the associated Questionnaire ID

setConnQuestionnaireId

public void setConnQuestionnaireId(int id)
Sets the ID of the Questionnaire to which the Observation is connected.

Parameters:
id - the associated Questionnaire ID

getDataSet

public DataSet getDataSet()
Returns the DataSet containing the actual observation data.

Returns:
the DataSet containing the actual observation data

getExpressionVariableName

public java.lang.String getExpressionVariableName()
Returns:
Returns the expressionVariableName.

setExpressionVariableName

public void setExpressionVariableName(java.lang.String expressionVariableName)
Parameters:
expressionVariableName - The expressionVariableName to set.

setDataSet

public void setDataSet(DataSet dataSet)
Sets the DataSet containing the actual observation data. The ID of the DataSet is changed to fit in with the internal numbering scheme used by the Observation.

Parameters:
dataSet - the new DataSet

clone

public java.lang.Object clone()
This method will clone the observation, and return the new;y cloned object

Overrides:
clone in class java.lang.Object
Returns:
The cloned observation

isDirectObservation

public boolean isDirectObservation()
                            throws ObservationNotInitialisedException
Determines whether there is a direct Observation i.e. whether the Observation only involves a single state with a probability attribute equal to 1 rather than a likelihood distribution across multiple states or a probability attribute not equal to 1.

Returns:
true if there is one DataPoint in the Observation's DataSet with a value of 1, false otherwise
Throws:
ObservationNotInitialisedException - if the Observation has not been initialised

getDirectObservation

public int getDirectObservation()
                         throws ObservationNotDirectException,
                                ObservationNotInitialisedException
Returns the ID of the selected ExtendedState state associated with this Observation. This method is only appropriate if the Observation involves a single State (rather than a likelihood across more than one ExtendedState) i.e. if a call to isDirectObservation returns true. In most cases, Observations are of this kind which is why this convenience method exists.

Returns:
the ID of the ExtendedState selected in the Observation
Throws:
ObservationNotDirectException - if the Observation is not direct
ObservationNotInitialisedException - if the Observation has no data

getUserEnteredAnswer

public java.lang.String getUserEnteredAnswer()
Returns the answer entered by the user if one exists.

Returns:
the value of the entered answer

setUserEnteredAnswer

public void setUserEnteredAnswer(java.lang.String userEnteredAnswer)
Sets the user-entered answer for this Observation.

Parameters:
userEnteredAnswer - the value of the entered answer or an empty String

getUserEnteredAnswerMapping

public int getUserEnteredAnswerMapping()
Returns the mapping that is used to interpret the user-entered answer. The value will be one of: OBSERVATION_TYPE_SHORT_ANSWER, OBSERVATION_TYPE_LONG_ANSWER or OBSERVATION_TYPE_NUMERIC.

Returns:
the mapping type

setUserEnteredAnswerMapping

public void setUserEnteredAnswerMapping(int userEnteredAnswerMapping)
Sets the mapping that is used to interpret the user-entered answer.

Parameters:
userEnteredAnswerMapping - the new mapping type

write

public java.util.List write()
                     throws MinervaReadWriteException
Description copied from interface: Writable
Writes the object in question to a List of Strings.

Specified by:
write in interface Writable
Returns:
the List to which the Strings have been written
Throws:
MinervaReadWriteException - if there

read

public int read(java.util.List strings,
                int currentLineNumber)
         throws MinervaReadWriteException
Specified by:
read in interface Writable
Throws:
MinervaReadWriteException


Copyright © 2006 Agena Ltd. All Rights Reserved.