uk.co.agena.minerva.model
Class Model

java.lang.Object
  extended by uk.co.agena.minerva.model.Model
All Implemented Interfaces:
java.util.EventListener, ExtendedBNListener, PropagationListener, uk.co.agena.minerva.model.questionnaire.QuestionnaireListener, ScenarioListener, FamilyMember, Identifiable, Nameable, NamedFamilyMember, Writable

public class Model
extends java.lang.Object
implements ScenarioListener, ExtendedBNListener, uk.co.agena.minerva.model.questionnaire.QuestionnaireListener, NamedFamilyMember, PropagationListener, Writable

This class encapsulates all of the ExtendedBNs, Scenarios and Questionnaires in an application and mediates all interaction between them.


Field Summary
static int APPLY_SCENARIO_EXCLUDE_NODES
          Indicates that a Scenario should be applied to all specified ExtendedNodes in a given ExtendedBN except those specified.
static int APPLY_SCENARIO_EXCLUSIVELY
          Indicates that before a Scenario is applied to any ExtendedBN which this Scenario affects, all other evidence is removed.
static int APPLY_SCENARIO_INCLUDE_ONLY_NODES
          Indicates that a Scenario should only be applied to the specified ExtendedNodes in a given ExtendedBN.
static int APPLY_SCENARIO_INEXCLUSIVELY
          Indicates that before a Scenario is applied to any ExtendedBN in this model, all other evidence is left in the ExtendedBN; the new Scenario is applied "on top of" any existing evidence.
static int APPLY_SCENARIO_MODEL_EXCLUSIVELY
          Indicates that before a Scenario is applied to any ExtendedBN in this model, all other evidence is removed.
static int APPLY_SCENARIO_NO_SPECIFIC_NODES
          Indicates that a Scenario should be applied to all ExtendedNodes in a given ExtendedBN.
static int SCENARIO_IMPORT_NODE_NOT_FOUND
           
static int SCENARIO_IMPORT_WRONG_NODE_ID
           
static int SCENARIO_IMPORT_WRONG_STATES_UNWORKABLE
           
static int SCENARIO_IMPORT_WRONG_STATES_WORKABLE
           
static double version
           
 
Fields inherited from interface uk.co.agena.minerva.model.PropagationListener
successfulSimulationCompletion
 
Fields inherited from interface uk.co.agena.minerva.util.model.Writable
FIELD_SEPARATOR
 
Constructor Summary
Model()
          Default constructor.
 
Method Summary
 int addExtendedBN(ExtendedBN ebn)
          Adds the supplied ExtendedBN to the Model.
 int addExtendedBN(ExtendedBN ebn, boolean compiled)
          Adds the supplied ExtendedBN to the Model's ExtendedBNList and compiles it (if required and if it is not already compiled).
 int addExtendedBN(ExtendedBN ebn, boolean compiled, boolean fireMergeModelEvent)
          Adds the supplied ExtendedBN to the Model's ExtendedBNList and compiles it (if required and if if it is not already compiled).
 ExtendedBN addExtendedBN(java.lang.String name, java.lang.String description)
          Creates an empty BN with the supplied name and description and adds it to this model's list.
 int[] addExtendedBNs(java.util.List extendedBNs, boolean compiled)
          Adds the supplied List of ExtendedBNs to this Model's List of ExtendedBNs and compiles them (if required and if if they are not already compiled).
 int[] addExtendedBNs(java.util.List extendedBNs, boolean compiled, boolean fireMergeModelEvent)
          Adds the supplied List of ExtendedBNs to this Model's List of ExtendedBNs and compiles them (if required and if if they are not already compiled).
 boolean addMessageParseLink(ExtendedNode sourceNode, ExtendedBN targetexBN)
          This method will create a new message parse link from the specified source node, and the selected target BN a Clone of the source node will be created and added to the target BN in order to create the link.
 void addMessageParseLink(ExtendedNode sourceNode, ExtendedNode targetNode)
          This method will add the specified message parssing link to the model.
 void addMessagePassingLinks(java.util.List newMessagePassingLinks, boolean fireMergeModelEvent)
          Adds the supplied MessagePassingLinks objects to the Model's List.
 void addModelListener(ModelListener ebnl)
          Adds an object interested in ModelEvents to the List of ModelListeners (actually held by an internal ModelEventGenerator).
 void addQuestionnaire(uk.co.agena.minerva.model.questionnaire.Questionnaire questionnaire)
          Adds the supplied Questionnaire to the Model's QuestionnaireList.
 void addQuestionnaire(uk.co.agena.minerva.model.questionnaire.Questionnaire questionnaire, boolean fireMergeModelEvent)
          Adds the supplied Questionnaire to the Model's QuestionnaireList.
 void addQuestionnaires(java.util.List questionnaires)
          Adds the supplied Questionnaires to the Model's QuestionnaireList.
 void addQuestionnaires(java.util.List questionnaires, boolean fireMergeModelEvent)
          Adds the supplied Questionnaires to the Model's QuestionnaireList.
 void addScenario(Scenario scenario, boolean fireScenarioAddedEvent, java.lang.Object ebnOrMDI)
          Adds a scenario to the model
 void addScenario(Scenario scenario, java.lang.Object ebnOrMDI)
          Adds the supplied Scenario to the Model's ScenarioList.
 Scenario addScenario(java.lang.String name)
           
 void addScenarios(java.util.List scenarios)
          Adds the supplied Scenarios to the Model's ScenarioList.
 void addScenarios(java.util.List scenarios, boolean fireMergeModelEvent)
           
 void applyScenario(Scenario scenario, boolean propagate, int exclusivity, boolean useClosestMedianIfPossible)
          Applies the Scenario to all the relevant ExtendedBNs in this Model.
 void applyScenario(Scenario scenario, boolean propagate, int exclusivity, java.util.List extendedBNs2applyOn, boolean useClosestMedianIfPossible)
          Applies the Scenarios only to the ExtendedBNs contained in the supplied List.
 void applyScenario(Scenario scenario, boolean propagate, int exclusivity, java.util.List extendedBNs2applyOn, boolean overrideCallSign, java.lang.String[] overridingCallSigns, boolean useClosestMedianIfPossible)
          Applies the Scenarios only to the ExtendedBNs contained in the supplied List using the supplied call sign information.
 void applyScenario(Scenario scenario, boolean propagate, int exclusivity, java.util.List extendedBNs2applyOn, int incl_excl, java.lang.String[] nodes2Incl_Excl, boolean overrideCallSign, java.lang.String[] overridingCallSigns, boolean useClosestMedianIfPossible)
          Applies the Scenarios only to the ExtendedBNs contained in the supplied list using the supplied call sign information and information about which nodes to include and exclude.
 void autoGenerateMessagePassingLinks(ExtendedBN rootBN, ExtendedBN targetBN)
          Automatically generates MessagePassingLinks objects between the supplied ExtendedBNs depending on their input and output nodes.
 void autoLinkBNOs()
          This method uses the generic link generator and the link generator property uk.co.agena.minervaapps.basicminerva.linkgenerator in the minerva.properties file to generate the message passing8 links on this model between the BNO's.
 void calculate()
           
 void calculate(java.util.List scenarios)
           
 void calculate(java.util.List scenarios, java.util.List exbns)
           
 java.lang.String checkBasicPropagationRequirements(java.lang.String propagationType)
          This method will call the propagation algorithm to do some basic checks.
 void checkCreationTimestamps(java.lang.String licenceType)
          Check the difference between the creation timestamp, stored in the CoreBN's associated with this model, and the current time does not exceed a certain limit.
 void clearAllObservations()
          Clears all observations in this model.
 void clearAllObservations(ExtendedBN ebn)
          Clears all the observations for a given ExtendedBN.
 void clearObservations(boolean onlyActiveScenarios)
          Removes all the Observations for all the ExtendedBNs in this Model.
 void clearObservations(ExtendedBN ebn, boolean onlyActiveScenarios)
          Removes all the observations for a given ExtendedBN.
 void clearProblemNodes()
          Empties out the list of problem nodes.
 void compileAllExtendedBNs()
          Compiles all ExtendedBNs in the Model.
 boolean containsDDNodes()
           
 void copyQuestions(java.util.List sourceQuestions, java.util.List targetQuestions, java.lang.String counter, int targetBNID, int targetNodeID)
          Copy the properties of the source Questions to those of the target Questions.
static Model createEmptyModel()
           
static Model createModelFromNetFile(java.lang.String loadFromNetFile)
          Creates a new model adding the net file in the string
 java.util.List createModificationLogsInreleventBNs(java.util.List effectedExBns, ModelEvent me, NameDescription nd)
          Locates the extended Bns that require a modifcation log, and creates them.
 void createMPLinksFromFile(java.lang.String linkMappingfilename)
          Message passing links are created using a configuration file.
static uk.co.agena.minerva.model.questionnaire.Questionnaire createQuestionnaireFromExtendedBN(ExtendedBN extendedbn)
          Creates a default Questionnaire from the supplied ExtendedBN.
 void deleteExtendedBN(ExtendedBN ebn)
          Deletes the supplied BN from the model.
 void deleteExtendedBNs(java.util.List ebns)
          Removes the BNs in the supplied list from the model.
 void deleteScenario(Scenario scenario)
          Deletes the supplied Scenario from the model.
 void deleteScenarios(java.util.List scenarios)
          Removes the Scenarios in the supplied list from the model.
 void destroy()
          Removes this Model as a listener from all Scenarios, Questionnaires and ExtendedBNs.
 void extendedBNAboutToBePropagated(ExtendedBNEvent ebne)
          Not currently implemented
 void extendedBNAllEvidenceRetracted(ExtendedBNEvent ebne)
          Not currently implemented.
 void extendedBNConnBNNotFound(ExtendedBNEvent ebne)
          Loads up the relevant CoreBN when it is required and when its ExtendedBN has informed listeners that it is not present.
 void extendedBNIDChanged(ExtendedBNEvent ebne)
          Changes the connected IDs on Questions, Observations and MessagePassingLinks objects in response to the ID on an ExtendedBN changing.
 void extendedBNInconsistentEvidencePropagated(ExtendedBNEvent ebne)
          Responds to inconsistent evidence being propagated on one of this Model's ExtendedBNs.
 void extendedBNNameDescriptionChanged(ExtendedBNEvent ebne)
          Tells all registered listeners that this Model has changed (in response to the name of one of its ExtendedBNs having changed).
 void extendedBNPropagated(ExtendedBNEvent ebne)
          Not currently implemented.
 void extendedNodeAboutToBeCut(ExtendedBNEvent ebne, ExtendedBN sourceEXBN, int targetEXNodeID, int sourceEXNodeID, java.lang.String nameCounter)
          This event is fired when an ExtendedNode has been pasted to the destination ExtendedBN and is about to be cut from the specified source ExtendedBN.
 void extendedNodeAdded(ExtendedBNEvent ebne, ExtendedNode exNode)
          This event is fired when ever a new node has been added to the extendedBN.
 void extendedNodeEventFired(ExtendedBNEvent ebne, ExtendedNodeEvent ene, java.lang.String eventName)
          Event received from the extended BN Invoked whenever the extended BN recieves a BN Node event, this event throws the event up to any listeners on the extended BN.
 void extendedNodePasted(ExtendedBNEvent ebne, ExtendedBN sourceEXBN, ExtendedNode sourceNode, ExtendedNode exNode)
          Extended Node pasted event, fired by the extended BN
 void extendedNodeRemoved(ExtendedBNEvent ebne, ExtendedNode exnode)
          Extended Node removed event, fired by the extended BN
 void extendedNodeReplaced(ExtendedBNEvent ebne, ExtendedNode oldNode, ExtendedNode newNode, ExtendedBN ebn)
          This event is fired whenever a node is replaced with another one.
 java.util.List findIdentifiables(java.lang.String className, java.lang.String searchTerm)
          Searches for all Identifiable objects of the supplied class using the supplied search term.
 void fireModelChangedEvent(Model model, int eventType, java.util.List eventAttributes)
          Fires a model changed event with the specified parameters
