COM.hugin.HAPI
Class InstanceNode

java.lang.Object
  extended byCOM.hugin.HAPI.Node
      extended byCOM.hugin.HAPI.InstanceNode

public class InstanceNode
extends Node

InstanceNodes are the key building block of object-oriented Bayesian networks and influence diagrams.

An InstanceNode represents an instance of a Class (i.e., a Bayesian network or an influence diagram). In other words, an instance node represents a subnetwork. The Class of which InstanceNodes exist in other Classes can itself contain InstanceNodes, whereby an object-oriented network can be viewed as a hierarchical description of a problem domain. Describing a network in a hierarchical fashion often makes the network much less cluttered, and thus provides a much better means of communicating ideas among knowledge engineers and users.

As systems often are composed of collections of identical or similar components, models of systems often contain repetitive patterns. The notion of InstanceNodes makes it very easy to construct multiple identical instances of a network fragment.

An InstanceNode is connected to other nodes via its interface nodes, which are the input Nodes and the output Nodes of the Class of which the InstanceNode is an instance. Chance nodes and decision nodes of the encapsulating Class (i.e., network) as well as output nodes of InstanceNodes of the encapsulating Class can be bound to input nodes of an InstanceNode.

As the output nodes of an InstanceNode can be parents of non-InstanceNodes, these output nodes are represented in the "home Class" of the InstanceNode as clones of the output nodes of the "instance Class" of the InstanceNode. Therefore, the output nodes of InstanceNodes are sometimes referred to as "output clones".


Constructor Summary
InstanceNode(Class home, Class instanceOf)
          Constructs a new InstanceNode.
 
Method Summary
 void delete()
          Deletes this InstanceNode.
 NetworkModel.Category getCategory()
          Returns the Category for this InstanceNode.
 Node getInput(Node formalInput)
          Returns the actual input node associated with a formal input node for this InstanceNode.
 Class getInstanceClass()
          Returns the instance Class of this InstanceNode (i.e., the Class on which this InstanceNode is based).
 NetworkModel.Kind getKind()
          Returns the Kind for this InstanceNode.
 Node getOutput(Node output)
          Returns the output node of this InstanceNode that is a clone of a given output node of the Class from which this InstanceNode has been instantiated.
 NodeList getOutputs()
          Returns the output nodes (i.e., output clones) of this InstanceNode.
 void setInput(Node formalInput, Node actualInput)
          Binds a node to an input node of this InstanceNode.
 void substituteClass(Class newClass)
          Replace the class that this instance node represents.
 void unsetInput(Node formalInput)
          Unbinds an input node of this InstanceNode.
 
Methods inherited from class COM.hugin.HAPI.Node
addParent, addToInputs, addToOutputs, evidenceIsEntered, evidenceIsPropagated, evidenceToPropagate, getAttribute, getAttributes, getChildren, getDomain, getEdgeConstraint, getHome, getHomeClass, getHomeDomain, getInstance, getJunctionTree, getLabel, getMaster, getModel, getName, getParents, getPosition, getSource, getUserData, likelihoodIsEntered, likelihoodIsPropagated, removeFromInputs, removeFromOutputs, removeParent, reverseEdge, setAttribute, setAttributes, setEdgeConstraint, setLabel, setName, setPosition, setUserData, switchParent
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InstanceNode

public InstanceNode(Class home,
                    Class instanceOf)
             throws ExceptionHugin
Constructs a new InstanceNode. The InstanceNode is an instance of Class 'instanceOf' and is added to Class 'home'.

Parameters:
home - the home Class of the new InstanceNode.
instanceOf - the Class from which to instantiate the new InstanceNode.
Method Detail

getCategory

public NetworkModel.Category getCategory()
                                  throws ExceptionObjectNotAlive
Returns the Category for this InstanceNode.

Overrides:
getCategory in class Node
Returns:
NetworkModel.H_CATEGORY_INSTANCE.
Throws:
ExceptionObjectNotAlive

getKind

public NetworkModel.Kind getKind()
                          throws ExceptionObjectNotAlive
Returns the Kind for this InstanceNode.

Overrides:
getKind in class Node
Returns:
NetworkModel.H_KIND_DISCRETE.
Throws:
ExceptionObjectNotAlive

getOutput

public Node getOutput(Node output)
               throws ExceptionHugin
Returns the output node of this InstanceNode that is a clone of a given output node of the Class from which this InstanceNode has been instantiated.

Parameters:
output - the output node of the Class from which this InstanceNode has been instantiated.
Throws:
ExceptionHugin

getOutputs

public NodeList getOutputs()
                    throws ExceptionHugin
Returns the output nodes (i.e., output clones) of this InstanceNode.

Returns:
NodeList containing the output Nodes of this InstanceNode.
Throws:
ExceptionHugin

setInput

public void setInput(Node formalInput,
                     Node actualInput)
              throws ExceptionHugin
Binds a node to an input node of this InstanceNode.

Parameters:
formalInput - the formal input node of this InstanceNode. This node is to be considered a placeholder for the 'actualInput'.
actualInput - the actual input node to be bound to 'formalInput'. This node must belong to the same Class as this InstanceNode.
Throws:
ExceptionHugin

unsetInput

public void unsetInput(Node formalInput)
                throws ExceptionHugin
Unbinds an input node of this InstanceNode.

Parameters:
formalInput - the input node to become unbound.
Throws:
ExceptionHugin

getInput

public Node getInput(Node formalInput)
              throws ExceptionHugin
Returns the actual input node associated with a formal input node for this InstanceNode.

Parameters:
formalInput - The formal input node of this InstanceNode.

Returns:
The actual input - the node bound to 'formalInput'.
Throws:
ExceptionHugin

getInstanceClass

public Class getInstanceClass()
                       throws ExceptionHugin
Returns the instance Class of this InstanceNode (i.e., the Class on which this InstanceNode is based).

Throws:
ExceptionHugin

delete

public void delete()
            throws ExceptionHugin
Deletes this InstanceNode.

Overrides:
delete in class Node
Throws:
ExceptionHugin

substituteClass

public void substituteClass(Class newClass)
                     throws ExceptionHugin
Replace the class that this instance node represents. The node itself is not deleted during this operation, nor are the input and output nodes. However, new output nodes may be created.

This operation is only allowed, if the interface of the original class is a true subset of the interface of the given newClass argument.

Parameters:
newClass - The class that the instance node should represent.
Throws:
ExceptionHugin