com.cra.bnet.engine
Class AmgInferenceEngine

java.lang.Object
  |
  +--com.cra.bnet.engine.AmgInferenceEngine
All Implemented Interfaces:
InferenceEngine

public class AmgInferenceEngine
extends Object
implements InferenceEngine

Inference engine based on an add-multiply graph.


Constructor Summary
AmgInferenceEngine(BayesianNetwork network)
          Creates a new AMG inference engine using the specified Bayesian network.
AmgInferenceEngine(BayesianNetwork network, boolean primary)
          Creates a new AMG inference engine using the specified Bayesian network.
 
Method Summary
 void clearEvidence()
          Removes (or equivalently, retracts) evidence from all nodes in the network.
 double[] getBeliefs(DiscreteNode node)
          Returns the current beliefs for the specified variable.
 double[] getEvidence(DiscreteNode node)
          Returns the current evidence associated with the specified variable.
 void removed()
          Called by BayesianNetwork to notify this inference engine that it has been replaced by another inference engine and will not be used anymore.
 void removeEvidence(DiscreteNode node)
          Removes (or equivalently, retracts) evidence from the specified variable.
 void setEvidence(DiscreteNode node, double[] evidence)
          Posts the specified evidence to the specified variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AmgInferenceEngine

public AmgInferenceEngine(BayesianNetwork network)
Creates a new AMG inference engine using the specified Bayesian network. This constructor just calls this(network, true).

Parameters:
network - Bayesian network for this inference engine.

AmgInferenceEngine

public AmgInferenceEngine(BayesianNetwork network,
                          boolean primary)
Creates a new AMG inference engine using the specified Bayesian network.

Parameters:
network - Bayesian network for this inference engine.
primary - true if this engine is the network's primary engine and false if this engine is just for temporary use.
Method Detail

removed

public void removed()
Description copied from interface: InferenceEngine
Called by BayesianNetwork to notify this inference engine that it has been replaced by another inference engine and will not be used anymore.

Specified by:
removed in interface InferenceEngine

getBeliefs

public double[] getBeliefs(DiscreteNode node)
Description copied from interface: InferenceEngine
Returns the current beliefs for the specified variable. The beliefs are the probability of each state of the variable given the evidence posted to the network. The returned double[] contains one belief value for each state of the specified variable and these belief values are in the same order as the specified variable's states. These belief values are guaranteed to be between 0.0 and 1.0 inclusive and sum to unity. A return value of null indicates that inconsistent evidence was posted. This method guarantees that the engine will be in a consistent state upon returning null, so that subsequent calls to this method will return valid beliefs. The consistent state is simply the state it was in before the inconsistent evidence was posted.

Specified by:
getBeliefs in interface InferenceEngine
Parameters:
node - variable whose beliefs are returned.
Returns:
the current beliefs for the specified variable or null if inconsistent evidence was posted.

getEvidence

public double[] getEvidence(DiscreteNode node)
Description copied from interface: InferenceEngine
Returns the current evidence associated with the specified variable. If no evidence has been posted for the specified variable, an array of all ones will be returned. The returned array contains one likelihood value for each state of the specified variable, in the same order as the states of the specified variable. These likelihood values are between 0.0 and 1.0 inclusive and need not sum to unity.

Specified by:
getEvidence in interface InferenceEngine
Returns:
the current evidence associated with the specified variable, or an array of ones if no evidence has been posted to the variable.

setEvidence

public void setEvidence(DiscreteNode node,
                        double[] evidence)
Description copied from interface: InferenceEngine
Posts the specified evidence to the specified variable. The likelihood array must contain one likelihood value for each state of the specified variable, in the same order as the states of the specified variable. These likelihood values must be between 0.0 and 1.0 inclusive and need not sum to unity.

Specified by:
setEvidence in interface InferenceEngine
Parameters:
node - variable to post evidence to.
evidence - evidence in the form of a likelihood vector.

removeEvidence

public void removeEvidence(DiscreteNode node)
Description copied from interface: InferenceEngine
Removes (or equivalently, retracts) evidence from the specified variable.

Specified by:
removeEvidence in interface InferenceEngine
Parameters:
node - variable whose evidence is retracted.

clearEvidence

public void clearEvidence()
Description copied from interface: InferenceEngine
Removes (or equivalently, retracts) evidence from all nodes in the network.

Specified by:
clearEvidence in interface InferenceEngine