uk.co.agena.minerva.model
Class Propagation

java.lang.Object
  extended by uk.co.agena.minerva.model.Propagation
All Implemented Interfaces:
java.util.EventListener, uk.co.agena.minerva.model.corebn.CoreBNListener, Progressable
Direct Known Subclasses:
MinervaPropagation

public abstract class Propagation
extends java.lang.Object
implements Progressable, uk.co.agena.minerva.model.corebn.CoreBNListener

This class encapsulates propagation algorithms in which multiple Scenarios may be applied in different ways to a set of ExtendedBNs over a sequence of time periods. The Propagation class cannot be directly instantiated; instead, a sub-class must be created that defines the actual propagation properties and behaviour. Major changes to the structure and order of propagation made on 30/9/04


Nested Class Summary
 class Propagation.PropagationEventGenerator
          The PropagationEventGenerator is used to inform listeners of events relating to propagation.
 
Field Summary
static java.lang.String BASIC_PROPAGATION
           
static java.lang.String DD_PROPAGATION
           
protected  boolean inconsistentEvidencePropagated
          We need to monitor if there has been any inconsistent evidence propagated.
protected  int lengthOfProgressableTask
          Represnts the length of the operation which is currently being monitored in this class.
protected  Model model
          This is the Model on which to do the propagation.
static boolean ONLY_PROPAGATE_MODIFIED_EXTENDEDBNS
          Propagation will only deal with ExtendedBN's which have been modified if this flag is true.
protected  int progress
          Represnts the current progress of any operation which is currently being monitored in this class.
protected  boolean progressableTaskDone
          When set to true the current task being monitored will have been completed.
protected  Propagation.PropagationEventGenerator propagationEventGenerator
          Event generator used for firing events relating to propagation.
protected  boolean terminateProgressableTask
          When set to true the current propagation will be terminated/cancelled.
 
Constructor Summary
Propagation(Model model)
          Contructs a Propagation object that relates to the specified Model.
 
Method Summary
 void addCoreBNListeners()
          Adds this as a Listener to each of the CoreBN's associated with the ExtendedBN's in the current models ExtendedBNList.
 void addPropagationListener(PropagationListener pl)
          Adds an object interested in PropagationEvents to the List of PropagationListeners (actually held by an internal PropagationEventGenerator).
protected  void calculateLengthOfProgressableTask(java.util.List extendedBNsToCalculate)
          Calculates the length of a propagation task based upon the Scenario's and ExtendedBN's being propagated.
 void coreBNPropagationStageComplete(uk.co.agena.minerva.model.corebn.CoreBNEvent cbne)
          A stage of the Propagation has completed for the CoreBN in the specified event.
 void destroy()
           
 java.lang.String doesBasicChecksPass()
          This method should run some basic check that need to pass before the propagation can continue.
 int getCurrentProgress()
          Represents the current progress of any operation which is currently being monitored in this class.
 int getEstimatedNumberOfCalculations()
          This method is used to intomathe user of the number
 int getLengthOfProgressableTask()
          The length of the propagation task.
 boolean isProgressableTaskDone()
          When set to true the current task being monitored will have been completed.
 void modelInconsistentEvidencePropagated(ModelEvent ebne)
           
protected abstract  void propagateScenario(java.util.List extendedbns, Scenario scenario, boolean propagate, int propagationExclusivity)
           
 void removeCoreBNListeners()
          Removes this as a Listener to each of the CoreBN's associated with the ExtendedBN's in the current models ExtendedBNList.
 void removePropagationListener(PropagationListener pl)
          Removes an object no longer interested in PropagationEvents from the List of PropagationListeners (actually held by an internal PropagationEventGenerator).
 void resetProgressableTask()
          Reset the variables used in the monitoring of the current propagation.
 java.util.List restartDataCollectionStore(boolean onlyModifiedBns, java.util.List specifiedExtendedBNs)
          This method should be called always at the start of the simulate method to restart the data collection store.
 int revertAllExtendedBNsToSavedMarginals(int revertToSavedMarginals)
          Returns all ExtendedBNs to a state stored during propagation if there is one.
 void rollBackCores()
           
 java.util.Map setupExpressionVariableNodesFromScenario(Scenario scenario, ExtendedBNList extendedBNList)
           
 void setupMessagePasses(MessagePassingLinks mplink, int noOfPassesToReactTo, boolean touchTable)
          Sets up parameter passes among ExtendedNodes as defined in the supplied MessagePassingLinks object.
 void simulate(java.util.List extendedBNsToUse)
           
 void simulate(java.util.List scenarios, java.util.List extendedBNsToUse)
          Propagates using a given list of scenarios if the model allows this.
 void simulateCheckPoint()
          This method should be used to check if the marginals have changed from the last propagation, and if it should continue to Dynamically Discretise Nodes before it starts doing so.
 void terminateProgressableTask()
          Stop the current propagation.
 void unmarkExpressionVariableNodes(java.util.Map extendedNodesToRecalculateVarExpressionToBNMap)
           
 void updateCurrentProgress(int inc)
          Increment the currentProgress by the specified value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

