blog
Class Evidence

java.lang.Object
  extended by blog.Evidence

public class Evidence
extends java.lang.Object

Stores the information extracted from evidence file. The evidence is of 2 kinds:

An Evidence object serves two purposes. First, it defines a set of Skolem constants, which are additional constant symbols that can be used in the evidence and query files. Second, it defines a set of evidence variables and an observed value for each of these variables. The evidence variables may be basic variables or other random variables created to represent the evidence. For example, if we have a value evidence statement:
height(mother(John)) = 13.7
then the evidence object creates a new random variable whose value is the value of the term height(mother(John)).

See Also:
SymbolEvidenceStatement, ValueEvidenceStatement

Constructor Summary
Evidence()
          Creates a new Evidence object with no evidence.
 
Method Summary
 void addAll(Evidence another)
          Adds all symbol and value evidence statements from another evidence object.
 void addSymbolEvidence(SymbolEvidenceStatement sevid)
           
 void addValueEvidence(ValueEvidenceStatement evid)
           
 boolean checkTypesAndScope(Model model)
          Returns true if the evidence satisfies type and scope constraints.
 int compile()
          Does compilation steps that can only be done correctly once the model is complete.
 double getEvidenceLogProb(PartialWorld curWorld)
           
 double getEvidenceLogProb(PartialWorld curWorld, Timestep t)
           
 double getEvidenceProb(PartialWorld curWorld)
           
 double getEvidenceProb(PartialWorld curWorld, Timestep t)
           
 java.util.Set getEvidenceVars()
          Returns the set of evidence variables for which the user has observed values.
 java.util.Set getEvidenceVars(Timestep t)
           
 java.lang.Object getObservedValue(BayesNetVar var)
          Returns the observed value of the given variable.
 SkolemConstant getSkolemConstant(java.lang.String name)
          Returns the SkolemConstant object for the given symbol, or null if no such Skolem constant has been introduced.
 java.util.List getSkolemConstants()
          Returns an unmodifiable List of the SkolemConstant objects introduced by this evidence, in the order they were introduced.
 java.util.Collection getSymbolEvidence()
          Returns an unmodifiable Collection of SymbolEvidenceStatement objects.
 java.util.Collection getValueEvidence()
          Returns an unmodifiable Collection of ValueEvidenceStatement objects.
 boolean isDetermined(PartialWorld w)
          Returns true if the given partial world is complete enough to determine whether this evidence is true or false.
 boolean isTrue(PartialWorld w)
          Returns true if this evidence is true in the given world; otherwise false.
 void print(java.io.PrintStream s)
          Prints the evidence to the given stream.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Evidence

public Evidence()
Creates a new Evidence object with no evidence.

Method Detail

addSymbolEvidence

public void addSymbolEvidence(SymbolEvidenceStatement sevid)

getSymbolEvidence

public java.util.Collection getSymbolEvidence()
Returns an unmodifiable Collection of SymbolEvidenceStatement objects.


addValueEvidence

public void addValueEvidence(ValueEvidenceStatement evid)

getValueEvidence

public java.util.Collection getValueEvidence()
Returns an unmodifiable Collection of ValueEvidenceStatement objects.


addAll

public void addAll(Evidence another)
Adds all symbol and value evidence statements from another evidence object.


getSkolemConstant

public SkolemConstant getSkolemConstant(java.lang.String name)
Returns the SkolemConstant object for the given symbol, or null if no such Skolem constant has been introduced.


getSkolemConstants

public java.util.List getSkolemConstants()
Returns an unmodifiable List of the SkolemConstant objects introduced by this evidence, in the order they were introduced.


getEvidenceVars

public java.util.Set getEvidenceVars()
Returns the set of evidence variables for which the user has observed values.

Returns:
an unmodifiable Set of BayesNetVar objects

getEvidenceVars

public java.util.Set getEvidenceVars(Timestep t)

getObservedValue

public java.lang.Object getObservedValue(BayesNetVar var)
Returns the observed value of the given variable.

Throws:
java.lang.IllegalArgumentException - if no value has been observed for the given variable

isDetermined

public boolean isDetermined(PartialWorld w)
Returns true if the given partial world is complete enough to determine whether this evidence is true or false.


isTrue

public boolean isTrue(PartialWorld w)
Returns true if this evidence is true in the given world; otherwise false.


print

public void print(java.io.PrintStream s)
Prints the evidence to the given stream.


getEvidenceProb

public double getEvidenceProb(PartialWorld curWorld)

getEvidenceProb

public double getEvidenceProb(PartialWorld curWorld,
                              Timestep t)

getEvidenceLogProb

public double getEvidenceLogProb(PartialWorld curWorld)

getEvidenceLogProb

public double getEvidenceLogProb(PartialWorld curWorld,
                                 Timestep t)

checkTypesAndScope

public boolean checkTypesAndScope(Model model)
Returns true if the evidence satisfies type and scope constraints. If there are type or scope errors, prints messages to standard error and returns false.


compile

public int compile()
Does compilation steps that can only be done correctly once the model is complete. Prints messages to standard error if any errors are encountered. Returns the number of errors encountered.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object