static uk.co.agena.minerva.model.questionnaire.Question generateQuestionFromNode(ExtendedBN extendedbn, ExtendedNode extendedNode)
           
 java.util.Set getAncestorExtendedBNs(ExtendedBN ebn)
          This method will use the MessagePassingLinks to get all the Ancestors of the argument ExtendedBN This is done recursively using the getParentExtendedBNs method.
 java.util.List getChildren()
          Returns the children of this Model.
 java.util.List getChildrenExtendedBNs(ExtendedBN ebn)
          This method uses the message passing links to return a list of the children ExtendedBNs of the argument BN.
 java.util.Map getCoreFilenamesToCoreBNs()
           
 java.util.Set getDecendentExtendedBNs(ExtendedBN ebn)
          This method will use the MessagePassingLinks to get all the decendents of the argument ExtendedBN This is done recursively using the getChildrenExtendedBNs method.
 ExtendedBN getExtendedBNAtIndex(int index)
          Returns the BN at the supplied index in the model's list of BNs.
 ExtendedBN getExtendedBNForNode(ExtendedNode node)
           
 ExtendedBNList getExtendedBNList()
          Returns this Model's ExtendedBNList.
 java.util.List getExtendedBNs(int[] ebnIds)
          Returns all ExtendedBNs corresponding to the supplied IDs.
 ExtendedBN getExtendedBNWithName(java.lang.String name)
          Returns the BN with the supplied name.
 ExtendedNode getExtendedNodeWithName(java.lang.String name)
           
 java.lang.String getFullyQualifiedPathForNode(ExtendedNode exNode)
          Returns a string that contains the full path of the selected node: mdiPath.exbnName
 int getId()
          Returns the ID of this Model.
 java.util.List getListOfOrderedMessagePassingLinksLists()
          Returns the MessagePassingLinks objects associated with this Model as a set of Lists, such that each List contains MessagePassingLinks objects that have the same priority level.
 MarginalDataStore getMarginalDataStore()
           
 MessagePassingLinks getMessageParseLinkWithID(int id)
          Returns the message parse link with the specified ID
 java.util.List getMessagePassingLinks()
          Return's this Model's List of MessagePassingLinks objects.
protected  java.util.List getMessagePassingLinksForChild(int childId)
          Returns the MessagePassingLinks objects that have the ExtendedBN with the supplied ID as a child.
 java.util.List getMessagePassingLinksForParent(int parentId)
          Returns the MessagePassingLinks objects that have the ExtendedBN with the supplied ID as a parent.
 uk.co.agena.minerva.model.metadata.MetaData getMetaData()
           
 NameDescription getName()
          Returns the name of this Model.
 java.util.List getNetFileAestheticData()
          Returns a List holding the aesthetic data relating to nodes of a .net file such as x and y co-ordinates.
 Notes getNotes()
          Tne notes set connected to the model
 java.util.List getParentExtendedBNs(ExtendedBN ebn)
          This method uses the message passing links to return a list of the parent ExtendedBNs of the argument BN.
 int getParentId()
          Returns the parent ID of this Model
 java.util.List getProblemNodes()
           
 Propagation getPropagationAlgorithm()
          This is the propagation algorithm that will be used for this model.
 int getPropagationCalculationEstimate()
          Returns the estimated number of calculations required by the propagation algorithm.
 uk.co.agena.minerva.model.questionnaire.QuestionnaireList getQuestionnaireList()
          Returns this Model's QuestionnaireList.
 java.util.List getQuestionnaires(int[] qIds)
          Returns all Questionnaires corresponding to the supplied IDs.
 int getRankedSampleSize()
           
 int getSampleSize()
           
 Scenario getScenarioAtIndex(int index)
          Returns the Scenario at the supplied index in the model's list of Scenarios.
 ScenarioList getScenarioList()
          Returns this Model's ScenarioList.
 java.util.List getScenarios(int[] sIds)
          Returns all Scenarios corresponding to the supplied IDs.
 Scenario getScenarioWithName(java.lang.String name)
          Returns the Scenario with the supplied name in the list of the model's Scenarios.
 double getSimulationEntropyConvergenceTolerance()
           
 double getSimulationEvidenceTolerancePercent()
           
 int getSimulationNoOfIterations()
           
 java.util.List getUnmarkedMessagePassingExtendedBNs()
          Gets all the ExtendedBNs that are not flagged to have been visted by the MessagePassing algorithm.
 java.util.List getUnmatchedNodeNames()
           
 double getVersion()
          Returns the version of the class.
 void importScenarios(ScenarioList sl)
          Takes the supplied list of Scenarios and adds them to the Model.
 boolean isAllParentExtendedBNsMarkedForMessagePassing(ExtendedBN extendedBN)
           
 boolean isFireUpExtendedNodeEvent()
           
 boolean isMetaDataUsed()
           
 boolean isPropagateUsingModelScenarios()
           
 boolean isSimulationLogging()
           
 void link(ExtendedNode source, ExtendedNode target)
          Links the two ExtendedNodes together, thereby linking the two containing ExtendedBNs.
