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

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

public class Scenario
extends java.lang.Object
implements Nameable, Identifiable, Writable

A Scenario contains a collection of Observations that have been made by a user on an ExtendedBN. Each Observation in a Scenario corresponds to one or more ExtendedStates being selected on an ExtendedNode. Where more than one ExtendedState has been selected (i.e. a likelihood has been entered), the Observation will also contain a probability distribution across the selected ExtendedStates. A Scenario can be saved and reloaded at a later date. Once reloaded, it can be applied to the ExtendedBN to which its Observations are connected.


Field Summary
static double version
           
 
Fields inherited from interface uk.co.agena.minerva.util.model.Writable
FIELD_SEPARATOR
 
Constructor Summary
Scenario()
          Default constructor.
Scenario(NameDescription name)
          Creates a Scenario with the specified name.
 
Method Summary
 void addHardEvidenceObservation(int extendedBNId, int extendedNodeId, int stateId)
           
 void addIntegerObservation(int extendedBNId, int extendedNodeId, int value)
           
 void addObservation(Observation observation, boolean allowAutoPropagation)
          Adds the supplied Observation to the end of the List of Observations.
 void addRealObservation(int extendedBNId, int extendedNodeId, double value)
           
 void addScenarioListenerPrimary(ScenarioListener sl)
          Adds an object interested in ScenarioEvents to the List of ScenarioListeners (actually held by an internal ScenarioEventGenerator).
 void addScenarioListenerSecondary(ScenarioListener sl)
          Adds an object interested in ScenarioEvents to the List of ScenarioListeners (actually held by an internal ScenarioEventGenerator).
 void addSoftEvidenceObservation(int extendedBNId, int extendedNodeId, int[] stateIds, double[] probabilities)
           
 void addUserDefinedRevantExtendedBNIds(int[] additionalUserDefinedRelevantExtendedBNIds)
           
 void clearAllObservations()
          Removes all Observations from the Scenario.
 void clearObservationsForNode(int extendedBNId, int extendedNodeId)
          Removes all observations for the supplied BN and Node.
 java.lang.Object clone()
          This method will clone the scenario, and return the copy
 int getDirectObservation(int connExtendedBNId, int connExtendedNodeId)
          Returns the ID of the selected ExtendedState in the ExtendedNode.
 int getId()
          Returns the unique ID of the Scenario.
 NameDescription getName()
          Returns the name of the Scenario.
 Observation getObservation(int connExtendedBNId, int connExtendedNodeId)
          Returns the Observation associated with the supplied ExtendedBN and ExtendedNode IDs.
 java.util.List getObservations()
          Returns a List of all the Observations contained in this Scenario.
 java.util.List getObservations(int connExtendedBNId, int connExtendedNodeId)
          This method will return all observations connected to the specified node in the connected extended BN
 int[] getRelevantExtendedBNIds()
          Returns a list of IDs of all the ExtendedBNs that are related to this Scenario.
 int[] getUserDefinedRelevantExtendedBNIds()
          Returns the user-defined ExtendedBN IDs that are deemed relevant to this Scenario.
 double getVersion()
          Returns the version of the class.
 boolean isDisplayOnRiskGraphs()
           
 boolean isReportable()
          Flag can be toggled by external objects to determine whether the scenario is reportable (the user is interested in seeing its results).
 int read(java.util.List strings, int currentLineNumber)
           
 void removeObservation(Observation ob, boolean allowAutoPropagation)
          This method will remove the specified Observations from the Scenario.
 void removeObservationsForExtendedBN(int exBNId)
          This method will remove all the observations from the scenario that are contaiend within the specified extended BN
 void removeObservationsForNode(int connExtendedBNID, int connExtendedNodeID, int[] DoNotRemoveObservationsOfTheseTypes, boolean allowAutoPropagation)
          This method will remove all Observations in the Scenario that are related to the specified ExtendedNode (determined by its ID, and the ID of the ExtendedBN in which it resides).
 void removeObservationsForNodeExpression(int connExtendedBNID, int connExtendedNodeID, java.lang.String parameterName)
          This method will remove all observations for the specified node that have the same parameter name as the one specified in the third argument
 void removeScenarioListener(ScenarioListener sl)
          Removes an object no longer interested in ScenarioEvents from the List of ScenarioListeners (actually held by an internal ScenarioEventGenerator).
 void setDisplayOnRiskGraphs(boolean displayOnRiskGraphs)
           
 void setId(int id)
          Sets the unique ID of the Scenario to the ID specified.
 void setName(NameDescription name)
          Sets the name of the Scenario to the name specified.
 void setReportable(boolean reportable)
          Flag can be toggled by external objects to determine whether the scenario is reportable (the user is interested in seeing its results).
 void setUserDefinedRelevantExtendedBNIds(int[] userDefinedRelevantExtendedBNIds)
          Sets the user-defined ExtendedBN IDs that are deemed relevant to this Scenario.
 void setVersion(double version)
          Sets the version number of the class.
 java.lang.String toString()
          Returns a String representation of this Scenario.
 void updateExpressionParameterName(int extendedBNID, int extendedNodeID, java.lang.String oldname, java.lang.String newName)
          This method updates all observatins connected to the specified node with the specified parameter expression name, with the new name of the parameter
 void updateUserDefinedRelevantExtendedBNIds(int[] oldExtendedBNIds, int[] newExtendedBNIds)
          Updated the User defined relevant extended BN ids with the two argument arrays.
 void updateUserDefinedRelevantExtendedBNIds(int oldId, int newId)
          Updates an ExtendedBN ID in the array of relevant ones with the new value.
 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, wait, wait, wait
 

