blog
Class ArgSpecQuery

java.lang.Object
  extended by blog.AbstractQuery
      extended by blog.ArgSpecQuery
All Implemented Interfaces:
Query
Direct Known Subclasses:
FormulaQuery

public class ArgSpecQuery
extends AbstractQuery


Field Summary
protected  ArgSpec argSpec
           
protected  Histogram histogram
           
protected  java.io.PrintStream outputFile
           
protected  java.util.Map outputFiles
           
protected  int trialNum
           
protected  BayesNetVar variable
           
 
Constructor Summary
ArgSpecQuery(ArgSpec argSpec)
           
 
Method Summary
 ArgSpec argSpec()
           
 boolean checkTypesAndScope(Model model)
          Returns true if this query satisfies type and scope constraints.
 int compile()
          Compiles the underlying ArgSpec, and initializes the variable corresponding to this query.
 Histogram getHistogram()
           
 java.lang.Object getLocation()
          Returns an object whose toString method yields a description of the location where this query occurred in an input file.
 java.util.Collection<? extends BayesNetVar> getVariables()
          Returns a collection of (basic or derived) random variables such that the result of this query depends only on the posterior joint distribution for these variables.
 void logResults(int numSamples)
          If a log file has been specified, prints the results so far to that file.
 void printResults(java.io.PrintStream s)
          Prints the results of this query to the given stream.
 void printVarianceResults(java.io.PrintStream s)
          Prints across-run statistics.
 void setPosterior(ve.Factor posterior)
          Throws an UnsupportedOperationException.
 java.lang.String toString()
           
 void updateStats(PartialWorld world, double weight)
          Updates the within-run statistics for this query to reflect the given world sampled with the given weight.
 void zeroOut()
          Ends the current run, records across-run statistics for it, and clears the within-run statistics.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

argSpec

protected ArgSpec argSpec

variable

protected BayesNetVar variable

histogram

protected Histogram histogram

trialNum

protected int trialNum

outputFiles

protected java.util.Map outputFiles

outputFile

protected java.io.PrintStream outputFile
Constructor Detail

ArgSpecQuery

public ArgSpecQuery(ArgSpec argSpec)
Method Detail

argSpec

public ArgSpec argSpec()

printResults

public void printResults(java.io.PrintStream s)
Description copied from interface: Query
Prints the results of this query to the given stream.


logResults

public void logResults(int numSamples)
Description copied from class: AbstractQuery
If a log file has been specified, prints the results so far to that file.

This default implementation does nothing.

Specified by:
logResults in interface Query
Overrides:
logResults in class AbstractQuery
Parameters:
numSamples - the number of samples taken by the inference engine so far (can be set to zero for non-sampling inference engines)

getVariables

public java.util.Collection<? extends BayesNetVar> getVariables()
Description copied from interface: Query
Returns a collection of (basic or derived) random variables such that the result of this query depends only on the posterior joint distribution for these variables.


checkTypesAndScope

public boolean checkTypesAndScope(Model model)
Description copied from interface: Query
Returns true if this query satisfies type and scope constraints. If there is a type or scope error, prints a message to standard error and returns false.


compile

public int compile()
Compiles the underlying ArgSpec, and initializes the variable corresponding to this query.


updateStats

public void updateStats(PartialWorld world,
                        double weight)
Description copied from interface: Query
Updates the within-run statistics for this query to reflect the given world sampled with the given weight. The world must be complete enough to define values for all the variables returned by getVariables.

The effects of calling both updateStats and setPosterior in the same run are not defined.


setPosterior

public void setPosterior(ve.Factor posterior)
Description copied from class: AbstractQuery
Throws an UnsupportedOperationException.

Specified by:
setPosterior in interface Query
Overrides:
setPosterior in class AbstractQuery
Parameters:
posterior - factor whose set of variables is the same as the collection returned by getVariables, and whose entries sum to 1

zeroOut

public void zeroOut()
Description copied from interface: Query
Ends the current run, records across-run statistics for it, and clears the within-run statistics.


printVarianceResults

public void printVarianceResults(java.io.PrintStream s)
Description copied from interface: Query
Prints across-run statistics.


getHistogram

public Histogram getHistogram()

getLocation

public java.lang.Object getLocation()
Description copied from class: AbstractQuery
Returns an object whose toString method yields a description of the location where this query occurred in an input file.

This default implementation returns a string indicating that this query was generated internally, rather than from an input file.

Specified by:
getLocation in interface Query
Overrides:
getLocation in class AbstractQuery

toString

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