static Model load(java.lang.String filename)
          Loads the model from the supplied file.
 void loadScenariosFromCSV(java.util.List csvStrings)
          Takes the supplied set of CSV strings, creates scenarios from it and loads them into the Model (replacing any existing scenarios).
 java.util.List LocateModelObjectsNoConnectedToMetaDataItems(boolean removeUnConnectedScenarios, boolean removeUnConnectedQuestionnaires, boolean removeUnconnectedExtendedBNs)
          This method will itterate over the model items (Extended BNs, scenarios and questionnaires), and add to a return list all those that are not connected to any of the meta data objects connected to the model.
 void merge(Model model, boolean destroyArgumentModel, boolean useArgumentModelMetaData, uk.co.agena.minerva.model.metadata.MetaDataItem mdiToPlaceMergedItemUnder)
          Merges the supplied Model into this one, by adding its Questionnaires, ExtendedBNs, Scenarios and MessagePassingLinks objects.
 void observationsAdded(ScenarioEvent se, java.util.List obs, boolean allowAutoPropagation)
          Gets the Observations from the supplied ScenarioEvent and enters them into the relevant ExtendedBN.
 void observationsRemoved(ScenarioEvent se, java.util.List obs, boolean autopropagate)
          Gets the Observations from the supplied ScenarioEvent and removes them from the current relevant ExtendedBNs in the model.
 void propagate(java.util.List scenarios, java.util.List extendedBNsToUse)
          This method should be called to propagate the model.
 void propagateAllExtendedBNs(boolean fireUpExtendedNodeEvents)
          Propagates all ExtendedBNs in this Model's ExtendedBNList.
 void propagateDDAlgorithm(java.util.List scenarios)
          This method will propagate all extendedBNs as normal.
 void propagateDDAlgorithm(java.util.List scenarios, java.util.List exbns, boolean local, boolean withAncestors)
          This method will be call the DD propagation after deriving which ExtendedBNs to actually propagate dependent on its arguments.
 void propagationIncremented(PropagationEvent ebne, int timePeriodPropagated)
          Fired whenever a cycle of a Propagation has finished.
 void questionAdded(uk.co.agena.minerva.model.questionnaire.QuestionnaireEvent qe, uk.co.agena.minerva.model.questionnaire.Question q)
          This event is fired whenever a new question is added to the questionnaire
 void questionEventFired(uk.co.agena.minerva.model.questionnaire.QuestionnaireEvent qte, uk.co.agena.minerva.model.questionnaire.QuestionEvent qe, int eventType)
          This event is fired up to the questionnaire listeners when the questionnaire receives an event from one of its questions.
 void questionnaireChanged(uk.co.agena.minerva.model.questionnaire.QuestionnaireEvent ebne)
          Event fired by questionnaires
 void questionnaireIDChanged(uk.co.agena.minerva.model.questionnaire.QuestionnaireEvent qe)
          Informs all Observations within this Model when the ID for a connected Questionnaire changes.
 void questionsRemoved(uk.co.agena.minerva.model.questionnaire.QuestionnaireEvent qe, java.util.List questions)
          Fired whenever one or more questions are removed from a questionnaire.
 int read(java.util.List strings, int currentLineNumber)
           
 void regenerateProblemNPTs()
          Checks the list of problem nodes and, if there are any, regenerates their NPTs.
 void reinitialiseAllExtendedBNs()
          Reinitialises all ExtendedBNs in this Model's ExtendedBNList.
 void removeAllMessageParsesBetweenBNs(ExtendedBN source, ExtendedBN target)
          This method removes all MessagePassingLinks objects that exist between the two specified ExtendedBNs.
 void removeAllMessagePassesForBN(int extendedBNId)
          Given the ID of an ExtendedBN, this method will then remove all the MessagePassingLinks objects that are associated with it.
 void removeAllMessagePassLinks()
          Removes all message passing links
 void removeAllTracesOfExtendedNode(ExtendedBN ebn, ExtendedNode enode)
          Removes the supplied ExtendedNode from its ExtendedBN.
 void removeCrossMDIMessagePassingLinks()
          This method will remove all Message Passing links that exist between ExtendedBNs of 2 different Metadataitems.
 void removeExtendedBNs(ExtendedBN exBN, boolean invokeDestroy)
          Convinence method for the remove extended BNs, takes a single BN, calls the list based remove extended Bns
 void removeExtendedBNs(java.util.List extendedBNs, boolean invokeDestroy)
          Removes a specified ExtendedBN from this Model.
 void removeMessageParseLinks(ExtendedNode sourceNode, ExtendedNode targetNode)
          Removes all message parsing links between the specified nodes
 void removeModelListener(ModelListener ebnl)
          Removes an object no longer interested in ModelEvents from the List of ModelListeners (actually held by an internal ModelEventGenerator).
 void removeModificationLogsFoeExBNs(java.util.List exBNs)
          This method will remove the inconsitency logs for the specified BNs
 void removeQuestionnaire(uk.co.agena.minerva.model.questionnaire.Questionnaire q)
          This method will remove the selected questionnaire from the model.
 void removeScenario(Scenario scenario)
           
 void resetAllScenarios()
          Removes all Observations from all Scenarios.
 void retractAllEvidence()
          Retracts evidence from all ExtendedBNs in this Model.
 void save(java.lang.String filename)
          Saves the model to the specified file
 void saveCreationTimestamp(java.lang.String licenceType)
          Stores a time stamp in the each of the CoreBN's associated with this model.
 void scenarioAttributeChanged(ScenarioEvent se, int attribute)
          Fired whenever an attribute of the scenario is modified
 void setChildren(java.util.List children)
          Sets the children for this Model.
 void setCoreFilenamesToCoreBNs(java.util.Map coreFilenamesToCoreBNs)
           
 void setDefaultScenario()
          Creates scenarios for each of the metadataitems extendedbns for those which do not have any connected scenarios.
 void setExtendedBnList(java.util.List extendedBns)
          Sets the ExtendedBNs for this Model.
 void setFireUpExtendedNodeEvent(boolean fireUpExtendedNodeEvent)
           
 void setId(int id)
          Sets the ID of this Model.
 void setMarginalDataStore(MarginalDataStore marginalDataStore)
           
 void setMessagePassingLinks(java.util.List messagePassingLinks)
          Sets the MessagePassingLinks objects associated with this Model.
 void setMetaData(uk.co.agena.minerva.model.metadata.MetaData metaData)
           
 void setMetaDataUsed(boolean b)
           
 void setName(NameDescription name)
          Sets the name of this Model.
 void setNetFileAestheticData(java.util.List netFileAestheticData)
           
 void setNotes(Notes notes)
          Tne notes set connected to the model
 void setParentId(int parentId)
          Sets the parent ID of this Model.
 void setProblemNodes(java.util.List problemNodeNames)
           
 void setPropagateUsingModelScenarios(boolean propagateUsingModelScenarios)
           
 void setPropagationAlgorithm(Propagation p)
          This is the propagation algorithm that will be used for this model.
 void setQuestionnaireList(java.util.List questionnaires)
          Sets the Questionnaires for this Model.
 void setRankedSampleSize(int rankedSampleSize)
           
 void setSampleSize(int sampleSize)
           
 void setScenarioList(java.util.List scenarios)
          Sets this Model's ScenarioList
 void setSimulationEntropyConvergenceTolerance(double simulationEntropyConvergenceTolerance)
           
 void setSimulationEvidenceTolerancePercent(double simulationEvidenceTolerancePercent)
           
 void setSimulationLogging(boolean simulationLogging)
           
 void setSimulationNoOfIterations(int simulationNoOfIterations)
           
 void setUnmatchedNodeNames(java.util.List unmatchedNodeNames)
           
 void setUpMetaData(uk.co.agena.minerva.model.metadata.MetaData metaData, java.util.List ids, java.util.Map typesConnections)
           
 void setupNonRecursiveParameterPasses(MessagePassingLinks mplinks, int noOfPassesAllowed, boolean forceSetNPT, boolean savePrior, boolean changeStatesOnInputNodeIfRequired)
          Same as setupParameterPasses but only for non recursive links
 void setupParameterPasses(MessagePassingLinks mplinks, int noOfPassesAllowed, boolean forceSetNPT, boolean savePrior, boolean changeStatesOnInputNodeIfRequired)
          Connects the two supplied ExtendedBNs together so that information can be passed between them.
 void setupRecursiveParameterPasses(MessagePassingLinks mplinks, int noOfPassesAllowed, boolean forceSetNPT, boolean savePrior, boolean changeStatesOnInputNodeIfRequired)
          Same as setupParameterPasses but only for recursive links
 void setUpScenarios()
          Ensures that Scenarios are set up correctly once a Model has been loaded in.
 void setVersion(double version)
          Sets the version number of the class.
 void shiftQuestionnaireInModelList(uk.co.agena.minerva.model.questionnaire.Questionnaire q, uk.co.agena.minerva.model.questionnaire.Questionnaire relationQ, int moveDirection)
          This method will reorder the specified questionnaire in the model list of questionnaires and reorder it in the connected meta data layer
 void simulationFinished(PropagationEvent ebne, boolean completedSuccessfully, java.util.List propagatedExtendedBNs)
          Fired whenever an execution of a Propagation has finished.
 void simulationStarted(PropagationEvent msmpe)
          Fired whenever an execution of a Propagation is about to be Started.
 void synchroniseQuestionAnswersToNodeStates(ExtendedBN exBN, ExtendedNode exNode)
          This method will locate all questions connected to the specified node, and ensure that if the question is configured to auto synchronise the answers to the states in the connected node then it there is indeed a 1-1 mapping
 void updateNewAndImportedBNsTimestamps(java.util.List bns)
          The CoreBN's being added/imported into this model need to have the creation timestamps set to be identical to those CoreBN's currently in the Model.
 java.util.List write()
          Writes the object in question to a List of Strings.
 java.util.List writeMarginalsToCSV()
          Writes the marginals in the model to a List of CSV strings that can be saved to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static double version

APPLY_SCENARIO_MODEL_EXCLUSIVELY

public static final int APPLY_SCENARIO_MODEL_EXCLUSIVELY
Indicates that before a Scenario is applied to any ExtendedBN in this model, all other evidence is removed.

See Also:
Constant Field Values

APPLY_SCENARIO_EXCLUSIVELY

public static final int APPLY_SCENARIO_EXCLUSIVELY
Indicates that before a Scenario is applied to any ExtendedBN which this Scenario affects, all other evidence is removed.

See Also:
Constant Field Values

APPLY_SCENARIO_INEXCLUSIVELY

public static final int APPLY_SCENARIO_INEXCLUSIVELY
Indicates that before a Scenario is applied to any ExtendedBN in this model, all other evidence is left in the ExtendedBN; the new Scenario is applied "on top of" any existing evidence.

See Also:
Constant Field Values

APPLY_SCENARIO_NO_SPECIFIC_NODES

public static int APPLY_SCENARIO_NO_SPECIFIC_NODES
Indicates that a Scenario should be applied to all ExtendedNodes in a given ExtendedBN.


APPLY_SCENARIO_INCLUDE_ONLY_NODES

public static int APPLY_SCENARIO_INCLUDE_ONLY_NODES
Indicates that a Scenario should only be applied to the specified ExtendedNodes in a given ExtendedBN.


APPLY_SCENARIO_EXCLUDE_NODES

public static int APPLY_SCENARIO_EXCLUDE_NODES
Indicates that a Scenario should be applied to all specified ExtendedNodes in a given ExtendedBN except those specified.


SCENARIO_IMPORT_WRONG_NODE_ID

public static final int SCENARIO_IMPORT_WRONG_NODE_ID
See Also:
Constant Field Values

SCENARIO_IMPORT_WRONG_STATES_WORKABLE

public static final int SCENARIO_IMPORT_WRONG_STATES_WORKABLE
See Also:
Constant Field Values

SCENARIO_IMPORT_WRONG_STATES_UNWORKABLE

public static final int SCENARIO_IMPORT_WRONG_STATES_UNWORKABLE
See Also:
Constant Field Values

SCENARIO_IMPORT_NODE_NOT_FOUND

public static final int SCENARIO_IMPORT_NODE_NOT_FOUND
See Also:
Constant Field Values
Constructor Detail

Model

public Model()
Default constructor.

Method Detail

createEmptyModel

public static Model createEmptyModel()
                              throws ModelException
Returns:
Throws:
ModelException

createModelFromNetFile

public static Model createModelFromNetFile(java.lang.String loadFromNetFile)
                                    throws ModelException
Creates a new model adding the net file in the string

Parameters:
netfile -
compile -
Returns:
Throws:
ModelException

createQuestionnaireFromExtendedBN

public static uk.co.agena.minerva.model.questionnaire.Questionnaire createQuestionnaireFromExtendedBN(ExtendedBN extendedbn)
Creates a default Questionnaire from the supplied ExtendedBN. For each ExtendedNode in the ExtendedBN, a Question with the same long and short description is added to the Questionnaire. Similarly, for each ExtendedState an Answer (with the same short and long description as the ExtendedState) is added to the appropriate Question.

Parameters:
extendedbn - the ExtendedBN from which the Questionnaire is to be created
Returns:
the created Questionnaire

generateQuestionFromNode

public static uk.co.agena.minerva.model.questionnaire.Question generateQuestionFromNode(ExtendedBN extendedbn,
                                                                                        ExtendedNode extendedNode)

setDefaultScenario

public void setDefaultScenario()
Creates scenarios for each of the metadataitems extendedbns for those which do not have any connected scenarios.


propagate

public void propagate(java.util.List scenarios,
                      java.util.List extendedBNsToUse)
               throws PropagationException,
                      InconsistentEvidenceException,
                      PropagationTerminatedException
This method should be called to propagate the model. The user can specify a specific list of scenarios to be propagated if required, for example when a specific MetaDataItem is required to be propagated. If this is required then the model must also have the propagateUsingModelScenarios flag to be false. If null is provided as the argument then all the scenarios in the model are used.

Parameters:
scenarios - enter null to use all the scenarios available in the model.
Throws:
PropagationException
InconsistentEvidenceException
PropagationTerminatedException

propagateDDAlgorithm

public void propagateDDAlgorithm(java.util.List scenarios)
                          throws InconsistentEvidenceException,
                                 PropagationException,
                                 PropagationTerminatedException
This method will propagate all extendedBNs as normal.

Parameters:
exbns - This is a list of extendedBns to propagate
local - This should be true if the user has requested a local propagation
withAncestors - If this is a local propagation it may also want to include its ancestors, then this should be true
Throws:
PropagationTerminatedException
PropagationException
InconsistentEvidenceException

calculate

public void calculate()
               throws InconsistentEvidenceException,
                      PropagationException,
                      PropagationTerminatedException
Throws:
InconsistentEvidenceException
PropagationException
PropagationTerminatedException

calculate

public void calculate(java.util.List scenarios)
               throws InconsistentEvidenceException,
                      PropagationException,
                      PropagationTerminatedException
Throws:
InconsistentEvidenceException
PropagationException
PropagationTerminatedException

calculate

