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 and Class.


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.Kind
          The Kind class is used to attach a sub-category tag to the chance and decision 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_FUNCTION
          Represents the Category tag attached to FunctionNodes.
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_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.Kind H_KIND_CONTINUOUS
          Represents the Kind tag attached to continuous nodes.
static NetworkModel.Kind H_KIND_DISCRETE
          Represents the Kind tag attached to discrete nodes.
static NetworkModel.Kind H_KIND_OTHER
          Represents the Kind tag attached to utility, function, and instance nodes.
 
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.
 boolean isAlive()
          Is this NetworkModel object alive?
 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_FUNCTION

public static final NetworkModel.Category H_CATEGORY_FUNCTION
Represents the Category tag attached to FunctionNodes.


H_KIND_DISCRETE

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


H_KIND_CONTINUOUS

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


H_KIND_OTHER

public static final NetworkModel.Kind H_KIND_OTHER
Represents the Kind tag attached to utility, function, and instance nodes.


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.

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. Returns null if no value is associated with the given key.

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

Throws:
ExceptionHugin

getNodes

public NodeList getNodes()
                  throws ExceptionHugin
Returns the Nodes of this NetworkModel.

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

getNodeByName

public Node getNodeByName(java.lang.String nodeName)
                   throws ExceptionHugin
Returns a Node by name. If no node by the given name exists, null is returned.

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()
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.

Returns:
Object stored within the NetworkModel.

setUserData

public void setUserData(java.lang.Object data)
Sets the user data field of this NetworkModel. The Hugin API provides a slot within each NetworkModel for use exclusively by the user/application.

Parameters:
data - User-defined data associated with this NetworkModel.

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.


isAlive

public boolean isAlive()
Is this NetworkModel object alive?