COM.hugin.HAPI
Class DiscreteNode

java.lang.Object
  extended byCOM.hugin.HAPI.Node
      extended byCOM.hugin.HAPI.DiscreteNode
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
DiscreteChanceNode, DiscreteDecisionNode

public abstract class DiscreteNode
extends Node

The DiscreteNode class. Base class for all discrete nodes.


Method Summary
 boolean caseIsSet(int c)
          Returns true if a value has been set for this DiscreteNode in case c; otherwise, returns false.
 void enterFinding(int state, double finding)
          Specifies a finding value for a given state with all other states unaffected.
 void generateTable()
          Generates the table of this DiscreteNode from its model (a missing model will trigger an ExceptionUsage).
 double getBelief(int state)
          Returns the belief for the specified state of this DiscreteNode.
 int getCaseState(int c)
          Returns the state of this DiscreteNode for case c.
 double getEnteredFinding(int state)
          Returns the entered finding for the specified state of this node.
 double getEntropy()
          Computes the entropy of this node.
 double getExpectedUtility(int state)
          Returns the expected utility associated with the specified action (state).
 NetworkModel.Kind getKind()
          Returns the Kind of this DiscreteNode.
 double getMutualInformation(DiscreteNode node)
          Computes the mutual information between this node and the specified node.
 int getNumberOfStates()
          Returns the number of states of this node.
 double getPropagatedFinding(int state)
          Returns the propagated finding.
 int getSampledState()
          Returns the state index of this DiscreteNode for the configuration generated by the most recent call to Domain.simulate().
 double[] getSensitivityConstants(int input)
          Returns the four constants of the specified sensitivity function.
 double[] getSensitivityConstants(int input, int output)
          Returns the four constants of the specified sensitivity function.
 int getStateIndex(java.lang.String label)
          Returns the index of the state matching the specified label.
 java.lang.String getStateLabel(int state)
          Returns the label of the specified state.
 void retractFindings()
          Retracts all findings for this node.
 void selectState(int state)
          Selects the specified state of this node.
 void setCaseState(int c, int state)
          Sets the state of this DiscreteNode to state in case c.
 void setNumberOfStates(int stateCount)
          Sets the number of states of this node.
 void setStateLabel(int state, java.lang.String newLabel)
          Sets the label of the specified state.
 void unsetCase(int c)
          Specifies that the state of this DiscreteNode is "unknown" for case c.
 
Methods inherited from class COM.hugin.HAPI.Node
addParent, addToInputs, addToOutputs, clone, delete, evidenceIsEntered, evidenceIsPropagated, evidenceToPropagate, getAttribute, getAttributes, getCategory, getChildren, getDomain, getEdgeConstraint, getHome, getHomeClass, getHomeDomain, getInstance, getJunctionTree, getLabel, getMaster, getModel, getName, getParents, getPosition, getSource, getTable, getUserData, isAlive, 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 DiscreteNode. 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 representing the belief.
Throws:
ExceptionHugin

getExpectedUtility

public double getExpectedUtility(int state)
                          throws ExceptionHugin
Returns the expected utility associated with the specified action (state).

Parameters:
state - An integer value designating which state to examine.
Returns:
A real value expressing the expected utility associated with the specified state.

Throws:
ExceptionHugin

getEnteredFinding

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

Parameters:
state - an integer value representing which state to examine.
Returns:
A real number 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 node.

Parameters:
state - an integer representing the state to be examined.
Returns:
A real number 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 of this node. The states are numbered from 0 to N-1, where N is the number of states of the node.

Throws:
ExceptionHugin

setNumberOfStates

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

Throws:
ExceptionHugin

getStateLabel

public java.lang.String getStateLabel(int state)
                               throws ExceptionHugin
Returns the label of the specified state.

Parameters:
state - the index (a nonnegative integer) of the state; must be less than the number of states of the node
Returns:
the label (a String) of the specified state
Throws:
ExceptionHugin

getStateIndex

public int getStateIndex(java.lang.String label)
                  throws ExceptionHugin
Returns the index of the state matching the specified label. If there is no (unique) state with the specified state label, -1 is returned.

Parameters:
label - the state label to search for
Returns:
the index of the state having the specified state label.
Throws:
ExceptionHugin

setStateLabel

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

Parameters:
state - the index (a nonnegative integer) of the state; must be less than the number of states of the node.
newLabel - the desired state label (a String).
Throws:
ExceptionHugin

selectState

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

Throws:
ExceptionHugin

enterFinding

public void enterFinding(int state,
                         double finding)
                  throws ExceptionHugin
Specifies a finding 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 nonnegative real number as the finding value.
Throws:
ExceptionHugin

getKind

public NetworkModel.Kind getKind()
Returns the Kind of this DiscreteNode.

Specified by:
getKind in class Node
Returns:
NetworkModel.H_KIND_DISCRETE.

setCaseState

public void setCaseState(int c,
                         int state)
                  throws ExceptionHugin
Sets the state of this DiscreteNode 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 DiscreteNode is "unknown" for case c.

Parameters:
c - the case index (an integer in the range 0, ..., number of cases)
Throws:
ExceptionHugin

caseIsSet

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

Parameters:
c - the case index (an integer in the range 0, ..., number of cases)
Throws:
ExceptionHugin

getCaseState

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

Parameters:
c - the case index (an integer in the range 0, ..., number of cases)
Throws:
ExceptionHugin

getSampledState

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

Throws:
ExceptionHugin

generateTable

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

Throws:
ExceptionHugin

getEntropy

public double getEntropy()
                  throws ExceptionHugin
Computes the entropy of this node.

Throws:
ExceptionHugin

getMutualInformation

public double getMutualInformation(DiscreteNode node)
                            throws ExceptionHugin
Computes the mutual information between this node and the specified node.

Parameters:
node - the other node
Throws:
ExceptionHugin

getSensitivityConstants

public double[] getSensitivityConstants(int input)
                                 throws ExceptionHugin
Returns the four constants of the specified sensitivity function. The output probability of this function was specified in the preceding call to computeSensitivityData. If the results produced by that call have been invalidated, a usage exception is thrown.

Parameters:
input - specifies a conditional probability (or policy) parameter of this node (i.e., input is the index of an entry in the CPT/policy of this node).
Returns:
an array of size 4 containing the constants of the specified sensitivity function.
Throws:
ExceptionHugin

getSensitivityConstants

public double[] getSensitivityConstants(int input,
                                        int output)
                                 throws ExceptionHugin
Returns the four constants of the specified sensitivity function. The output probability of this function must be one of the output probabilities specified in the preceding call to computeSensitivityData. If the results produced by that call have been invalidated, a usage exception is thrown.

Parameters:
input - specifies a conditional probability (or policy) parameter of this node (i.e., input is the index of an entry in the CPT/policy of this node).
output - identifies one of the output probabilities specified in the call to computeSensitivityData.
Returns:
an array of size 4 containing the constants of the specified sensitivity function.
Throws:
ExceptionHugin