public void calculate(java.util.List scenarios,
                      java.util.List exbns)
               throws InconsistentEvidenceException,
                      PropagationException,
                      PropagationTerminatedException
Throws:
InconsistentEvidenceException
PropagationException
PropagationTerminatedException

propagateDDAlgorithm

public void propagateDDAlgorithm(java.util.List scenarios,
                                 java.util.List exbns,
                                 boolean local,
                                 boolean withAncestors)
                          throws InconsistentEvidenceException,
                                 PropagationException,
                                 PropagationTerminatedException
This method will be call the DD propagation after deriving which ExtendedBNs to actually propagate dependent on its arguments.

Parameters:
exbns - This is a list of extendedBns to propagate
local - This should be true if the user has requested a local propagation
withAncestors - If this is a local propagation it may also want to include its ancestors, then this should be true
Throws:
PropagationTerminatedException
PropagationException
InconsistentEvidenceException

containsDDNodes

public boolean containsDDNodes()
Returns:
true if the model contains any DD nodes; false otherwise.

getCoreFilenamesToCoreBNs

public java.util.Map getCoreFilenamesToCoreBNs()

setCoreFilenamesToCoreBNs

public void setCoreFilenamesToCoreBNs(java.util.Map coreFilenamesToCoreBNs)

getPropagationCalculationEstimate

public int getPropagationCalculationEstimate()
Returns the estimated number of calculations required by the propagation algorithm.

Returns:

checkBasicPropagationRequirements

public java.lang.String checkBasicPropagationRequirements(java.lang.String propagationType)
This method will call the propagation algorithm to do some basic checks. It will just return the values that are returned by the method in the propagation classes.

Parameters:
propagationType - The type of propagation we are dealing with.
Returns:
A String holding the information about the issue the user must act upon; null or "" if there are no issues.

getNetFileAestheticData

public java.util.List getNetFileAestheticData()
Returns a List holding the aesthetic data relating to nodes of a .net file such as x and y co-ordinates. The reference in the Model class to the List is then destroyed.

Returns:
List containing aesthetic data relating to the nodes of a net file.

setNetFileAestheticData

public void setNetFileAestheticData(java.util.List netFileAestheticData)

getId

public int getId()
Returns the ID of this Model.

Specified by:
getId in interface Identifiable
Returns:
the ID of this Model

setId

public void setId(int id)
Sets the ID of this Model.

Parameters:
id - the new Model ID

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

getProblemNodes

public java.util.List getProblemNodes()

setProblemNodes

public void setProblemNodes(java.util.List problemNodeNames)

getParentId

public int getParentId()
Returns the parent ID of this Model

Specified by:
getParentId in interface FamilyMember
Returns:
the parent ID of this Model

setParentId

public void setParentId(int parentId)
Sets the parent ID of this Model.

Specified by:
setParentId in interface FamilyMember
Parameters:
parentId - the new parent ID for this Model

getName

public NameDescription getName()
Returns the name of this Model.

Specified by:
getName in interface Nameable
Returns:
the name of this Model

setName

public void setName(NameDescription name)
Sets the name of this Model.

Specified by:
setName in interface Nameable
Parameters:
name - the new name of this Model

getNotes

public Notes getNotes()
Tne notes set connected to the model

Returns:

setNotes

public void setNotes(Notes notes)
Tne notes set connected to the model


getChildren

public java.util.List getChildren()
Returns the children of this Model.

Specified by:
getChildren in interface FamilyMember
Returns:
the children of this Model

setChildren

public void setChildren(java.util.List children)
Sets the children for this Model.

Specified by:
setChildren in interface FamilyMember
Parameters:
children - the new children for this Model

getRankedSampleSize

public int getRankedSampleSize()
Returns:
Returns the rankedSampleSize.

setRankedSampleSize

public void setRankedSampleSize(int rankedSampleSize)
Parameters:
rankedSampleSize - The rankedSampleSize to set.

getSampleSize

public int getSampleSize()
Returns:
Returns the sampleSize.

setSampleSize

public void setSampleSize(int sampleSize)
Parameters:
sampleSize - The sampleSize to set.

getSimulationEntropyConvergenceTolerance

public double getSimulationEntropyConvergenceTolerance()
Returns:
Returns the simulationEntropyConvergenceTolerance.

setSimulationEntropyConvergenceTolerance

public void setSimulationEntropyConvergenceTolerance(double simulationEntropyConvergenceTolerance)
Parameters:
simulationEntropyConvergenceTolerance - The simulationEntropyConvergenceTolerance to set.

getSimulationEvidenceTolerancePercent

public double getSimulationEvidenceTolerancePercent()
Returns:
Returns the simulationEvidenceTolerancePercent.

setSimulationEvidenceTolerancePercent

public void setSimulationEvidenceTolerancePercent(double simulationEvidenceTolerancePercent)
Parameters:
simulationEvidenceTolerancePercent - The simulationEvidenceTolerancePercent to set.

getSimulationNoOfIterations

public int getSimulationNoOfIterations()
Returns:
the number of simulation iterations

setSimulationNoOfIterations

public void setSimulationNoOfIterations(int simulationNoOfIterations)
Parameters:
simulationNoOfIterations - the number of simulation iterations to set

isSimulationLogging

public boolean isSimulationLogging()
Returns:
Returns the simulationLogging.

setSimulationLogging

public void setSimulationLogging(boolean simulationLogging)
Parameters:
simulationLogging - The simulationLogging to set.

merge

public void merge(Model model,
                  boolean destroyArgumentModel,
                  boolean useArgumentModelMetaData,
                  uk.co.agena.minerva.model.metadata.MetaDataItem mdiToPlaceMergedItemUnder)
           throws ModelException,
                  InconsistentEvidenceException,
                  uk.co.agena.minervaapps.basicminerva.linkgenerator.LinkModelException
Merges the supplied Model into this one, by adding its Questionnaires, ExtendedBNs, Scenarios and MessagePassingLinks objects.

Parameters:
model - the Model to be merged with this one
destroyArgumentModel - if the imported meta data should be used, (like in Modist), false if it should be destroyed and we create our own (like Obsolesence)
mdiToPlaceMergedItemUnder - The meta data itemk to merge the contents of the selcted model under. If specified as null the root will be assumed
Throws:
ModelException - if there is a problem merging the ExtendedBNs
InconsistentEvidenceException
uk.co.agena.minervaapps.basicminerva.linkgenerator.LinkModelException

compileAllExtendedBNs

public void compileAllExtendedBNs()
                           throws ExtendedBNException,
                                  InconsistentEvidenceException
Compiles all ExtendedBNs in the Model. If the ExtendedBNs are already compiled then they are all retracted back to their original state (in case any evidence existed in any of them).

Throws:
ExtendedBNException - if there is a problem during compilation or retraction
InconsistentEvidenceException

propagateAllExtendedBNs

public void propagateAllExtendedBNs(boolean fireUpExtendedNodeEvents)
                             throws ExtendedBNException
Propagates all ExtendedBNs in this Model's ExtendedBNList.

Throws:
ExtendedBNException - if there is a problem during propagation

reinitialiseAllExtendedBNs

public void reinitialiseAllExtendedBNs()
                                throws ExtendedBNException,
                                       InconsistentEvidenceException
Reinitialises all ExtendedBNs in this Model's ExtendedBNList.

Throws:
ExtendedBNException - if there is a problem during reinitialisation
InconsistentEvidenceException

applyScenario

public void applyScenario(Scenario scenario,
                          boolean propagate,
                          int exclusivity,
                          boolean useClosestMedianIfPossible)
                   throws ModelException
Applies the Scenario to all the relevant ExtendedBNs in this Model.

Parameters:
scenario - the Scenario to be applied
propagate - whether the underlying CoreBN should be propagated immediately
exclusivity - whether the evidence should be applied exclusively or not
useClosestMedianIfPossible - TODO
Throws:
ModelException - if there is a problem applying the Scenario

applyScenario

public void applyScenario(Scenario scenario,
                          boolean propagate,
                          int exclusivity,
                          java.util.List extendedBNs2applyOn,
                          boolean useClosestMedianIfPossible)
                   throws ModelException
Applies the Scenarios only to the ExtendedBNs contained in the supplied List.

Parameters:
scenario - the Scenario to apply
propagate - whether the underlying BN should be propagated immediately
exclusivity - whether the evidence should be applied exclusively or not
extendedBNs2applyOn - the ExtendedBNs to which the Scenario should be applied
useClosestMedianIfPossible - TODO
Throws:
ModelException - if there is a problem applying the Scenario

applyScenario

public void applyScenario(Scenario scenario,
                          boolean propagate,
                          int exclusivity,
                          java.util.List extendedBNs2applyOn,
                          boolean overrideCallSign,
                          java.lang.String[] overridingCallSigns,
                          boolean useClosestMedianIfPossible)
                   throws ModelException
Applies the Scenarios only to the ExtendedBNs contained in the supplied List using the supplied call sign information.

Parameters:
scenario - the Scenario to apply
propagate - whether the underlying BN should be propagated immediately
exclusivity - whether the evidence should be applied exclusively or not
extendedBNs2applyOn - the ExtendedBNs to which the Scenario should be applied
overrideCallSign - whether the call sign should be generated automatically from the Scenario id, or whether the overriding argument array should be used.
overridingCallSigns - an array of Strings containing call signs that can be used for overriding if required.
useClosestMedianIfPossible - TODO
Throws:
ModelException - if there is a problem applying the Scenario

applyScenario

public void applyScenario(Scenario scenario,
                          boolean propagate,
                          int exclusivity,
                          java.util.List extendedBNs2applyOn,
                          int incl_excl,
                          java.lang.String[] nodes2Incl_Excl,
                          boolean overrideCallSign,
                          java.lang.String[] overridingCallSigns,
                          boolean useClosestMedianIfPossible)
                   throws ModelException
Applies the Scenarios only to the ExtendedBNs contained in the supplied list using the supplied call sign information and information about which nodes to include and exclude.

Parameters:
scenario - the Scenario to apply
propagate - whether the underlying BN should be propagated immediately
exclusivity - whether the evidence should be applied exclusively or not
extendedBNs2applyOn - the ExtendedBNs to which the Scenario should be applied
incl_excl - value indicating if the array of Strings nodes2Incl_Excl should be used if 0, then it will not be used (APPLY_SCENARIO_NO_SPECIFICATION) if 1, then it will include nodes with those names (APPLY_SCENARIO_INCLUDE_NODES) if 2, then it will exclude nodes of those names (APPLY_SCENARIO_EXCLUDE_NODES)
nodes2Incl_Excl - the String of node names that should be included, excluded or ignored
overrideCallSign - whether the call sign should be generated automatically from the Scenario id, or whether the overriding argument array should be used.
overridingCallSigns - an array of Strings containing call signs that can be used for overriding if required.
useClosestMedianIfPossible - TODO
Throws:
ModelException - if there is a problem applying the Scenario

