COM.hugin.HAPI
Class NetworkModel

java.lang.Object
  extended byCOM.hugin.HAPI.NetworkModel
Direct Known Subclasses:
Class, Domain

public abstract class NetworkModel
extends java.lang.Object

The NetworkModel class is an abstract class with two subclasses: Domain.java and Class.java.


Nested Class Summary
static class NetworkModel.Category
          The Category class is used to attach a category tag to the Nodes of Classes and Domains.
static class NetworkModel.Constraint
          The Constraint class is used to represent possible domain knowledge about a particular edge between a pair of variables.
static class NetworkModel.Endian
          The Endian class is used to represent the byte-order used when saving a Hugin Knowledge Base (HKB) file.
static class NetworkModel.Kind
          The Kind class is used to attach a sub-category tag to the chance nodes of Classes and Domains.
 
Field Summary
static NetworkModel.Category H_CATEGORY_CHANCE
          Represents the Category tag attached to ChanceNodes.
static NetworkModel.Category H_CATEGORY_DECISION
          Represents the Category tag attached to DecisionNodes.
static NetworkModel.Category H_CATEGORY_ERROR
          Represents an unknown or erroneous Category tag.
static NetworkModel.Category H_CATEGORY_INSTANCE
          Represents the Category tag attached to InstanceNodes.
static NetworkModel.Category H_CATEGORY_UTILITY
          Represents the Category tag attached to UtilityNodes.
static NetworkModel.Constraint H_CONSTRAINT_BACKWARD_EDGE_FORBIDDEN
          Represents the domain knowledge that a directed edge is forbidden from the second to the first Node in an ordered pair of Nodes.
static NetworkModel.Constraint H_CONSTRAINT_BACKWARD_EDGE_REQUIRED
          Represents the domain knowledge that a directed edge is required from the second to the first Node in an ordered pair of Nodes.
static NetworkModel.Constraint H_CONSTRAINT_EDGE_FORBIDDEN
          Represents the domain knowledge that an edge is forbidden between a particular pair of Nodes.
static NetworkModel.Constraint H_CONSTRAINT_EDGE_REQUIRED
          Represents the domain knowledge that an edge is required for a particular pair of Nodes.
static NetworkModel.Constraint H_CONSTRAINT_ERROR
          Used to denote error returns from the getEdgeConstraint method.
static NetworkModel.Constraint H_CONSTRAINT_FORWARD_EDGE_FORBIDDEN
          Represents the domain knowledge that a directed edge is forbidden from the first to the second Node in an ordered pair of Nodes.
static NetworkModel.Constraint H_CONSTRAINT_FORWARD_EDGE_REQUIRED
          Represents the domain knowledge that a directed edge is required from the first to the second Node in an ordered pair of Nodes.
static NetworkModel.Constraint H_CONSTRAINT_NONE
          Represents that no domain knowledge is available for a particular pair of Nodes.
static NetworkModel.Endian H_ENDIAN_BIG
          Represents the Endian value corresponding to big-endian byte order.
static NetworkModel.Endian H_ENDIAN_HOST
          Represents the Endian value corresponding the byte order used by the host machine.
static NetworkModel.Endian H_ENDIAN_LITTLE
          Represents the Endian value corresponding to little-endian byte order.
static NetworkModel.Kind H_KIND_CONTINUOUS
          Represents the Kind tag attached to continuous chance nodes.
static NetworkModel.Kind H_KIND_DISCRETE
          Represents the Kind tag attached to discrete chance nodes.
static NetworkModel.Kind H_KIND_ERROR
          Represents an unknown or erroneous Kind tag.
 
Constructor Summary
NetworkModel()
           
 
Method Summary
 void closeLogFile()
          Closes the log file associated with this NetworkModel.
abstract  void delete()
          Deletes this NetworkModel.
 void generateTables()
          Generates the conditional probability tables for all nodes of this NetworkModel.
 java.lang.String getAttribute(java.lang.String key)
          Returns an attribute value.
 java.util.LinkedList getAttributes()
          Returns the list of attributes associated with this NetworkModel.
 java.lang.String getFileName()
          Returns the file name most recently used for loading or saving this NetworkModel.
 java.lang.String getLogFile()
          Returns the name of the most recent log file opened by openLogFile(String, boolean) or openLogFile(String).
 Node getNodeByName(java.lang.String nodeName)
          Returns a Node by name.
 NodeList getNodes()
          Returns the Nodes of this NetworkModel.
 java.awt.geom.Point2D getNodeSize()
          Returns the size of the displayed nodes.
 java.lang.Object getUserData()
          Returns the value stored within the user data slot of this NetworkModel.
