com.cra.bnet.engine
Class AddMultiplyGraph

java.lang.Object
  |
  +--com.cra.bnet.engine.AddMultiplyGraph

public class AddMultiplyGraph
extends Object

An Add-Multiply Graph used to calculate beliefs in a Bayesian network.


Constructor Summary
AddMultiplyGraph()
          Creates a new empty AddMultiplyGraph.
AddMultiplyGraph(AddNode[] roots)
          Creates a new AddMultiplyGraph using the specified root node.
 
Method Summary
 double[] getBeliefs(DiscreteNode node)
          Returns the beliefs for the specified variable in the Bayesian network.
 Iterator getBfsIterator()
          Returns an iterator over the nodes in this AMG in breadth-first order, starting at the root node.
 CptEntryNode getCptEntryNode(DiscreteNode node, int instantiationIndex)
           
 double[] getEvidence(DiscreteNode node)
          Returns the evidence for the specified variable in the Bayesian network.
 EvidenceNode getEvidenceNode(DiscreteNode node, int state)
           
 int getIndex(DiscreteNode node)
           
 AddNode[] getRoots()
          Returns this AMG's root node.
 DiscreteNode getVariableIndex(int index)
          Returns the discrete node at the specified index.
 boolean isResetNeeded()
           
 void postEvidence(DiscreteNode node, double[] evidence)
          Posts the specified evidence to the specified variable.
 void reset()
          Resets/initializes this AMG.
 void retractAllEvidence()
          Retracts the evidence from all variables.
 void retractEvidence(DiscreteNode node)
          Retracts the evidence from the specified variable.
 void setResetNeeded(boolean resetNeeded)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AddMultiplyGraph

public AddMultiplyGraph()
Creates a new empty AddMultiplyGraph. An empty add-multiply graph can be used for an empty Bayesian network.


AddMultiplyGraph

public AddMultiplyGraph(AddNode[] roots)
Creates a new AddMultiplyGraph using the specified root node. Clients should use AddMultiplyGraphFactory.createAddMultiplyGraph instead of this constructor to create instances of this class.

Parameters:
roots - root node.
Method Detail

getRoots

public AddNode[] getRoots()
Returns this AMG's root node.

Returns:
this AMG's root node.

reset

public void reset()
Resets/initializes this AMG.


getBeliefs

public double[] getBeliefs(DiscreteNode node)
Returns the beliefs for the specified variable in the Bayesian network.

Parameters:
node - index of a node in the Bayesian network.
Returns:
the beliefs for the specified variable in the Bayesian network.

getVariableIndex

public DiscreteNode getVariableIndex(int index)
Returns the discrete node at the specified index.

Parameters:
index -
Returns:
the discrete node at the specified index.

getIndex

public int getIndex(DiscreteNode node)

getEvidence

public double[] getEvidence(DiscreteNode node)
Returns the evidence for the specified variable in the Bayesian network.

Parameters:
node - index of a node in the Bayesian network.
Returns:
the evidence for the specified variable in the Bayesian network.

postEvidence

public void postEvidence(DiscreteNode node,
                         double[] evidence)
Posts the specified evidence to the specified variable.

Parameters:
node - index of a node in the Bayesian network.
evidence - evidence to post.

retractEvidence

public void retractEvidence(DiscreteNode node)
Retracts the evidence from the specified variable.

Parameters:
node - index of a node in the Bayesian network.

retractAllEvidence

public void retractAllEvidence()
Retracts the evidence from all variables.


getBfsIterator

public Iterator getBfsIterator()
Returns an iterator over the nodes in this AMG in breadth-first order, starting at the root node. Elements returned by the iterator are guaranteed to be of type Node.

Returns:
Returns an iterator over the nodes in this AMG in breadth-first order, starting at the root node.

getEvidenceNode

public EvidenceNode getEvidenceNode(DiscreteNode node,
                                    int state)

getCptEntryNode

public CptEntryNode getCptEntryNode(DiscreteNode node,
                                    int instantiationIndex)

isResetNeeded

public boolean isResetNeeded()

setResetNeeded

public void setResetNeeded(boolean resetNeeded)