addExtendedBN

public int addExtendedBN(ExtendedBN ebn)
Adds the supplied ExtendedBN to the Model.

Parameters:
ebn - the ExtendedBN to add
Returns:
the id of the Extended BN added.

addExtendedBN

public ExtendedBN addExtendedBN(java.lang.String name,
                                java.lang.String description)
                         throws ExtendedBNException
Creates an empty BN with the supplied name and description and adds it to this model's list.

Parameters:
name - the name of the BN
description - the BN's description
Returns:
the newly created BN
Throws:
ExtendedBNException - if there is a problem creating the BN

addExtendedBN

public int addExtendedBN(ExtendedBN ebn,
                         boolean compiled)
                  throws ExtendedBNException,
                         InconsistentEvidenceException
Adds the supplied ExtendedBN to the Model's ExtendedBNList and compiles it (if required and if it is not already compiled).

Parameters:
ebn - the ExtendedBN to add
compiled - whether the ExtendedBN should be compiled
Returns:
the old id of the extendedbn added.
Throws:
ExtendedBNException - if there is a problem during compilation
InconsistentEvidenceException

addExtendedBN

public int addExtendedBN(ExtendedBN ebn,
                         boolean compiled,
                         boolean fireMergeModelEvent)
                  throws ExtendedBNException,
                         InconsistentEvidenceException
Adds the supplied ExtendedBN to the Model's ExtendedBNList and compiles it (if required and if if it is not already compiled).

Parameters:
ebn - the ExtendedBN to add
compiled - whether the ExtendedBN should be compiled
Returns:
the old id of the extendedbn added.
Throws:
ExtendedBNException - if there is a problem during compilation
InconsistentEvidenceException

addExtendedBNs

public int[] addExtendedBNs(java.util.List extendedBNs,
                            boolean compiled)
                     throws ExtendedBNException,
                            InconsistentEvidenceException
Adds the supplied List of ExtendedBNs to this Model's List of ExtendedBNs and compiles them (if required and if if they are not already compiled).

Parameters:
extendedBNs - the ExtendedBNs to add to this Model's List
compiled - whether the ExtendedBNs should be compiled or not
Returns:
int[] of the old Ids from the extendedBNs added.
Throws:
ExtendedBNException - if there is a problem during compilation
InconsistentEvidenceException

addExtendedBNs

public int[] addExtendedBNs(java.util.List extendedBNs,
                            boolean compiled,
                            boolean fireMergeModelEvent)
                     throws ExtendedBNException,
                            InconsistentEvidenceException
Adds the supplied List of ExtendedBNs to this Model's List of ExtendedBNs and compiles them (if required and if if they are not already compiled).

Parameters:
extendedBNs - the ExtendedBNs to add to this Model's List
compiled - whether the ExtendedBNs should be compiled or not
Returns:
int[] of the old Ids from the extendedBNs added.
Throws:
ExtendedBNException - if there is a problem during compilation
InconsistentEvidenceException

addQuestionnaire

public void addQuestionnaire(uk.co.agena.minerva.model.questionnaire.Questionnaire questionnaire)
Adds the supplied Questionnaire to the Model's QuestionnaireList.

Parameters:
questionnaire - the Questionnaire to be added

addQuestionnaire

public void addQuestionnaire(uk.co.agena.minerva.model.questionnaire.Questionnaire questionnaire,
                             boolean fireMergeModelEvent)
Adds the supplied Questionnaire to the Model's QuestionnaireList.

Parameters:
questionnaire - the Questionnaire to be added

addQuestionnaires

public void addQuestionnaires(java.util.List questionnaires)
Adds the supplied Questionnaires to the Model's QuestionnaireList.

Parameters:
questionnaires - the Questionnaires to be added

addQuestionnaires

public void addQuestionnaires(java.util.List questionnaires,
                              boolean fireMergeModelEvent)
Adds the supplied Questionnaires to the Model's QuestionnaireList.

Parameters:
questionnaires - the Questionnaires to be added

isPropagateUsingModelScenarios

public boolean isPropagateUsingModelScenarios()

setPropagateUsingModelScenarios

public void setPropagateUsingModelScenarios(boolean propagateUsingModelScenarios)

addMessagePassingLinks

public void addMessagePassingLinks(java.util.List newMessagePassingLinks,
                                   boolean fireMergeModelEvent)
Adds the supplied MessagePassingLinks objects to the Model's List.

Parameters:
newMessagePassingLinks - the new MessagePassingLinks objects to be added

addScenario

public Scenario addScenario(java.lang.String name)

addScenario

public void addScenario(Scenario scenario,
                        java.lang.Object ebnOrMDI)
Adds the supplied Scenario to the Model's ScenarioList.

Parameters:
scenario - the Scenario to be added

addScenario

public void addScenario(Scenario scenario,
                        boolean fireScenarioAddedEvent,
                        java.lang.Object ebnOrMDI)
Adds a scenario to the model

Parameters:
scenario -
fireMergeModelEvent -
ebnOrMDI -

addScenarios

public void addScenarios(java.util.List scenarios)
Adds the supplied Scenarios to the Model's ScenarioList.

Parameters:
scenarios - the Scenarios to be added

addScenarios

public void addScenarios(java.util.List scenarios,
                         boolean fireMergeModelEvent)

removeScenario

public void removeScenario(Scenario scenario)
                    throws ScenarioNotFoundException
Throws:
ScenarioNotFoundException

getMetaData

public uk.co.agena.minerva.model.metadata.MetaData getMetaData()

getFullyQualifiedPathForNode

public java.lang.String getFullyQualifiedPathForNode(ExtendedNode exNode)
Returns a string that contains the full path of the selected node: mdiPath.exbnName

Parameters:
exNode -
Returns:

setMetaData

public void setMetaData(uk.co.agena.minerva.model.metadata.MetaData metaData)

setUpMetaData

public void setUpMetaData(uk.co.agena.minerva.model.metadata.MetaData metaData,
                          java.util.List ids,
                          java.util.Map typesConnections)
                   throws ModelException
Throws:
ModelException

findIdentifiables

public java.util.List findIdentifiables(java.lang.String className,
                                        java.lang.String searchTerm)
Searches for all Identifiable objects of the supplied class using the supplied search term. If the search term is an ID, the object with that ID will be returned. If it is "*" then all objects of that class will be returned.

Parameters:
className -
searchTerm -
Returns:

getMarginalDataStore

public MarginalDataStore getMarginalDataStore()

setMarginalDataStore

public void setMarginalDataStore(MarginalDataStore marginalDataStore)

setExtendedBnList

public void setExtendedBnList(java.util.List extendedBns)
Sets the ExtendedBNs for this Model.

Parameters:
extendedBns - the ExtendedBNs used to initialise the Model's ExtendedBNList

setQuestionnaireList

public void setQuestionnaireList(java.util.List questionnaires)
Sets the Questionnaires for this Model.

Parameters:
questionnaires - the Questionnaires used to initialise the Model's QuestionnaireList

getMessageParseLinkWithID

public MessagePassingLinks getMessageParseLinkWithID(int id)
Returns the message parse link with the specified ID

Parameters:
id -
Returns:

getMessagePassingLinks

public java.util.List getMessagePassingLinks()
Return's this Model's List of MessagePassingLinks objects.

Returns:
this Model's List of MessagePassingLinks objects

getListOfOrderedMessagePassingLinksLists

public java.util.List getListOfOrderedMessagePassingLinksLists()
                                                        throws ModelException
Returns the MessagePassingLinks objects associated with this Model as a set of Lists, such that each List contains MessagePassingLinks objects that have the same priority level.

Returns:
a List of Lists of MessagePassingLinks objects
Throws:
ModelException

removeCrossMDIMessagePassingLinks

public void removeCrossMDIMessagePassingLinks()
                                       throws ExtendedBNNotFoundException
This method will remove all Message Passing links that exist between ExtendedBNs of 2 different Metadataitems. This is acheived by going through each MessagePassingLink in this model, getting the associated ExtendedBNs, if the ExtendedBNs belong to different MetaDataItems, then remove the messagepassing link. This is used in the Obsolescence and Availability link generator. Before fresh linking begins, this method should be called. We do this because when metadataitems are imported, there are usually message passing links between the extendedbns of it. But when the link generator is called, links are created between extendedbns from different metadataitems. At the point of regeneration, we need to make sure we don't remove messagepassing links from between extendedbns which belong to the same metadataitem.

Throws:
ExtendedBNNotFoundException

removeAllMessageParsesBetweenBNs

public void removeAllMessageParsesBetweenBNs(ExtendedBN source,
                                             ExtendedBN target)
This method removes all MessagePassingLinks objects that exist between the two specified ExtendedBNs.

Parameters:
source - the ExtendedBN that is the source of a given MessagePassingLinks object
target - the ExtendedBN that is the target of a given MessagePassingLinks object

removeAllMessagePassesForBN

public void removeAllMessagePassesForBN(int extendedBNId)
Given the ID of an ExtendedBN, this method will then remove all the MessagePassingLinks objects that are associated with it.

Parameters:
extendedBNId - the ID of the ExtendedBN for which all MessagePassingLinks objects will be removed

removeAllMessagePassLinks

public void removeAllMessagePassLinks()
Removes all message passing links


removeExtendedBNs

public void removeExtendedBNs(java.util.List extendedBNs,
                              boolean invokeDestroy)
                       throws ModelException
Removes a specified ExtendedBN from this Model. Internally all the associated Questionnaires, Scenarios and MessagePassingLinks are removed.

Parameters:
ebn - the ExtendedBN to be removed
invokeDestroy - flag determines whether the destroy method should be invoked on the exBN, this will sever all listener links the exBN has with other model objects
Throws:
ModelException - if the ExtendedBN (or any of its associated Questionnaires or Scenarios) cannot be found

deleteScenario

public void deleteScenario(Scenario scenario)
                    throws ModelException
Deletes the supplied Scenario from the model.

Parameters:
scenario - the Scenario to remove
Throws:
ModelException - if there is a problem with the deletion

deleteScenarios

public void deleteScenarios(java.util.List scenarios)
                     throws ModelException
Removes the Scenarios in the supplied list from the model.

Parameters:
scenario - the Scenarios to be removed.
Throws:
ModelException - if there is a problem with the deletion

deleteExtendedBN

public void deleteExtendedBN(ExtendedBN ebn)
                      throws ModelException
Deletes the supplied BN from the model.

Parameters:
ebn - the BN to remove
Throws:
ModelException - if there is a problem with the deletion

deleteExtendedBNs

public void deleteExtendedBNs(java.util.List ebns)
                       throws ModelException
