com.cra.bnet.engine
Interface InferenceEngine

All Known Implementing Classes:
AmgInferenceEngine, JunctionTreeInferenceEngine, ScgInferenceEngine

public interface InferenceEngine

An engine that performs probabilistic inference on a Bayesian network. This interface represents an inference engine used by the BayesianNetwork class to compute belief values given evidence. BayesianNetwork holds a reference to an instance of this interface and forwards all evidence-related and belief-related calls to it. Since BayesianNetwork refers to an interface and not a concrete class, clients can change BayesianNetwork's inference engine dynamically at run-time.


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.
 

Method Detail

getBeliefs

public double[] getBeliefs(DiscreteNode node)
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.

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)
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.

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)
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.

Parameters:
node - variable to post evidence to.
evidence - evidence in the form of a likelihood vector.

removeEvidence

public void removeEvidence(DiscreteNode node)
Removes (or equivalently, retracts) evidence from the specified variable.

Parameters:
node - variable whose evidence is retracted.

clearEvidence

public void clearEvidence()
Removes (or equivalently, retracts) evidence from all nodes in the network.


removed

public 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.