uk.co.agena.minerva.model
Class MessagePassingLinks

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

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

This class should be used to setup a link between ExtendedNodes of possibly different ExtendedBNs so that message-passing can occur between them. A single MessagePassingLinks object contains multiple links of this kind.


Field Summary
static java.lang.String MESSAGE_LINK_NAME
          Constant used when storing MessagePassingLinks to file.
static int PRIORITY_HIGH
          Constant used to indicate high priority.
static int PRIORITY_LOW
          Constant used to indicate low priority.
static int PRIORITY_MEDIUM
          Constant used to indicate medium priority.
static int PRIORITY_VERY_HIGH
          Constant used to indicate very high priority.
static int PRIORITY_VERY_LOW
          Constant used to indicate very low priority.
static double version
           
 
Fields inherited from interface uk.co.agena.minerva.util.model.Writable
FIELD_SEPARATOR
 
Constructor Summary
MessagePassingLinks()
          Default constructor.
MessagePassingLinks(int childExtBNID, int childExtNodeID, int parentExtBNID, int parentExtNodeID)
          Creates a MessagePassingLinks object with one initial link.
 
Method Summary
 void add(int parentExtBNID, int childExtBNID, int parentExtNodeID, int childExtNodeID)
          Adds a new link with the specified child/parent ExtendedBN/ExtendedNode IDs to this MessagePassingLinks object.
 void changeExtendedBNId(int oldExtendedBNId, int newExtendedBNId)
          Changes all occurences of the specified old ExtendedBN ID to the specified new ExtendedBN ID, wherever it occurs in any of the links.
 java.lang.Object clone()
           
 void decreasePriorityLevel()
          Decrements the current priority level by one (unless the priority level is already PRIORITY_VERY_LOW i.e.
 int[] getChildrenExtendedBNIds(int parentExtendedBNID)
          Returns all child ExtendedBN IDs that are connected to the supplied parent ExtendedBN ID in the links contained in this MessagePassingLinks object.
 int getId()
          Returns the unique integer ID of the object.
 int getIterationChildExtendedBNId()
          Gets the child ExtendedBN ID at the index specified by the current value of the iterator counter.
 int getIterationChildExtendedNodeId()
          Gets the child ExtendedNode ID at the index specified by the current value of the iterator counter.
 int getIterationParentExtendedBNId()
          Gets the parent ExtendedBN ID at the index specified by the current value of the iterator counter.
 int getIterationParentExtendedNodeId()
          Gets the parent ExtendedNode ID at the index specified by the current value of the iterator counter.
 int[] getParentExtendedBNIds(int childExtendedBNID)
          Returns all parent ExtendedBN IDs that are connected to the supplied child ExtendedBN ID in the links contained in this MessagePassingLinks object.
 int getPriorityLevel()
          Returns the current priority level of this MessagePassingLinks object with respect to any other MessagePassingLinks objects that are being navigated.
 double getVersion()
          Returns the version of the class.
 void increasePriority()
          Increments the current priority level by one (unless the priority level is already PRIORITY_VERY_HIGH i.e.
 int isAllParentsSame()
          Goes through and checks whether all the IDs for the parent ExtendedBNs in this MessagePassingLinks object are the same.
 boolean isChildExtendedBN(int childExtendedBNID)
          Checks whether there are any links in this MessagePassingLinks object whose children have the supplied ExtendedBN ID.
 boolean isParentExtendedBN(int parentExtendedBNID)
          Checks whether there are any links in this MessagePassingLinks object whose parents have the supplied ExtendedBN ID.
 boolean isRecursive()
          Checks if this link is recursive
 boolean isValidForModel(Model m)
          This method will itterate over the message pass links in the message pass link object, and remove those that are connected to exBNs and exNodes that are in the connected model.
static boolean isValidLink(ExtendedNode sourceNode, ExtendedBN targetBN, ExtendedNode targetNode)
          This method takes two nodes, and informs the user whether they are a valid source and target for a message parse link.
static MessagePassingLinks joinLinks(java.util.List mpLinksList)
          Joins the Links in the List of MessagePassingLinks.
 boolean messageParseExistsFor(int childExtBNID, int childExtNodeID, int parentExtBNID, int parentExtNodeID)
          Indicates whether a message-passing link exists between the two specified ExtendedNodes (that reside in the two specified ExtendedBNs).
 boolean next()
          Increments the iterator counter.
 int read(java.util.List strings, int currentLineNumber)
           
 boolean removeAllRelatedMessagePassLinks(int extBNID, int extNodeID)
          Removes all message passing links where the supplied BN/Node ID combination features as child or parent.
 boolean removeMessagePassingLinkByIndex(int indexToRemove)
          This will remove the message passing links that are located in the argument index.
 boolean removeMessagePassLink(int extBNID)
          Removes all links involving the specified Extended BN.
 boolean removeMessagePassLink(int childExtBNID, int parentExtBNID)
          Removes all links between the specified ExtendedBNs.
 boolean removeMessagePassLink(int childExtBNID, int childExtNodeID, int parentExtBNID, int parentExtNodeID)
          Removes the first link in this MessagePassingLinks object that has the specified child/parent ExtendedBN/ExtendedNode IDs.
static java.util.List reorderByPriority(java.util.List messagePassingLinksList)
          Takes the supplied list of MessagePassingLinks objects, orders them by priority level and then returns them.
 void setId(int id)
           
 void setIterationChildExtendedBNId(int newChildExtendedBNId)
          Sets the child ExtendedBN ID at the index specified by the current value of the iterator counter.
 void setIterationChildExtendedNodeId(int newChildExtendedNodeId)
          Sets the child ExtendedNode ID at the index specified by the current value of the iterator counter.
 void setIterationParentExtendedBNId(int newParentExtendedBNId)
          Sets the parent ExtendedBN ID at the index specified by the current value of the iterator counter.
 void setIterationParentExtendedNodeId(int newParentExtendedNodeId)
          Sets the parent ExtendedNode ID at the index specified by the current value of the iterator counter.
 void setPriorityLevel(int priorityLevel)
          Sets the current priority level of this MessagePassingLinks object with respect to any other MessagePassingLinks objects that are being navigated.
 void setVersion(double version)
          Sets the version number of the class.
 int size()
          Returns the number of links stored in this MessagePassingLinks object.
 void startIterator()
          Starts an iterator for the links in this MessagePassingLinks object.
 java.util.List write()
          Writes the object in question to a List of Strings.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static double version

MESSAGE_LINK_NAME

public static final java.lang.String MESSAGE_LINK_NAME
Constant used when storing MessagePassingLinks to file.

See Also:
Constant Field Values

PRIORITY_VERY_LOW

public static final int PRIORITY_VERY_LOW
Constant used to indicate very low priority.

See Also:
Constant Field Values

PRIORITY_LOW

public static final int PRIORITY_LOW
Constant used to indicate low priority.

See Also:
Constant Field Values

PRIORITY_MEDIUM

public static final int PRIORITY_MEDIUM
Constant used to indicate medium priority.

See Also:
Constant Field Values

PRIORITY_HIGH

public static final int PRIORITY_HIGH
Constant used to indicate high priority.

See Also:
Constant Field Values

PRIORITY_VERY_HIGH

public static final int PRIORITY_VERY_HIGH
Constant used to indicate very high priority.

See Also:
Constant Field Values
Constructor Detail

MessagePassingLinks

public MessagePassingLinks()
Default constructor.


MessagePassingLinks

public MessagePassingLinks(int childExtBNID,
                           int childExtNodeID,
                           int parentExtBNID,
                           int parentExtNodeID)
Creates a MessagePassingLinks object with one initial link. This link is specified by the supplied child and parent ExtendedBN and ExtendedNode IDs.

Parameters:
childExtBNID - the ExtendedBN ID of the child end of the link
childExtNodeID - the ExtendedNode ID of the child end of the link
parentExtBNID - the ExtendedBN ID of the parent end of the link
parentExtNodeID - the ExtendedNode ID of the parent end of the link
Method Detail

changeExtendedBNId

public void changeExtendedBNId(int oldExtendedBNId,
                               int newExtendedBNId)
Changes all occurences of the specified old ExtendedBN ID to the specified new ExtendedBN ID, wherever it occurs in any of the links.

Parameters:
oldExtendedBNId - the ID to be changed
newExtendedBNId - the new value of the ID

isValidLink

public static boolean isValidLink(ExtendedNode sourceNode,
                                  ExtendedBN targetBN,
                                  ExtendedNode targetNode)
                           throws MessagePassingLinkException
This method takes two nodes, and informs the user whether they are a valid source and target for a message parse link.

Parameters:
sourceNode -
targetNode -
Returns:
Throws:
MessagePassingLinkException

isValidForModel

public boolean isValidForModel(Model m)
This method will itterate over the message pass links in the message pass link object, and remove those that are connected to exBNs and exNodes that are in the connected model. It will return true if there are relevent links remaining

Parameters:
m -
Returns:

removeAllRelatedMessagePassLinks

public boolean removeAllRelatedMessagePassLinks(int extBNID,
                                                int extNodeID)
Removes all message passing links where the supplied BN/Node ID combination features as child or parent.

Parameters:
extBNID - the BN under consideration
extNodeID - the node under consideration
Returns:
true if there are message passing links left; false otherwise.

removeMessagePassLink

public boolean removeMessagePassLink(int childExtBNID,
                                     int childExtNodeID,
                                     int parentExtBNID,
                                     int parentExtNodeID)
Removes the first link in this MessagePassingLinks object that has the specified child/parent ExtendedBN/ExtendedNode IDs.

Parameters:
childExtBNID - the ExtendedBN ID of the child end of the link
childExtNodeID - the ExtendedNode ID of the child end of the link
parentExtBNID - the ExtendedBN ID of the parent end of the link
parentExtNodeID - the ExtendedNode ID of the parent end of the link
Returns:
true if there are still any links left, false otherwise

removeMessagePassingLinkByIndex

public boolean removeMessagePassingLinkByIndex(int indexToRemove)
This will remove the message passing links that are located in the argument index.

Parameters:
indexToRemove -
Returns:

removeMessagePassLink

public boolean removeMessagePassLink(int childExtBNID,
                                     int parentExtBNID)
Removes all links between the specified ExtendedBNs.

Parameters:
childExtBNID - the ExtendedBN ID of the child end of the link
parentExtBNID - the ExtendedBN ID of the parent end of the link
Returns:
true if there are still any links left, false otherwise

removeMessagePassLink

public boolean removeMessagePassLink(int extBNID)
Removes all links involving the specified Extended BN.

Parameters:
extBNID - the ExtendedBN for which to remove all links
Returns:
true if there are still any links left, false otherwise

messageParseExistsFor

public boolean messageParseExistsFor(int childExtBNID,
                                     int childExtNodeID,
                                     int parentExtBNID,
                                     int parentExtNodeID)
Indicates whether a message-passing link exists between the two specified ExtendedNodes (that reside in the two specified ExtendedBNs).

Parameters:
childExtBNID - the target child ExtendedBN ID
childExtNodeID - the target child ExtendedNode ID
parentExtBNID - the target parent ExtendedBN ID
parentExtNodeID - the target child ExtendedNode ID
Returns:
true if a link exists, false otherwise

getPriorityLevel

public int getPriorityLevel()
Returns the current priority level of this MessagePassingLinks object with respect to any other MessagePassingLinks objects that are being navigated.

Returns:
the current priority level of this MessagePassingLinks object

setPriorityLevel

public void setPriorityLevel(int priorityLevel)
Sets the current priority level of this MessagePassingLinks object with respect to any other MessagePassingLinks objects that are being navigated. If the priority level specified falls outside the range PRIORITY_VERY_LOW - PRIORITY_VERY_HIGH (i.e. 1 - 5), then it is set to the lower or upper bound as appropriate.

Parameters:
priorityLevel - the new priority level

increasePriority

public void increasePriority()
Increments the current priority level by one (unless the priority level is already PRIORITY_VERY_HIGH i.e. 5 in which case it is not incremented).


decreasePriorityLevel

public void decreasePriorityLevel()
Decrements the current priority level by one (unless the priority level is already PRIORITY_VERY_LOW i.e. 1 in which case it is not decremented).


size

public int size()
Returns the number of links stored in this MessagePassingLinks object.

Returns:
the number of links stored in this MessagePassingLinks object

add

public void add(int parentExtBNID,
                int childExtBNID,
                int parentExtNodeID,
                int childExtNodeID)
Adds a new link with the specified child/parent ExtendedBN/ExtendedNode IDs to this MessagePassingLinks object.

Parameters:
parentExtBNID - the ExtendedBN ID of the parent end of the link
childExtBNID - the ExtendedBN ID of the child end of the link
parentExtNodeID - the ExtendedNode ID of the parent end of the link
childExtNodeID - the ExtendedNode ID of the child end of the link

isParentExtendedBN

public boolean isParentExtendedBN(int parentExtendedBNID)
Checks whether there are any links in this MessagePassingLinks object whose parents have the supplied ExtendedBN ID.

Parameters:
parentExtendedBNID - the parent ExtendedBN ID of the link being sought
Returns:
true if such a link exists, false otherwise

isChildExtendedBN

public boolean isChildExtendedBN(int childExtendedBNID)
Checks whether there are any links in this MessagePassingLinks object whose children have the supplied ExtendedBN ID.

Parameters:
childExtendedBNID - the child ExtendedBN ID of the link being sought
Returns:
true if such a link exists, false otherwise

getChildrenExtendedBNIds

public int[] getChildrenExtendedBNIds(int parentExtendedBNID)
Returns all child ExtendedBN IDs that are connected to the supplied parent ExtendedBN ID in the links contained in this MessagePassingLinks object.

Parameters:
parentExtendedBNID - the parent ExtendedBN ID being sought
Returns:
an array of child ExtendedBN IDs

getParentExtendedBNIds

public int[] getParentExtendedBNIds(int childExtendedBNID)
Returns all parent ExtendedBN IDs that are connected to the supplied child ExtendedBN ID in the links contained in this MessagePassingLinks object.

Parameters:
childExtendedBNID - the child ExtendedBN ID being sought
Returns:
an array of parent ExtendedBN IDs

reorderByPriority

public static java.util.List reorderByPriority(java.util.List messagePassingLinksList)
Takes the supplied list of MessagePassingLinks objects, orders them by priority level and then returns them.

Parameters:
messagePassingLinksList - the unordered List of MessagePassingLinks objects
Returns:
the ordered List of MessagePassingLinks objects

startIterator

public void startIterator()
Starts an iterator for the links in this MessagePassingLinks object.


next

public boolean next()
Increments the iterator counter.

Returns:
true if the iterator counter has reached the number of links

getIterationParentExtendedBNId

public int getIterationParentExtendedBNId()
Gets the parent ExtendedBN ID at the index specified by the current value of the iterator counter.

Returns:
the parent ExtendedBN ID at the index specified by the current value of the iterator counter

getIterationChildExtendedBNId

public int getIterationChildExtendedBNId()
Gets the child ExtendedBN ID at the index specified by the current value of the iterator counter.

Returns:
the child ExtendedBN ID at the index specified by the current value of the iterator counter

getIterationParentExtendedNodeId

public int getIterationParentExtendedNodeId()
Gets the parent ExtendedNode ID at the index specified by the current value of the iterator counter.

Returns:
the parent ExtendedNode ID at the index specified by the current value of the iterator counter

getIterationChildExtendedNodeId

public int getIterationChildExtendedNodeId()
Gets the child ExtendedNode ID at the index specified by the current value of the iterator counter.

Returns:
the child ExtendedNode ID at the index specified by the current value of the iterator counter

setIterationParentExtendedBNId

public void setIterationParentExtendedBNId(int newParentExtendedBNId)
Sets the parent ExtendedBN ID at the index specified by the current value of the iterator counter.

Parameters:
newParentExtendedBNId - the new parent ExtendedBN ID at the index specified by the current value of the iterator counter

setIterationChildExtendedBNId

public void setIterationChildExtendedBNId(int newChildExtendedBNId)
Sets the child ExtendedBN ID at the index specified by the current value of the iterator counter.

Parameters:
newChildExtendedBNId - the new child ExtendedBN ID at the index specified by the current value of the iterator counter

setIterationParentExtendedNodeId

public void setIterationParentExtendedNodeId(int newParentExtendedNodeId)
Sets the parent ExtendedNode ID at the index specified by the current value of the iterator counter.

Parameters:
newParentExtendedNodeId - the new parent ExtendedNode ID at the index specified by the current value of the iterator counter

setIterationChildExtendedNodeId

public void setIterationChildExtendedNodeId(int newChildExtendedNodeId)
Sets the child ExtendedNode ID at the index specified by the current value of the iterator counter.

Parameters:
newChildExtendedNodeId - the new child ExtendedNode ID at the index specified by the current value of the iterator counter

isAllParentsSame

public int isAllParentsSame()
Goes through and checks whether all the IDs for the parent ExtendedBNs in this MessagePassingLinks object are the same.

Returns:
the ID if all parent ExtendedBN IDs are the same, otherwise Integer.MIN_VALUE

isRecursive

public boolean isRecursive()
Checks if this link is recursive

Returns:

joinLinks

public static MessagePassingLinks joinLinks(java.util.List mpLinksList)
Joins the Links in the List of MessagePassingLinks.

Parameters:
mpLinksList -
Returns:

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

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

getId

public int getId()
Description copied from interface: Identifiable
Returns the unique integer ID of the object.

Specified by:
getId in interface Identifiable
Returns:
Returns the id.

setId

public void setId(int id)
Parameters:
id - The id to set.

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


Copyright © 2006 Agena Ltd. All Rights Reserved.