Removes the BNs in the supplied list from the model.

Parameters:
ebns - the BNs to be removed.
Throws:
ModelException - if there is a problem with the deletion

removeExtendedBNs

public void removeExtendedBNs(ExtendedBN exBN,
                              boolean invokeDestroy)
                       throws ModelException
Convinence method for the remove extended BNs, takes a single BN, calls the list based remove extended Bns

Parameters:
extendedBNs -
invokeDestroy -
Throws:
ModelException

removeQuestionnaire

public void removeQuestionnaire(uk.co.agena.minerva.model.questionnaire.Questionnaire q)
                         throws ModelException
This method will remove the selected questionnaire from the model. It fires an event to say that the selected questionnaire has been removed

Parameters:
q -
Throws:
ModelException

getMessagePassingLinksForParent

public java.util.List getMessagePassingLinksForParent(int parentId)
Returns the MessagePassingLinks objects that have the ExtendedBN with the supplied ID as a parent.

Parameters:
parentId - the ID of the parent ExtendedBN
Returns:
a List of all MessagePassingLinks objects that have the ExtendedBN with the supplied ID as a parent or null if there are none

getMessagePassingLinksForChild

protected java.util.List getMessagePassingLinksForChild(int childId)
Returns the MessagePassingLinks objects that have the ExtendedBN with the supplied ID as a child.

Parameters:
childId - the ID of the parent ExtendedBN
Returns:
a List of all MessagePassingLinks objects that have the ExtendedBN with the supplied ID as a child or null if there are none

setMessagePassingLinks

public void setMessagePassingLinks(java.util.List messagePassingLinks)
Sets the MessagePassingLinks objects associated with this Model.

Parameters:
messagePassingLinks - the MessagePassingLinks objects associated with this Model

autoGenerateMessagePassingLinks

public void autoGenerateMessagePassingLinks(ExtendedBN rootBN,
                                            ExtendedBN targetBN)
                                     throws ModelException
Automatically generates MessagePassingLinks objects between the supplied ExtendedBNs depending on their input and output nodes. The link will only be auto-generated from the rootBN to the targetBN if, for all output nodes in the rootBN, there is an input node in the targetBN. Each combination of nodes has to have the same number of states; this is the only criterion that must be met.

If no MessagePassingLinks object can be configured then no link is generated. A ModelException is thrown if the links cannot be created and the user will then be responsible for defining the links manually.

Parameters:
rootBN - the ExtendedBN which sits at the root of the link
targetBN - the ExtendedBN which sits at the head of the link
Throws:
ModelException - if the links cannot be created; the user is then responsible for defining the links manually

getExtendedBNList

public ExtendedBNList getExtendedBNList()
Returns this Model's ExtendedBNList.

Returns:
this Model's ExtendedBNList

getQuestionnaireList

public uk.co.agena.minerva.model.questionnaire.QuestionnaireList getQuestionnaireList()
Returns this Model's QuestionnaireList.

Returns:
this Model's QuestionnaireList

getScenarioList

public ScenarioList getScenarioList()
Returns this Model's ScenarioList.

Returns:
this Model's ScenarioList

setScenarioList

public void setScenarioList(java.util.List scenarios)
Sets this Model's ScenarioList

Parameters:
scenarios - the new ScenarioList

resetAllScenarios

public void resetAllScenarios()
Removes all Observations from all Scenarios.


autoLinkBNOs

public void autoLinkBNOs()
                  throws ModelException
This method uses the generic link generator and the link generator property uk.co.agena.minervaapps.basicminerva.linkgenerator in the minerva.properties file to generate the message passing8 links on this model between the BNO's.

Throws:
ModelException

createMPLinksFromFile

public void createMPLinksFromFile(java.lang.String linkMappingfilename)
                           throws ModelException,
                                  MessagePassingLinkException
Message passing links are created using a configuration file. The config file will be a comma delimited file specifying the OutputBNName, outputNodeUniqueID, InputBNName, inputNodeUniqueID. Each line of the file represents a new MessagePassingLink All lines begining with the '#' charachter are ignored as they are comments. An example file is: # comments start with # # format for the lines are: # outputBN, output_node, inputBN, input_node model,Node_7,model,Node_107 model,Node_1,model,Node_101 model,Node_17,model,Node_117 model,Node_9, model,Node_109

Throws:
ModelException
MessagePassingLinkException
ExtendedBNNotFoundException

link

public void link(ExtendedNode source,
                 ExtendedNode target)
          throws MessagePassingLinkException
Links the two ExtendedNodes together, thereby linking the two containing ExtendedBNs.

Parameters:
source - the start of the link
target - the end of the link
Throws:
MessagePassingLinkException - if there is a problem linking the two nodes

addMessageParseLink

public void addMessageParseLink(ExtendedNode sourceNode,
                                ExtendedNode targetNode)
                         throws MessagePassingLinkException
This method will add the specified message parssing link to the model. If the message parsing link is invalid then it will not be added, and an Exception will be throws.

Parameters:
mpl -
Throws:
MessagePassingLinkException - If there was a problem creating the link. The exception message will explain the reason for the failure.

addMessageParseLink

public boolean addMessageParseLink(ExtendedNode sourceNode,
                                   ExtendedBN targetexBN)
This method will create a new message parse link from the specified source node, and the selected target BN a Clone of the source node will be created and added to the target BN in order to create the link.

Parameters:
sourceNode -
exBN -
Returns:

removeMessageParseLinks

public void removeMessageParseLinks(ExtendedNode sourceNode,
                                    ExtendedNode targetNode)
Removes all message parsing links between the specified nodes

Parameters:
sourceNode -
targetNode -

setupParameterPasses

public void setupParameterPasses(MessagePassingLinks mplinks,
                                 int noOfPassesAllowed,
                                 boolean forceSetNPT,
                                 boolean savePrior,
                                 boolean changeStatesOnInputNodeIfRequired)
                          throws ModelException
Connects the two supplied ExtendedBNs together so that information can be passed between them. The ExtendedBNs are connected by the supplied ExtendedNodes. If the user requires the original priors to be added to the saved priors for the listening node then the savePrior flag must be set as true.

Parameters:
mplinks - the MessagePassingLinks involved in the parameter passing
noOfPassesAllowed - how many times information should be passed in succession between the ExtendedBNs
forceSetNPT - whether the NPT for the receiving ExtendedNode should be reset with the new values (i.e. true) or if the information should be added as likelihood evidence (i.e. false)
savePrior - true if the original priors are to be added to the saved priors for the listening node, otherwise false
changeStatesOnInputNodeIfRequired - If this flag is true then input node should change its states to be the same as that of the output node it is recieving a message from. This should primarily done when dynamic discretisation is used. Should be false by default.
Throws:
ModelException - if there is a problem setting up parameter passing

setupRecursiveParameterPasses

public void setupRecursiveParameterPasses(MessagePassingLinks mplinks,
                                          int noOfPassesAllowed,
                                          boolean forceSetNPT,
                                          boolean savePrior,
                                          boolean changeStatesOnInputNodeIfRequired)
                                   throws ModelException
Same as setupParameterPasses but only for recursive links

Parameters:
mplinks -
noOfPassesAllowed -
forceSetNPT -
savePrior -
Throws:
ModelException

setupNonRecursiveParameterPasses

public void setupNonRecursiveParameterPasses(MessagePassingLinks mplinks,
                                             int noOfPassesAllowed,
                                             boolean forceSetNPT,
                                             boolean savePrior,
                                             boolean changeStatesOnInputNodeIfRequired)
                                      throws ModelException
Same as setupParameterPasses but only for non recursive links

Parameters:
mplinks -
noOfPassesAllowed -
forceSetNPT -
savePrior -
Throws:
ModelException

destroy

public void destroy()
Removes this Model as a listener from all Scenarios, Questionnaires and ExtendedBNs. This should be called when the Model is no longer used.


addModelListener

public void addModelListener(ModelListener ebnl)
Adds an object interested in ModelEvents to the List of ModelListeners (actually held by an internal ModelEventGenerator).

Parameters:
ebnl - the intereseted ModelListener

removeModelListener

public void removeModelListener(ModelListener ebnl)
Removes an object no longer interested in ModelEvents from the List of ModelListeners (actually held by an internal ModelEventGenerator).

Parameters:
ebnl - the ModelListener no longer interested

clearObservations

public void clearObservations(ExtendedBN ebn,
                              boolean onlyActiveScenarios)
Removes all the observations for a given ExtendedBN. If the onlyActiveScenarios flag is set then only Observations from Active/Reportable scenarios will be removed.

Parameters:
ebn - The ExtendedBN for which all related Observations will be removed
onlyActiveScenarios - If true only Observations from Active/Reportable Scenarios will be removed

clearAllObservations

public void clearAllObservations(ExtendedBN ebn)
Clears all the observations for a given ExtendedBN.

Parameters:
ebn - The ExtendedBN for which all related Observations will be removed

clearAllObservations

public void clearAllObservations()
Clears all observations in this model.


clearObservations

public void clearObservations(boolean onlyActiveScenarios)
Removes all the Observations for all the ExtendedBNs in this Model. If the onlyActiveScenarios flag is set then only Observations from Active/Reportable scenarios will be removed.

Parameters:
onlyActiveScenarios - If true only Observations from Active/Reportable Scenarios will be removed

observationsAdded

public void observationsAdded(ScenarioEvent se,
                              java.util.List obs,
                              boolean allowAutoPropagation)
Gets the Observations from the supplied ScenarioEvent and enters them into the relevant ExtendedBN. This method is called whenever a Scenario in the Model has changed.

Specified by:
observationsAdded in interface ScenarioListener
Parameters:
se - a ScenarioEvent encapsulating the change that has occurred
allowAutoPropagation - If this flag is set to false Auto Propagation will not occur even if Auto Propagation is ON.

scenarioAttributeChanged

public void scenarioAttributeChanged(ScenarioEvent se,
                                     int attribute)
Fired whenever an attribute of the scenario is modified

Specified by:
scenarioAttributeChanged in interface ScenarioListener
Parameters:
se -
attribute -

observationsRemoved

public void observationsRemoved(ScenarioEvent se,
                                java.util.List obs,
                                boolean autopropagate)
Gets the Observations from the supplied ScenarioEvent and removes them from the current relevant ExtendedBNs in the model. This method is called whenever the current Scenario has changed.

Specified by:
observationsRemoved in interface ScenarioListener
Parameters:
se - an event encapsulating the change that has occurred

extendedBNNameDescriptionChanged

public void extendedBNNameDescriptionChanged(ExtendedBNEvent ebne)
Tells all registered listeners that this Model has changed (in response to the name of one of its ExtendedBNs having changed).