Field Detail

version

public static double version
Constructor Detail

Scenario

public Scenario()
Default constructor.


Scenario

public Scenario(NameDescription name)
Creates a Scenario with the specified name.

Method Detail

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

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

setId

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

Parameters:
id - the new ID for the Scenario

getName

public NameDescription getName()
Returns the name of the Scenario.

Specified by:
getName in interface Nameable
Returns:
the name of the Scenario

setName

public void setName(NameDescription name)
Sets the name of the Scenario to the name specified.

Specified by:
setName in interface Nameable
Parameters:
name - the new name for the Scenario

isReportable

public boolean isReportable()
Flag can be toggled by external objects to determine whether the scenario is reportable (the user is interested in seeing its results).


setReportable

public void setReportable(boolean reportable)
Flag can be toggled by external objects to determine whether the scenario is reportable (the user is interested in seeing its results).


getUserDefinedRelevantExtendedBNIds

public int[] getUserDefinedRelevantExtendedBNIds()
Returns the user-defined ExtendedBN IDs that are deemed relevant to this Scenario.

Returns:
the user-defined ExtendedBN IDs that are deemed relevant to this Scenario

setUserDefinedRelevantExtendedBNIds

public void setUserDefinedRelevantExtendedBNIds(int[] userDefinedRelevantExtendedBNIds)
Sets the user-defined ExtendedBN IDs that are deemed relevant to this Scenario.

Parameters:
userDefinedRelevantExtendedBNIds - the user-defined ExtendedBN IDs that are deemed relevant to this Scenario

addUserDefinedRevantExtendedBNIds

public void addUserDefinedRevantExtendedBNIds(int[] additionalUserDefinedRelevantExtendedBNIds)

getObservations

public java.util.List getObservations()
Returns a List of all the Observations contained in this Scenario.

Returns:
a List of Observations

isDisplayOnRiskGraphs

public boolean isDisplayOnRiskGraphs()
Returns:
Returns the displayOnRiskGraphs.

setDisplayOnRiskGraphs

public void setDisplayOnRiskGraphs(boolean displayOnRiskGraphs)
Parameters:
displayOnRiskGraphs - The displayOnRiskGraphs to set.

addRealObservation

public void addRealObservation(int extendedBNId,
                               int extendedNodeId,
                               double value)

addIntegerObservation

public void addIntegerObservation(int extendedBNId,
                                  int extendedNodeId,
                                  int value)

addHardEvidenceObservation

public void addHardEvidenceObservation(int extendedBNId,
                                       int extendedNodeId,
                                       int stateId)

addSoftEvidenceObservation

public void addSoftEvidenceObservation(int extendedBNId,
                                       int extendedNodeId,
                                       int[] stateIds,
                                       double[] probabilities)
                                throws ScenarioException
Throws:
ScenarioException

addObservation

public void addObservation(Observation observation,
                           boolean allowAutoPropagation)
Adds the supplied Observation to the end of the List of Observations. The ID of the Observation will be changed to fit in with the numbering scheme used by the Scenario.

Parameters:
observation - the Observation to be added
allowAutoPropagation - If this flag is set to false Auto Propagation will not occur even if Auto Propagation is ON.

clearObservationsForNode

public void clearObservationsForNode(int extendedBNId,
                                     int extendedNodeId)
Removes all observations for the supplied BN and Node.

Parameters:
extendedBNId - the relevant BN
extendedNodeId - the relevant Node

removeObservationsForNode

public void removeObservationsForNode(int connExtendedBNID,
                                      int connExtendedNodeID,
                                      int[] DoNotRemoveObservationsOfTheseTypes,
                                      boolean allowAutoPropagation)
This method will remove all Observations in the Scenario that are related to the specified ExtendedNode (determined by its ID, and the ID of the ExtendedBN in which it resides). The user can specify if numeric observations are removed too.

Parameters:
connExtendedBNID - The ID of the ExtendedBN in which the ExtendedNode sits
connExtendedNodeID - the ID of the ExtendedNode.

removeObservationsForNodeExpression

public void removeObservationsForNodeExpression(int connExtendedBNID,
                                                int connExtendedNodeID,
                                                java.lang.String parameterName)
This method will remove all observations for the specified node that have the same parameter name as the one specified in the third argument

Parameters:
connExtendedBNID -
connExtendedNodeID -
parameterName -

