COM.hugin.HAPI
Class DiscreteChanceNode

java.lang.Object
  extended byCOM.hugin.HAPI.Node
      extended byCOM.hugin.HAPI.DiscreteChanceNode
Direct Known Subclasses:
BooleanDCNode, IntervalDCNode, LabelledDCNode, NumberedDCNode

public class DiscreteChanceNode
extends Node

The discrete chance node. This class is the ancestor for all discrete nodes.


Method Summary
 boolean caseIsSet(int c)
          Returns 'true' if a value has been set for this DiscreteChanceNode in case 'c'; otherwise, returns 'false'.
 void delete()
          Deletes this DiscreteChanceNode.
 void enterFinding(int state, double finding)
          Specifies a state value for a given state with all other states unaffected.
 void generateTable()
          Generates the conditional probability table of this DiscreteChanceNode from its model (a missing model will trigger an ExceptionUsage).
 double getBelief(int state)
          Returns the belief for the specified state of this DiscreteChanceNode.
 int getCaseState(int c)
          Returns the state of this DiscreteChanceNode for case 'c'.
 NetworkModel.Category getCategory()
          Returns the Category for this DiscreteChanceNode.
 double getEnteredFinding(int state)
          Returns the entered finding for state of this.
 Table getExperienceTable()
          Returns the experience table of this DiscreteChanceNode.
 Table getFadingTable()
          Returns the fading table of this DiscreteChanceNode.
 NetworkModel.Kind getKind()
          Returns the Kind for this DiscreteChanceNode.
 int getNumberOfStates()
          Returns the number of states in this node.
 double getPropagatedFinding(int state)
          Returns the propagated finding.
 int getSampledState()
          Returns the state index of this DiscreteChanceNode for the configuration generated by the most recent call to simulate().
 int getSelection()
          Deprecated. Replaced by getSampledState().
 java.lang.String getStateLabel(int state)
          Returns the label of state.
 Table getTable()
          Returns the table associated with this DiscreteChanceNode.
 boolean hasExperienceTable()
          Returns 'true' if this DiscreteChanceNode has an experience table; returns 'false' otherwise.
 boolean hasFadingTable()
          Returns 'true' if this DiscreteChanceNode has a fading table; returns 'false' otherwise.
 void retractFindings()
          Retracts all findings for this node.
 void selectState(int state)
          Selects the specified state of this DiscreteChanceNode.
 void setCaseState(int c, int state)
          Sets the state of this DiscreteChanceNode to 'state' in case 'c'.
 void setNumberOfStates(int newNumber)
          Sets the number of states of this.
 void setStateLabel(int state, java.lang.String newLabel)
          Sets the state label of the node.
 void touchTable()
          Touches the table of this DiscreteChanceNode.
 void unSetCase(int c)
          Specifies that the state of this DiscreteChanceNode is 'unknown' for case 'c'.
 
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
 

Method Detail

getBelief

public double getBelief(int state)
                 throws ExceptionHugin
Returns the belief for the specified state of this DiscreteChanceNode. Note that if findings have been entered since the most recent propagation, the beliefs returned may not be up-to-date.

Parameters:
state - an integer value representing which state to examine.
Returns:
A real number (double precision) representing the belief.
Throws:
ExceptionHugin

getSelection

public int getSelection()
                 throws ExceptionHugin
Deprecated. Replaced by getSampledState().

Throws:
ExceptionHugin

getEnteredFinding

public double getEnteredFinding(int state)
                         throws ExceptionHugin
Returns the entered finding for state of this.

Parameters:
state - an integer value representing which state to examine.
Returns:
A real number (double precision) representing the entered finding.
Throws:
ExceptionHugin

getPropagatedFinding

public double getPropagatedFinding(int state)
                            throws ExceptionHugin
Returns the propagated finding. That is, it returns the finding value incorporated within the current JunctionTree potentials for the specified state of this DiscreteChanceNode.

Parameters:
state - an integer representing the state to be examined.
Returns:
A real number (double precision) expressing the propagated finding.
Throws:
ExceptionHugin

retractFindings

public void retractFindings()
                     throws ExceptionHugin
Retracts all findings for this node. This is equivalent to setting the finding value to 1 for all states of this node.

Throws:
ExceptionHugin

getNumberOfStates

public int getNumberOfStates()
                      throws ExceptionHugin
Returns the number of states in this node. The states are numbered from 0 to N-1.

Returns:
The number of states represented as an int.
Throws:
ExceptionHugin

setNumberOfStates