Specified by:
extendedBNNameDescriptionChanged in interface ExtendedBNListener
Parameters:
ebne - the event encapsulating the change

extendedBNPropagated

public void extendedBNPropagated(ExtendedBNEvent ebne)
Not currently implemented.

Specified by:
extendedBNPropagated in interface ExtendedBNListener
Parameters:
ebne - the event encapsulating the change

extendedBNAllEvidenceRetracted

public void extendedBNAllEvidenceRetracted(ExtendedBNEvent ebne)
Not currently implemented.

Specified by:
extendedBNAllEvidenceRetracted in interface ExtendedBNListener
Parameters:
ebne - the event encapsulating the change

extendedNodeEventFired

public void extendedNodeEventFired(ExtendedBNEvent ebne,
                                   ExtendedNodeEvent ene,
                                   java.lang.String eventName)
Event received from the extended BN Invoked whenever the extended BN recieves a BN Node event, this event throws the event up to any listeners on the extended BN. As well as the node event it provides a string which is the name of the event that BN node fired.

Specified by:
extendedNodeEventFired in interface ExtendedBNListener
Parameters:
ebne - Tne Extended Bn that fired the event
ene - The extended Node that fired the event, caught by the BN
eventName - The name of the extendedBN node event.

extendedNodePasted

public void extendedNodePasted(ExtendedBNEvent ebne,
                               ExtendedBN sourceEXBN,
                               ExtendedNode sourceNode,
                               ExtendedNode exNode)
Extended Node pasted event, fired by the extended BN

Specified by:
extendedNodePasted in interface ExtendedBNListener
Parameters:
ebne -
exNode -
sourceNode - the node that was copied

extendedNodeAboutToBeCut

public void extendedNodeAboutToBeCut(ExtendedBNEvent ebne,
                                     ExtendedBN sourceEXBN,
                                     int targetEXNodeID,
                                     int sourceEXNodeID,
                                     java.lang.String nameCounter)
This event is fired when an ExtendedNode has been pasted to the destination ExtendedBN and is about to be cut from the specified source ExtendedBN. This is the last point at which the ExtendedNode (which has the sourceEXNodeID in the source and the targetEXNodeID in the destination) will exist on both the source and destination ExtendedBN's. Note: Although the ID's of the source and target ExtendedNode are different they are the same object.

Specified by:
extendedNodeAboutToBeCut in interface ExtendedBNListener
Parameters:
ebne - Holds the destination/target ExtendedBN.
sourceEXBN - The ExtendedBN the ExtendedNode is about to be cut from.
targetEXNodeID - The ID of the ExtendedNode which has been pasted to the ExtendedBN in the specified event.
sourceEXNodeID - The ID of the ExtendedNode which is about to be cut from the specified ExtendedBN.
nameCounter - The extra String that was added to the cut/pasted node to make it unique in the destination ExtendedBN.

copyQuestions

public void copyQuestions(java.util.List sourceQuestions,
                          java.util.List targetQuestions,
                          java.lang.String counter,
                          int targetBNID,
                          int targetNodeID)
Copy the properties of the source Questions to those of the target Questions. Matching them up appropiatly so Expression Variable Questions are matched and normal Questions are matched.

Parameters:
sourceQuestions - The list of Source Questions
targetQuestions - The list of Target Questions
counter - The counter String which should be added to each of the targetQuestion names to make them unique.
targetBNID - The ID of the ExtnededBN the target questions will be associated with.
targetNodeID - The ID of the ExtendedNode the target questions will be associated with.

extendedNodeRemoved

public void extendedNodeRemoved(ExtendedBNEvent ebne,
                                ExtendedNode exnode)
Extended Node removed event, fired by the extended BN

Specified by:
extendedNodeRemoved in interface ExtendedBNListener
Parameters:
ebne -

extendedNodeAdded

public void extendedNodeAdded(ExtendedBNEvent ebne,
                              ExtendedNode exNode)
This event is fired when ever a new node has been added to the extendedBN. The model currently create a new question for the new node and adds it to the first questionnaire which already contains questions for the specified extended BN

Specified by:
extendedNodeAdded in interface ExtendedBNListener
Parameters:
ebne - The extended BN from which the event was fired
exNode - The extended node which was added to the extended BN

extendedNodeReplaced

public void extendedNodeReplaced(ExtendedBNEvent ebne,
                                 ExtendedNode oldNode,
                                 ExtendedNode newNode,
                                 ExtendedBN ebn)
Description copied from interface: ExtendedBNListener
This event is fired whenever a node is replaced with another one.

Specified by:
extendedNodeReplaced in interface ExtendedBNListener
Parameters:
ebne - The extended BN from which the event was fired
oldNode - the old node
newNode - the new node
ebn - the BN containing both nodes

extendedBNIDChanged

public void extendedBNIDChanged(ExtendedBNEvent ebne)
Changes the connected IDs on Questions, Observations and MessagePassingLinks objects in response to the ID on an ExtendedBN changing.

Specified by:
extendedBNIDChanged in interface ExtendedBNListener
Parameters:
ebne - the event encapsulating the change

extendedBNAboutToBePropagated

public void extendedBNAboutToBePropagated(ExtendedBNEvent ebne)
Not currently implemented

Specified by:
extendedBNAboutToBePropagated in interface ExtendedBNListener
Parameters:
ebne - the event encapsulating the change

extendedBNInconsistentEvidencePropagated

public void extendedBNInconsistentEvidencePropagated(ExtendedBNEvent ebne)
Responds to inconsistent evidence being propagated on one of this Model's ExtendedBNs.

Specified by:
extendedBNInconsistentEvidencePropagated in interface ExtendedBNListener
Parameters:
ebne - the event encapsulating the change

extendedBNConnBNNotFound

public void extendedBNConnBNNotFound(ExtendedBNEvent ebne)
                              throws ExtendedBNException
Loads up the relevant CoreBN when it is required and when its ExtendedBN has informed listeners that it is not present.

Specified by:
extendedBNConnBNNotFound in interface ExtendedBNListener
Parameters:
ebne - the event encapsulating the change
Throws:
ExtendedBNException - if there is any problem in loading or compiling the underlying CoreBN

questionnaireIDChanged

public void questionnaireIDChanged(uk.co.agena.minerva.model.questionnaire.QuestionnaireEvent qe)
Informs all Observations within this Model when the ID for a connected Questionnaire changes.

Specified by:
questionnaireIDChanged in interface uk.co.agena.minerva.model.questionnaire.QuestionnaireListener
Parameters:
qe - the event encapsulating the change

questionnaireChanged

public void questionnaireChanged(uk.co.agena.minerva.model.questionnaire.QuestionnaireEvent ebne)
Event fired by questionnaires

Specified by:
questionnaireChanged in interface uk.co.agena.minerva.model.questionnaire.QuestionnaireListener
Parameters:
ebne - the event encapsulating the change

retractAllEvidence

public void retractAllEvidence()
                        throws ModelException,
                               InconsistentEvidenceException
Retracts evidence from all ExtendedBNs in this Model.

Throws:
ModelException - if there is a problem retracting evidence from any of the ExtendedBNs.
InconsistentEvidenceException

createModificationLogsInreleventBNs

public java.util.List createModificationLogsInreleventBNs(java.util.List effectedExBns,
                                                          ModelEvent me,
                                                          NameDescription nd)
Locates the extended Bns that require a modifcation log, and creates them. It returns a list of the exBns that have had a modification log added.

Returns:

removeModificationLogsFoeExBNs

public void removeModificationLogsFoeExBNs(java.util.List exBNs)
This method will remove the inconsitency logs for the specified BNs

Parameters:
exBNs -

fireModelChangedEvent

public void fireModelChangedEvent(Model model,
                                  int eventType,
                                  java.util.List eventAttributes)
Fires a model changed event with the specified parameters

Parameters:
model -
eventType -
eventAttributes -

shiftQuestionnaireInModelList

public void shiftQuestionnaireInModelList(uk.co.agena.minerva.model.questionnaire.Questionnaire q,
                                          uk.co.agena.minerva.model.questionnaire.Questionnaire relationQ,
                                          int moveDirection)
This method will reorder the specified questionnaire in the model list of questionnaires and reorder it in the connected meta data layer

Parameters:
q - The questionnaire that was moved
moveDirection - The direction of the movement.

isMetaDataUsed

public boolean isMetaDataUsed()

setMetaDataUsed

public void setMetaDataUsed(boolean b)

getUnmarkedMessagePassingExtendedBNs

public java.util.List getUnmarkedMessagePassingExtendedBNs()
Gets all the ExtendedBNs that are not flagged to have been visted by the MessagePassing algorithm.

Returns:

isAllParentExtendedBNsMarkedForMessagePassing

public boolean isAllParentExtendedBNsMarkedForMessagePassing(ExtendedBN extendedBN)
                                                      throws ExtendedBNNotFoundException
Throws:
ExtendedBNNotFoundException

LocateModelObjectsNoConnectedToMetaDataItems

public java.util.List LocateModelObjectsNoConnectedToMetaDataItems(boolean removeUnConnectedScenarios,
                                                                   boolean removeUnConnectedQuestionnaires,
                                                                   boolean removeUnconnectedExtendedBNs)
This method will itterate over the model items (Extended BNs, scenarios and questionnaires), and add to a return list all those that are not connected to any of the meta data objects connected to the model. If the arguement flag is raised then it will delete any unconnected items from the model

Parameters:
removeUnConnectedScenarios - determines whether unconnected scenarios should be deleted from the model
removeUnConnectedQuestionnaires - determines whether unconnected questionnaires should be deleted from the model
removeUnconnectedExtendedBNs - determines whether unconnected extended BNs should be deleted from the model
Returns:
a list of the items that are unconnected

synchroniseQuestionAnswersToNodeStates

public void synchroniseQuestionAnswersToNodeStates(ExtendedBN exBN,
                                                   ExtendedNode exNode)
This method will locate all questions connected to the specified node, and ensure that if the question is configured to auto synchronise the answers to the states in the connected node then it there is indeed a 1-1 mapping

Parameters:
exNode -

questionAdded

public void questionAdded(uk.co.agena.minerva.model.questionnaire.QuestionnaireEvent qe,
                          uk.co.agena.minerva.model.questionnaire.Question q)
This event is fired whenever a new question is added to the questionnaire

Specified by:
questionAdded in interface uk.co.agena.minerva.model.questionnaire.QuestionnaireListener
Parameters:
qe - The questionnaire event itself
q - the question that has been added

questionEventFired

public void questionEventFired(uk.co.agena.minerva.model.questionnaire.QuestionnaireEvent qte,
                               uk.co.agena.minerva.model.questionnaire.QuestionEvent qe,
                               int eventType)
This event is fired up to the questionnaire listeners when the questionnaire receives an event from one of its questions. The final arguement specifies the type of the question event caught. The constants are available on this class