model

protected Model model
This is the Model on which to do the propagation. This contains the relevant ExtendedBNs, and Scenarios. The List of Scenarios in the Model are applied at every iteration of the algorithm (over time) in the order in which they feature in the Model's ScenarioList.


lengthOfProgressableTask

protected int lengthOfProgressableTask
Represnts the length of the operation which is currently being monitored in this class.


progress

protected int progress
Represnts the current progress of any operation which is currently being monitored in this class.


progressableTaskDone

protected boolean progressableTaskDone
When set to true the current task being monitored will have been completed.


terminateProgressableTask

protected boolean terminateProgressableTask
When set to true the current propagation will be terminated/cancelled.


propagationEventGenerator

protected Propagation.PropagationEventGenerator propagationEventGenerator
Event generator used for firing events relating to propagation.


inconsistentEvidencePropagated

protected boolean inconsistentEvidencePropagated
We need to monitor if there has been any inconsistent evidence propagated.


DD_PROPAGATION

public static java.lang.String DD_PROPAGATION

BASIC_PROPAGATION

public static java.lang.String BASIC_PROPAGATION

ONLY_PROPAGATE_MODIFIED_EXTENDEDBNS

public static final boolean ONLY_PROPAGATE_MODIFIED_EXTENDEDBNS
Propagation will only deal with ExtendedBN's which have been modified if this flag is true. Change this to false if you require all ExtendedBNs to be propagated. NOTE: Added as a requirement to bug1785.

See Also:
Constant Field Values
Constructor Detail

Propagation

public Propagation(Model model)
Contructs a Propagation object that relates to the specified Model.

Parameters:
model - the Model to which the Propagation relates
Method Detail

destroy

public void destroy()

restartDataCollectionStore

public java.util.List restartDataCollectionStore(boolean onlyModifiedBns,
                                                 java.util.List specifiedExtendedBNs)
This method should be called always at the start of the simulate method to restart the data collection store. This will ensure that all the old data is got rid off and new data is stored during propagation.


getEstimatedNumberOfCalculations

public int getEstimatedNumberOfCalculations()
This method is used to intomathe user of the number

Returns:

doesBasicChecksPass

public java.lang.String doesBasicChecksPass()
This method should run some basic check that need to pass before the propagation can continue.

Parameters:
updateStringInformation - This string should be updated by this method, to provide information to the user about why the checks may not have passed.
Returns:
true = everythings ok, false = something is not right and requires users attention.

simulate

public void simulate(java.util.List scenarios,
                     java.util.List extendedBNsToUse)
              throws PropagationException,
                     InconsistentEvidenceException,
                     PropagationTerminatedException
Propagates using a given list of scenarios if the model allows this. The model has a flag called PropagateUsingModelScenarios, if this is true then the default set of scenarios in the model are used (ignoring the parameter passed list of scenarios). If this is false then the argument scenarios in the model are temprarily replaced in the model, for propagation, then returned to their original values.

Parameters:
scenarios -
Throws:
PropagationException
InconsistentEvidenceException
PropagationTerminatedException

addPropagationListener

public void addPropagationListener(PropagationListener pl)
Adds an object interested in PropagationEvents to the List of PropagationListeners (actually held by an internal PropagationEventGenerator).

Parameters:
pl - the intereseted PropagationListeners

removePropagationListener

public void removePropagationListener(PropagationListener pl)
Removes an object no longer interested in PropagationEvents from the List of PropagationListeners (actually held by an internal PropagationEventGenerator).

Parameters:
pl - the PropagationListeners no longer interested

modelInconsistentEvidencePropagated

public void modelInconsistentEvidencePropagated(ModelEvent ebne)

setupMessagePasses

public void setupMessagePasses(MessagePassingLinks mplink,
                               int noOfPassesToReactTo,
                               boolean touchTable)
                        throws PropagationException
Sets up parameter passes among ExtendedNodes as defined in the supplied MessagePassingLinks object.

Parameters:
mplink - the MessagePassingLinks object that defines the parameter passing
noOfPassesToReactTo - defines how many times the listening ExtendedNode should react to a change in the sending ExtendedNode's marginals
touchTable - defines whether the change in the marginals of the sending node should be treated by the listening node as soft evidence (false) or as a setting of the NPT (true)
Throws:
PropagationException - if there is a problem setting up the parameter passing

revertAllExtendedBNsToSavedMarginals

public int revertAllExtendedBNsToSavedMarginals(int revertToSavedMarginals)
                                         throws PropagationException,
                                                InconsistentEvidenceException
Returns all ExtendedBNs to a state stored during propagation if there is one. This should be called before each simulation.

Parameters:
revertToSavedMarginals - the index of the saved marginals that should be restoredw
Returns:
the index of the Scenario from which the simulation should start
Throws:
PropagationException - if there is a problem with reverting
InconsistentEvidenceException

rollBackCores

public void rollBackCores()
                   throws ExtendedBNException,
                          InconsistentEvidenceException
Throws:
ExtendedBNException
InconsistentEvidenceException

simulateCheckPoint