public void setNumberOfStates(int newNumber)
                       throws ExceptionHugin
Sets the number of states of this.

Throws:
ExceptionHugin

getStateLabel

public java.lang.String getStateLabel(int state)
                               throws ExceptionHugin
Returns the label of state. 0 < state < N, where N is the number of states in the node.

Parameters:
state - an integer representing the state to be examined.
Returns:
A string.
Throws:
ExceptionHugin

setStateLabel

public void setStateLabel(int state,
                          java.lang.String newLabel)
                   throws ExceptionHugin
Sets the state label of the node.

Parameters:
state - an integer representing a state.
newLabel - the desired state label (String).
Throws:
ExceptionHugin

getTable

public Table getTable()
               throws ExceptionHugin
Returns the table associated with this DiscreteChanceNode. The table is the conditional probability table for the node given its parents. The set of nodes associated with the table will be the (discrete) parents of the DiscreteChanceNode in unspecified order followed by the node itself.

Returns:
A Table
Throws:
ExceptionHugin

selectState

public void selectState(int state)
                 throws ExceptionHugin
Selects the specified state of this DiscreteChanceNode. This is equivalent to specifying the finding value 1 for the specified state and 0 for all other states.

Parameters:
state - an integer representing which state to be selected. States are numbered consecutively from 0 and upwards.
Throws:
ExceptionHugin

enterFinding

public void enterFinding(int state,
                         double finding)
                  throws ExceptionHugin
Specifies a state value for a given state with all other states unaffected.

Parameters:
state - an integer representing the state to be selected. States are numbered consecutively from 0 and upwards.
finding - A non-negative real number as the state value.
Throws:
ExceptionHugin

touchTable

public void touchTable()
                throws ExceptionHugin
Touches the table of this DiscreteChanceNode. This should be done to notify the inference engine whenever changes made to the Table should be used in subsequent inference. Changes made by the Hugin API will automatically provide this notification.

Throws:
ExceptionHugin

getCategory

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

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

getKind

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

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

setCaseState

public void setCaseState(int c,
                         int state)
                  throws ExceptionHugin
Sets the state of this DiscreteChanceNode to 'state' in case 'c'.

Parameters:
c - the case index represented as an integer.
state - the state represented as an integer.
Throws:
ExceptionHugin

unSetCase

public void unSetCase(int c)
               throws ExceptionHugin
Specifies that the state of this DiscreteChanceNode is 'unknown' for case 'c'.

Parameters:
c - the case index represented as an integer.
Throws:
ExceptionHugin

caseIsSet

public boolean caseIsSet(int c)
                  throws ExceptionHugin
Returns 'true' if a value has been set for this DiscreteChanceNode in case 'c'; otherwise, returns 'false'.

Parameters:
c - the case index represented as an integer.
Returns:
A boolean.
Throws:
ExceptionHugin

getCaseState

public int getCaseState(int c)
                 throws ExceptionHugin
Returns the state of this DiscreteChanceNode for case 'c'.

Parameters:
c - the case index represented as an integer.
Throws:
ExceptionHugin

hasExperienceTable

public boolean hasExperienceTable()
                           throws ExceptionHugin
Returns 'true' if this DiscreteChanceNode has an experience table; returns 'false' otherwise.

Throws:
ExceptionHugin

hasFadingTable

public boolean hasFadingTable()
                       throws ExceptionHugin
Returns 'true' if this DiscreteChanceNode has a fading table; returns 'false' otherwise.

Throws:
ExceptionHugin

getFadingTable

public Table getFadingTable()
                     throws ExceptionHugin
Returns the fading table of this DiscreteChanceNode.

Returns:
A Table.
Throws:
ExceptionHugin

getExperienceTable

public Table getExperienceTable()
                         throws ExceptionHugin
Returns the experience table of this DiscreteChanceNode.

Returns:
A Table.
Throws:
ExceptionHugin

getSampledState

public int getSampledState()
                    throws ExceptionHugin
Returns the state index of this DiscreteChanceNode for the configuration generated by the most recent call to simulate().

Returns:
An int - the state index sampled for this DiscreteChanceNode in the last invocation of simulate() on the Domain of the node.
Throws:
ExceptionHugin

generateTable

public void generateTable()
                   throws ExceptionHugin
Generates the conditional probability table of this DiscreteChanceNode from its model (a missing model will trigger an ExceptionUsage).

Throws:
ExceptionHugin

delete

public void delete()
            throws ExceptionHugin
Deletes this DiscreteChanceNode.

Overrides:
delete in class Node
Throws:
ExceptionHugin