static double INFINITY()
          Returns infinity.
 void openLogFile(java.lang.String fileName)
          Opens a log file to be associated with this NetworkModel.
 void openLogFile(java.lang.String fileName, boolean append)
          Opens a log file to be associated with this NetworkModel.
 NodeList parseNodes(java.lang.String fileName, ParseListener parseListener)
          Parses file named fileName and returns a NodeList.
 void saveAsNet(java.lang.String fileName)
          Writes a NET description of this NetworkModel to a file.
 void setAttribute(java.lang.String key, java.lang.String value)
          Inserts the key/value pair in the attribute list for this NetworkModel.
 void setNodeSize(java.awt.geom.Point2D newNodeSize)
          Sets the size of the nodes.
 void setUserData(java.lang.Object data)
          Sets the user data field of this NetworkModel.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

H_CATEGORY_INSTANCE

public static final NetworkModel.Category H_CATEGORY_INSTANCE
Represents the Category tag attached to InstanceNodes.


H_CATEGORY_CHANCE

public static final NetworkModel.Category H_CATEGORY_CHANCE
Represents the Category tag attached to ChanceNodes.


H_CATEGORY_DECISION

public static final NetworkModel.Category H_CATEGORY_DECISION
Represents the Category tag attached to DecisionNodes.


H_CATEGORY_UTILITY

public static final NetworkModel.Category H_CATEGORY_UTILITY
Represents the Category tag attached to UtilityNodes.


H_CATEGORY_ERROR

public static final NetworkModel.Category H_CATEGORY_ERROR
Represents an unknown or erroneous Category tag. For example, NetworkModel.H_CATEGORY_ERROR is returned if the getCategory() method is called for a Node that has been deleted.


H_KIND_DISCRETE

public static final NetworkModel.Kind H_KIND_DISCRETE
Represents the Kind tag attached to discrete chance nodes.


H_KIND_CONTINUOUS

public static final NetworkModel.Kind H_KIND_CONTINUOUS
Represents the Kind tag attached to continuous chance nodes.


H_KIND_ERROR

public static final NetworkModel.Kind H_KIND_ERROR
Represents an unknown or erroneous Kind tag. For example, NetworkModel.H_KIND_ERROR is returned if the getKind() method is called for a Node that has been deleted.


H_ENDIAN_HOST

public static final NetworkModel.Endian H_ENDIAN_HOST
Represents the Endian value corresponding the byte order used by the host machine.


H_ENDIAN_BIG

public static final NetworkModel.Endian H_ENDIAN_BIG
Represents the Endian value corresponding to big-endian byte order.


H_ENDIAN_LITTLE

public static final NetworkModel.Endian H_ENDIAN_LITTLE
Represents the Endian value corresponding to little-endian byte order.


H_CONSTRAINT_NONE

public static final NetworkModel.Constraint H_CONSTRAINT_NONE
Represents that no domain knowledge is available for a particular pair of Nodes.


H_CONSTRAINT_EDGE_REQUIRED

public static final NetworkModel.Constraint H_CONSTRAINT_EDGE_REQUIRED
Represents the domain knowledge that an edge is required for a particular pair of Nodes.


H_CONSTRAINT_FORWARD_EDGE_REQUIRED

public static final NetworkModel.Constraint H_CONSTRAINT_FORWARD_EDGE_REQUIRED
Represents the domain knowledge that a directed edge is required from the first to the second Node in an ordered pair of Nodes.


H_CONSTRAINT_BACKWARD_EDGE_REQUIRED

public static final NetworkModel.Constraint H_CONSTRAINT_BACKWARD_EDGE_REQUIRED
Represents the domain knowledge that a directed edge is required from the second to the first Node in an ordered pair of Nodes.


H_CONSTRAINT_EDGE_FORBIDDEN

public static final NetworkModel.Constraint H_CONSTRAINT_EDGE_FORBIDDEN
Represents the domain knowledge that an edge is forbidden between a particular pair of Nodes.


H_CONSTRAINT_FORWARD_EDGE_FORBIDDEN

public static final NetworkModel.Constraint H_CONSTRAINT_FORWARD_EDGE_FORBIDDEN
Represents the domain knowledge that a directed edge is forbidden from the first to the second Node in an ordered pair of Nodes.


H_CONSTRAINT_BACKWARD_EDGE_FORBIDDEN

public static final NetworkModel.Constraint H_CONSTRAINT_BACKWARD_EDGE_FORBIDDEN
Represents the domain knowledge that a directed edge is forbidden from the second to the first Node in an ordered pair of Nodes.


H_CONSTRAINT_ERROR

public static final NetworkModel.Constraint H_CONSTRAINT_ERROR
Used to denote error returns from the getEdgeConstraint method.

Constructor Detail

NetworkModel

public NetworkModel()
Method Detail

delete

public abstract void delete()
                     throws ExceptionHugin
Deletes this NetworkModel.

Throws:
ExceptionHugin

getAttribute

public java.lang.String getAttribute(java.lang.String key)
                              throws ExceptionHugin
Returns an attribute value. That is, the value associated with a key in the attribute list for this NetworkModel.

Parameters:
key - the key for which the attribute value is returned (a String).
Returns:
A String containing the attribute value.
Throws:
ExceptionHugin

getAttributes