removeObservationsForExtendedBN

public void removeObservationsForExtendedBN(int exBNId)
This method will remove all the observations from the scenario that are contaiend within the specified extended BN

Parameters:
exBNId -

removeObservation

public void removeObservation(Observation ob,
                              boolean allowAutoPropagation)
This method will remove the specified Observations from the Scenario.

Parameters:
ob - The Observation to remove.

clearAllObservations

public void clearAllObservations()
Removes all Observations from the Scenario.


getObservation

public Observation getObservation(int connExtendedBNId,
                                  int connExtendedNodeId)
                           throws ObservationNotFoundException
Returns the Observation associated with the supplied ExtendedBN and ExtendedNode IDs. 28/1/2005, This method has been updated to ensure that this method will only return the first observation which is NOT a expression parameter value.

Parameters:
connExtendedBNId - the ID of the ExtendedBN with which the Observation is associated
connExtendedNodeId - the ID of the ExtendedNode with which the Observation is associated
Returns:
the appropriate Observation object
Throws:
ObservationNotFoundException - if there is noObservation associated with the ExtendedNode ID

getDirectObservation

public int getDirectObservation(int connExtendedBNId,
                                int connExtendedNodeId)
                         throws ObservationNotDirectException,
                                ObservationNotFoundException,
                                ObservationNotInitialisedException
Returns the ID of the selected ExtendedState in the ExtendedNode. This method is only appropriate if the Observation associated with the ExtendedNode has been made on a single ExtendedState (rather than a likelihood across more than one ExtendedState). This methid isgnores observations whose ansswer mapping is OBSERVATION_TYPE_EXPRESSION_VARIABLE

Parameters:
connExtendedBNId - the ID of the ExtendedBN with which the Observation is associated
connExtendedNodeId - the ID of the ExtendedNode with which the Observation is associated
Returns:
the ID of the ExtendedState selected in the Observation or -1 if there is no direct observation on the ExtendedNode.
Throws:
ObservationNotDirectException - if there is no direct observation on the specified ExtendedNode
ObservationNotFoundException - if an Observation for the specified ExtendedNode does not exist
ObservationNotInitialisedException - if the Observation has no data

getObservations

public java.util.List getObservations(int connExtendedBNId,
                                      int connExtendedNodeId)
This method will return all observations connected to the specified node in the connected extended BN

Parameters:
connExtendedBNId -
connExtendedNodeId -
Returns:

clone

public java.lang.Object clone()
This method will clone the scenario, and return the copy

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

getRelevantExtendedBNIds

public int[] getRelevantExtendedBNIds()
Returns a list of IDs of all the ExtendedBNs that are related to this Scenario. The returned List contains the ExtendedBNs that the Observations of this Scenario are linked to and also the user-defined ExtendedBN IDs.

Returns:
a list of IDs of all the ExtendedBNs that are related to this Scenario

addScenarioListenerPrimary

public void addScenarioListenerPrimary(ScenarioListener sl)
Adds an object interested in ScenarioEvents to the List of ScenarioListeners (actually held by an internal ScenarioEventGenerator).

Parameters:
sl - the interested ScenarioListener

addScenarioListenerSecondary

public void addScenarioListenerSecondary(ScenarioListener sl)
Adds an object interested in ScenarioEvents to the List of ScenarioListeners (actually held by an internal ScenarioEventGenerator). These get added to the end of the list being secondary.

Parameters:
sl - the interested ScenarioListener

removeScenarioListener

public void removeScenarioListener(ScenarioListener sl)
Removes an object no longer interested in ScenarioEvents from the List of ScenarioListeners (actually held by an internal ScenarioEventGenerator).

Parameters:
sl - the ScenarioListener no longer interested

toString

public java.lang.String toString()
Returns a String representation of this Scenario.

Overrides:
toString in class java.lang.Object
Returns:
the short description of this Scenario

updateUserDefinedRelevantExtendedBNIds

public void updateUserDefinedRelevantExtendedBNIds(int oldId,
                                                   int newId)
Updates an ExtendedBN ID in the array of relevant ones with the new value. This is called whenever an ExtendedBN's ID has changed (and thus needs to be updated in the array).

Parameters:
oldId - the old ExtendedBN ID
newId - the new ExtendedBN ID

updateExpressionParameterName

public void updateExpressionParameterName(int extendedBNID,
                                          int extendedNodeID,
                                          java.lang.String oldname,
                                          java.lang.String newName)
This method updates all observatins connected to the specified node with the specified parameter expression name, with the new name of the parameter

Parameters:
extendedBNID -
extendedNodeID -
oldname -
newName -

updateUserDefinedRelevantExtendedBNIds

public void updateUserDefinedRelevantExtendedBNIds(int[] oldExtendedBNIds,
                                                   int[] newExtendedBNIds)
Updated the User defined relevant extended BN ids with the two argument arrays.

Parameters:
oldExtendedBNIds -
newExtendedBNIds -

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.