public void simulateCheckPoint()
This method should be used to check if the marginals have changed from the last propagation, and if it should continue to Dynamically Discretise Nodes before it starts doing so. The standard simulation method writes to a Marginal DataStore which is held in the Model. What we need to do is to create another Marginals DataStore of a basic propagation then compare the two. If the two are diffrent then we need to proceed with a full DD propagation, otherwise do nothing (i.e. the evidence and marginals haven't changed). In order to do this without changing the propagation algorithm to write to another MDS, what we need to is: - Move the existing MDS to a temporary location - create a new MDS where the old one used to be - create a basic MinervaPropagation object (so that DD calculations are not run) - propagate the basic algorithm (this will cause the new MDS to fill up) - Now compare the old/new MDS. If the marginals in both are the same then do nothing, else run a full DD propagation. - BUT, before we do the propagation, we should destroy the temporary/new MDS and put the old/original back in its original position


simulate

public void simulate(java.util.List extendedBNsToUse)
              throws PropagationException,
                     InconsistentEvidenceException,
                     PropagationTerminatedException
Throws:
PropagationException
InconsistentEvidenceException
PropagationTerminatedException

propagateScenario

protected abstract void propagateScenario(java.util.List extendedbns,
                                          Scenario scenario,
                                          boolean propagate,
                                          int propagationExclusivity)
                                   throws ModelException,
                                          PropagationException,
                                          InconsistentEvidenceException,
                                          PropagationTerminatedException
Throws:
ModelException
PropagationException
InconsistentEvidenceException
PropagationTerminatedException

setupExpressionVariableNodesFromScenario

public java.util.Map setupExpressionVariableNodesFromScenario(Scenario scenario,
                                                              ExtendedBNList extendedBNList)
                                                       throws MinervaVariableException,
                                                              InconsistentEvidenceException,
                                                              ExtendedBNException,
                                                              MinervaRangeException,
                                                              NPTGeneratorInsufficientStateRangeException,
                                                              NPTGeneratorException
Throws:
MinervaVariableException
InconsistentEvidenceException
ExtendedBNException
MinervaRangeException
NPTGeneratorInsufficientStateRangeException
NPTGeneratorException

unmarkExpressionVariableNodes

public void unmarkExpressionVariableNodes(java.util.Map extendedNodesToRecalculateVarExpressionToBNMap)
                                   throws InconsistentEvidenceException,
                                          ExtendedBNException,
                                          MinervaRangeException,
                                          NPTGeneratorInsufficientStateRangeException,
                                          NPTGeneratorException
Throws:
InconsistentEvidenceException
ExtendedBNException
MinervaRangeException
NPTGeneratorInsufficientStateRangeException
NPTGeneratorException

getCurrentProgress

public int getCurrentProgress()
Represents the current progress of any operation which is currently being monitored in this class.

Specified by:
getCurrentProgress in interface Progressable
Returns:
The current progress value (int)

getLengthOfProgressableTask

public int getLengthOfProgressableTask()
The length of the propagation task.

Specified by:
getLengthOfProgressableTask in interface Progressable
Returns:
The length of the task being monitored as an int.

terminateProgressableTask

public void terminateProgressableTask()
Stop the current propagation.

Specified by:
terminateProgressableTask in interface Progressable

isProgressableTaskDone

public boolean isProgressableTaskDone()
When set to true the current task being monitored will have been completed.

Specified by:
isProgressableTaskDone in interface Progressable
Returns:
The status of the done flag which should be set to indicate the task is over whether is has been terminated or finished.

resetProgressableTask

public void resetProgressableTask()
Reset the variables used in the monitoring of the current propagation.

Specified by:
resetProgressableTask in interface Progressable

calculateLengthOfProgressableTask

protected void calculateLengthOfProgressableTask(java.util.List extendedBNsToCalculate)
Calculates the length of a propagation task based upon the Scenario's and ExtendedBN's being propagated. The final value is used as the lengthOfTask required for this Progressable object. This may be overridden if a more accurate value will be calculated.

Parameters:
extendedBNsToCalculate - The ExtendedBN's being propagated.

updateCurrentProgress

public void updateCurrentProgress(int inc)
Increment the currentProgress by the specified value.

Parameters:
inc - The amount by which we are updating the Current Progress.

removeCoreBNListeners

public void removeCoreBNListeners()
Removes this as a Listener to each of the CoreBN's associated with the ExtendedBN's in the current models ExtendedBNList.


addCoreBNListeners

public void addCoreBNListeners()
Adds this as a Listener to each of the CoreBN's associated with the ExtendedBN's in the current models ExtendedBNList.


coreBNPropagationStageComplete

public void coreBNPropagationStageComplete(uk.co.agena.minerva.model.corebn.CoreBNEvent cbne)
A stage of the Propagation has completed for the CoreBN in the specified event. We must update the progress appropiatly.

Specified by:
coreBNPropagationStageComplete in interface uk.co.agena.minerva.model.corebn.CoreBNListener
Parameters:
The - CoreBNEvent holding a reference to the source CoreBN.


Copyright © 2006 Agena Ltd. All Rights Reserved.