public java.util.LinkedList getAttributes()
                                   throws ExceptionHugin
Returns the list of attributes associated with this NetworkModel.

Returns:
A LinkedList.
Throws:
ExceptionHugin

generateTables

public void generateTables()
                    throws ExceptionHugin
Generates the conditional probability tables for all nodes of this NetworkModel. This is done by calling generateTable for all nodes having a model, so the descriptions of the generateTable method for DiscreteChanceNodes and UtilityNodes also apply here.

Throws:
ExceptionHugin

getFileName

public java.lang.String getFileName()
                             throws ExceptionHugin
Returns the file name most recently used for loading or saving this NetworkModel.

Returns:
A string.
Throws:
ExceptionHugin

getNodes

public NodeList getNodes()
                  throws ExceptionObjectNotAlive
Returns the Nodes of this NetworkModel. No ordering can be inferred.

Returns:
NodeList containing the Nodes of this NetworkModel.
Throws:
ExceptionObjectNotAlive

getNodeByName

public Node getNodeByName(java.lang.String nodeName)
                   throws ExceptionHugin
Returns a Node by name.

Parameters:
nodeName - a string containing the name of the Node to be found in this NetworkModel.
Returns:
A Node named 'name' in this NetworkModel.
Throws:
ExceptionHugin

getNodeSize

public java.awt.geom.Point2D getNodeSize()
                                  throws ExceptionHugin
Returns the size of the displayed nodes.

Returns:
a Point2D.Double(width, height).
Throws:
ExceptionHugin

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.String value)
                  throws ExceptionHugin
Inserts the key/value pair in the attribute list for this NetworkModel. If the key is already defined, the value is updated. If no value is provided, the attribute is removed.

Parameters:
key - The key identifying the attribute to be updated (a String).
value - The value of the attribute (a String).
Throws:
ExceptionHugin

openLogFile

public void openLogFile(java.lang.String fileName,
                        boolean append)
                 throws ExceptionHugin
Opens a log file to be associated with this NetworkModel.

Parameters:
fileName - the name of the log file.
append - if 'true' opens the log file in append mode; otherwise, opens in create mode.
Throws:
ExceptionHugin

openLogFile

public void openLogFile(java.lang.String fileName)
                 throws ExceptionHugin
Opens a log file to be associated with this NetworkModel. The file is opened in create mode.

Parameters:
fileName - the name of the log file.
Throws:
ExceptionHugin

closeLogFile

public void closeLogFile()
                  throws ExceptionHugin
Closes the log file associated with this NetworkModel.

Throws:
ExceptionHugin

getLogFile

public java.lang.String getLogFile()
                            throws ExceptionObjectNotAlive
Returns the name of the most recent log file opened by openLogFile(String, boolean) or openLogFile(String).

Returns:
String or null (if no log file has been opened or the most recent call to openLogFile() has been succeeded by a call to closeLogFile().)
Throws:
ExceptionObjectNotAlive

setNodeSize

public void setNodeSize(java.awt.geom.Point2D newNodeSize)
                 throws ExceptionHugin
Sets the size of the nodes.

Parameters:
newNodeSize - a Point2D object with width and height of the Nodes in this NetworkModel.
Throws:
ExceptionHugin

getUserData

public java.lang.Object getUserData()
                             throws ExceptionObjectNotAlive
Returns the value stored within the user data slot of this NetworkModel. If the stored value is NULL, or if no value has been stored, NULL is returned. It is the responsibility of the application programmer to ensure that the data is valid, that pointers are accessed correctly, etc.

Also note that when you delete a domain, Hugin does not attempt to delete the data pointed to by the user data slot. It is the responsibility of the user.

Returns:
Pointer stored within the NetworkModel as a reference to user data associated with this NetworkModel.
Throws:
ExceptionObjectNotAlive

setUserData

public void setUserData(java.lang.Object data)
                 throws ExceptionHugin
Sets the user data field of this NetworkModel. The Hugin API provides a slot within each NetworkModel for use exclusively by the user/application. This slot can hold a pointer to arbitrary data, such as a file, a function pointer, etc. Please note that Hugin does not do anything to the user data. Data is not even copied. Only the pointer to the data is stored.

Parameters:
data - Pointer to user-defined data associated with this NetworkModel.
Throws:
ExceptionHugin

saveAsNet

public void saveAsNet(java.lang.String fileName)
               throws ExceptionHugin
Writes a NET description of this NetworkModel to a file.

Parameters:
fileName - the name of the file in which to store the NET description (a String).
Throws:
ExceptionHugin

parseNodes

public NodeList parseNodes(java.lang.String fileName,
                           ParseListener parseListener)
                    throws ExceptionHugin
Parses file named fileName and returns a NodeList. This is used for reading an elimination order from a file.

Parameters:
fileName - a string containing the name of a file of node names.
parseListener - the ParseListener used for handling parse errors.
Throws:
ExceptionHugin

INFINITY

public static double INFINITY()
Returns infinity.