Specified by:
questionEventFired in interface uk.co.agena.minerva.model.questionnaire.QuestionnaireListener
Parameters:
qe -
qe -

questionsRemoved

public void questionsRemoved(uk.co.agena.minerva.model.questionnaire.QuestionnaireEvent qe,
                             java.util.List questions)
Description copied from interface: uk.co.agena.minerva.model.questionnaire.QuestionnaireListener
Fired whenever one or more questions are removed from a questionnaire.

Specified by:
questionsRemoved in interface uk.co.agena.minerva.model.questionnaire.QuestionnaireListener
Parameters:
qe - the event itself
questions - the questions that have been removed

simulationFinished

public void simulationFinished(PropagationEvent ebne,
                               boolean completedSuccessfully,
                               java.util.List propagatedExtendedBNs)
Description copied from interface: PropagationListener
Fired whenever an execution of a Propagation has finished.

Specified by:
simulationFinished in interface PropagationListener
Parameters:
ebne - an event encapsulating the completion of the Propagation execution
propagatedExtendedBNs - TODO

propagationIncremented

public void propagationIncremented(PropagationEvent ebne,
                                   int timePeriodPropagated)
Description copied from interface: PropagationListener
Fired whenever a cycle of a Propagation has finished.

Specified by:
propagationIncremented in interface PropagationListener
Parameters:
ebne - an event encapsulating the completion of the Propagation cycle

simulationStarted

public void simulationStarted(PropagationEvent msmpe)
Description copied from interface: PropagationListener
Fired whenever an execution of a Propagation is about to be Started.

Specified by:
simulationStarted in interface PropagationListener

removeAllTracesOfExtendedNode

public void removeAllTracesOfExtendedNode(ExtendedBN ebn,
                                          ExtendedNode enode)
                                   throws ExtendedBNException
Removes the supplied ExtendedNode from its ExtendedBN. It also removes all related MessagePassingLinks, Questions and Observations.

Parameters:
ebn - the ExtendedBN containing the ExtendedNode
enode - the ExtendedNode to remove
Throws:
ExtendedBNException

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

isFireUpExtendedNodeEvent

public boolean isFireUpExtendedNodeEvent()
Returns:
Returns the fireUpExtendedNodeEvent.

setFireUpExtendedNodeEvent

public void setFireUpExtendedNodeEvent(boolean fireUpExtendedNodeEvent)
Parameters:
fireUpExtendedNodeEvent - The fireUpExtendedNodeEvent to set.

getExtendedBNs

public java.util.List getExtendedBNs(int[] ebnIds)
                              throws ExtendedBNNotFoundException
Returns all ExtendedBNs corresponding to the supplied IDs.

Parameters:
ebnIds -
Returns:
Throws:
ExtendedBNNotFoundException

getQuestionnaires

public java.util.List getQuestionnaires(int[] qIds)
                                 throws uk.co.agena.minerva.model.questionnaire.QuestionnaireNotFoundException
Returns all Questionnaires corresponding to the supplied IDs.

Parameters:
qIds -
Returns:
Throws:
uk.co.agena.minerva.model.questionnaire.QuestionnaireNotFoundException

getScenarios

public java.util.List getScenarios(int[] sIds)
                            throws ScenarioNotFoundException
Returns all Scenarios corresponding to the supplied IDs.

Parameters:
sIds -
Returns:
Throws:
ScenarioNotFoundException

setUpScenarios

public void setUpScenarios()
Ensures that Scenarios are set up correctly once a Model has been loaded in.


regenerateProblemNPTs

public void regenerateProblemNPTs()
                           throws InconsistentEvidenceException,
                                  ExtendedBNException,
                                  NPTGeneratorException,
                                  PropagationException
Checks the list of problem nodes and, if there are any, regenerates their NPTs.

Throws:
PropagationException
NPTGeneratorException
ExtendedBNException
InconsistentEvidenceException

clearProblemNodes

public void clearProblemNodes()
Empties out the list of problem nodes.


getExtendedBNForNode

public ExtendedBN getExtendedBNForNode(ExtendedNode node)
Parameters:
node -
Returns:

getExtendedNodeWithName

public ExtendedNode getExtendedNodeWithName(java.lang.String name)
Parameters:
node -
Returns:

getExtendedBNAtIndex

public ExtendedBN getExtendedBNAtIndex(int index)
Returns the BN at the supplied index in the model's list of BNs. If the list is empty, null will be returned.

Parameters:
index - the index of the BN to be returned
Returns:

getExtendedBNWithName

public ExtendedBN getExtendedBNWithName(java.lang.String name)
Returns the BN with the supplied name. If the list is empty, null will be returned.

Parameters:
index - the name of the BN to be returned
Returns:

getScenarioAtIndex

public Scenario getScenarioAtIndex(int index)
Returns the Scenario at the supplied index in the model's list of Scenarios. If the list is empty, null will be returned.

Parameters:
index - the index of the Scenario to be returned
Returns:

getScenarioWithName

public Scenario getScenarioWithName(java.lang.String name)
Returns the Scenario with the supplied name in the list of the model's Scenarios. If the list is empty, null will be returned.

Parameters:
index - the name of the Scenario to be returned
Returns:

importScenarios

public void importScenarios(ScenarioList sl)
Takes the supplied list of Scenarios and adds them to the Model. In the process, a data structure is built up that contains the status of each Observation. This data structure is sent out in a ModelEvent that is fired at the end of the process.

The data structure sent out is a Map. In this Map, the key is a Scenario and the value is another Map. In this second Map, the key is an Observation and the value is a List of Integers. If this List is empty, it means that the Observation has been imported OK. If this List is not empty, there have been one or more problems. The Integers in the List detail the problems: SCENARIO_IMPORT_WRONG_NODE_ID = the matching node has been found based on the ID, but the unique ID in the Observation is wrong SCENARIO_IMPORT_WRONG_STATES_WORKABLE = the number of states is different, but the Observation is for a state index that still exists SCENARIO_IMPORT_WRONG_STATES_UNWORKABLE = the number of states is different, but the Observation is for a state index that no longer exists SCENARIO_IMPORT_NODE_NOT_FOUND = a node with the matching ID is not found

Parameters:
sl - The List of Scenarios that is being imported

saveCreationTimestamp

public void saveCreationTimestamp(java.lang.String licenceType)
Stores a time stamp in the each of the CoreBN's associated with this model. This time stamp indicates the date/time the file was first saved if under an evaluation licence or the date/time the file was last saved in under a professional licence.

Parameters:
licenceType - The type of licence the tool is currently running under will be either 'Evaluation' or 'Professional'

checkCreationTimestamps

public void checkCreationTimestamps(java.lang.String licenceType)
                             throws uk.co.agena.minerva.util.helpers.ProbabilityCalculatorException
Check the difference between the creation timestamp, stored in the CoreBN's associated with this model, and the current time does not exceed a certain limit. This check is only made if the tool is being run under an evaluation version licence.

Parameters:
licenceType - The type of licence the tool is currently running under will be either 'Evaluation' or 'Professional'
Throws:
uk.co.agena.minerva.util.helpers.ProbabilityCalculatorException - When difference between the creation timestamp and the current date/time exceeds the set limit. This will only occur when under an evaluation version licence.

updateNewAndImportedBNsTimestamps

public void updateNewAndImportedBNsTimestamps(java.util.List bns)
The CoreBN's being added/imported into this model need to have the creation timestamps set to be identical to those CoreBN's currently in the Model.

Parameters:
bns - The BN's being added/imported.

getPropagationAlgorithm

public Propagation getPropagationAlgorithm()
This is the propagation algorithm that will be used for this model.


setPropagationAlgorithm

public void setPropagationAlgorithm(Propagation p)
This is the propagation algorithm that will be used for this model.


getChildrenExtendedBNs

public java.util.List getChildrenExtendedBNs(ExtendedBN ebn)
                                      throws ExtendedBNNotFoundException
This method uses the message passing links to return a list of the children ExtendedBNs of the argument BN.

Parameters:
ebn -
Returns:
Throws:
ExtendedBNNotFoundException

getDecendentExtendedBNs

public java.util.Set getDecendentExtendedBNs(ExtendedBN ebn)
                                      throws ExtendedBNNotFoundException
This method will use the MessagePassingLinks to get all the decendents of the argument ExtendedBN This is done recursively using the getChildrenExtendedBNs method.

Parameters:
ebn -
Returns:
Throws:
ExtendedBNNotFoundException

getParentExtendedBNs

public java.util.List getParentExtendedBNs(ExtendedBN ebn)
                                    throws ExtendedBNNotFoundException
This method uses the message passing links to return a list of the parent ExtendedBNs of the argument BN.

Parameters:
ebn -
Returns:
Throws:
ExtendedBNNotFoundException

getAncestorExtendedBNs

public java.util.Set getAncestorExtendedBNs(ExtendedBN ebn)
                                     throws ExtendedBNNotFoundException
This method will use the MessagePassingLinks to get all the Ancestors of the argument ExtendedBN This is done recursively using the getParentExtendedBNs method.

Parameters:
ebn -
Returns:
Throws:
ExtendedBNNotFoundException

save

public void save(java.lang.String filename)
          throws uk.co.agena.minerva.util.io.FileHandlingException
Saves the model to the specified file

Parameters:
filename - the file to save the model to
Throws:
uk.co.agena.minerva.util.io.FileHandlingException - if there is a problem during the save

load

public static Model load(java.lang.String filename)
                  throws uk.co.agena.minerva.util.io.FileHandlingException
Loads the model from the supplied file.

Parameters:
filename - the name of the file containing the model
Returns:
the loaded model
Throws:
uk.co.agena.minerva.util.io.FileHandlingException - if there is a problem loading the model

writeMarginalsToCSV

public java.util.List writeMarginalsToCSV()
Writes the marginals in the model to a List of CSV strings that can be saved to a file. It only handles the first BN and the first Scenario at the moment.

Returns:
a List of CSV strings representing the scenarios; this will be empty if there are no scenarios

loadScenariosFromCSV

public void loadScenariosFromCSV(java.util.List csvStrings)
                          throws ScenarioException
Takes the supplied set of CSV strings, creates scenarios from it and loads them into the Model (replacing any existing scenarios). Note: this does not currently handle the situation where there is more than one node with the same name i.e. across multiple BNOs.

Parameters:
csvStrings - the strings containing the scenarios
Throws:
ScenarioNotFoundException
ScenarioException

getUnmatchedNodeNames

public java.util.List getUnmatchedNodeNames()

setUnmatchedNodeNames

public void setUnmatchedNodeNames(java.util.List unmatchedNodeNames)


Copyright © 2006 Agena Ltd. All Rights Reserved.