blog
Class Main

java.lang.Object
  extended by blog.Main

public class Main
extends java.lang.Object

Main program for the BLOG (Bayesian Logic) inference engine. Usage:

java blog.Main file1 ... fileN
Each file contains a sequence of BLOG statements. These may be declarations (specifying the model itself), evidence statements, or queries. The convention is to use one file for the model (with the "mblog" suffix), one file for the evidence (with the "eblog" suffix), and one file for the queries (with the "qblog" suffix). The files are loaded in the order specified, so the first file must be a model file. Optional flags:
-r, --randomize
Initialize the random seed based on the clock time. If this flag is not given, the program uses a fixed random seed so its behavior is reproducible. Default: false
-e classname, --engine=classname
Use classname as the inference engine. Default: blog.SamplingEngine
-n num, --num_samples=num
Run the sampling engine for num samples. Default: 10000 samples.
-b num, --burn_in=num
Treat first num samples as burn-in period (don't use them to compute query results). Default: 0.
-s classname --sampler=classname
Use classname to generate each sample. Default: blog.LWSampler (a likelihood weighting sampler)
-p classname, --proposer=classname
Use classname as the proposal distribution for the Metropolis-Hastings sampler. Default: blog.GenericProposer (samples each var given its parents)
-t, num, --num_trials=num
Do num independent runs (trials) of the inference algorithm. Default: 1
--generate
Rather than answering queries, just sample possible worlds from the prior distribution defined by the model, and print them out. Default: false
-k package, --package package
Look in package (e.g., "blog.distrib") when resolving the names of CondProbDistrib and NonRandomFunction classes in the model file. This option can be included several times with different packages; the packages are searched in the order given. The last places searched are the top-level package ("") and finally the default package blog.distrib. Note that you still need to set the Java classpath so that it includes all these packages.
-v, --verbose
Print information about the world generated at each iteration. Off by default (for perfomance reasons, consider leaving this option off).
-g, --debug
Print model, evidence, and queries for debugging. Default: false
-w file-prefix, --write=file-prefix
Write sampling results to file specified by this argument. Use with the -i flag.
-i, --interval
To be used with the -w option, specify the interval at which output is written. Note that if -i and -n are the same, output is written only once, at the last iteration.
-h file-prefix, --histogram_output=file-prefix
Output the histogram of an ArgSpecQuery to a file. The results are taken after the final sample completes.
-P key=value
Include the entry key=value in the properties table that is passed to the inference engine. This feature can be used to set configuration parameters for various inference engines (and the components they use, such as samplers). See the individual inference classes for documentation. Note: The -P option cannot be used to specify values for properties for which there exist special-purpose options, such as --engine or --num_samples.
-x, --extend setup-extender[,key=value,...]
Extend the problem setup (model, evidence and queries) using an object of class setup-extender. This class must implement the SetupExtender interface. The class name can optionally be followed by a series of key=value pairs (each preceded by a comma) that will be passed to the setup extender's constructor in a properties table.


Constructor Summary
Main()
           
 
Method Summary
static java.io.PrintStream filePrintStream(java.lang.String s)
          Returns a PrintStream representing the newly created file, with given pathname s.
static java.lang.String histOut()
           
static void main(java.lang.String[] args)
           
static java.util.List makeReaders(java.util.Collection filenames)
           
static int numSamples()
           
static int numTrials()
           
static int outputInterval()
           
static java.lang.String outputPath()
           
static void printTimes(java.io.PrintStream ps, java.lang.String s, int n)
          Print to the PrintStream ps the String s exactly n times, followed by a newline.
static void setup(Model model, Evidence evidence, java.util.List queries, java.util.Collection readersAndOrigins, java.util.Collection setupExtenders, boolean verbose, boolean parseFromMessage)
          Reads and prepares model, evidence and queries for inference.
static void stringSetup(Model model, Evidence evidence, java.util.List queries, java.lang.String modelString)
          A version of setup(Model, Evidence, List, Collection, Collection, boolean, boolean) receiving a single string, no setup extenders, and not verbose.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Main

public Main()
Method Detail

main

public static void main(java.lang.String[] args)

makeReaders

public static java.util.List makeReaders(java.util.Collection filenames)

printTimes

public static void printTimes(java.io.PrintStream ps,
                              java.lang.String s,
                              int n)
Print to the PrintStream ps the String s exactly n times, followed by a newline.


filePrintStream

public static java.io.PrintStream filePrintStream(java.lang.String s)
Returns a PrintStream representing the newly created file, with given pathname s. Guaranteed not to be null.


setup

public static void setup(Model model,
                         Evidence evidence,
                         java.util.List queries,
                         java.util.Collection readersAndOrigins,
                         java.util.Collection setupExtenders,
                         boolean verbose,
                         boolean parseFromMessage)
Reads and prepares model, evidence and queries for inference.

Parameters:
readersAndOrigins - A list of Object[] of size two, containing a Reader with text to be parsed and origin name (such as file name).
setupExtenders - A collection of SetupExtender(s) to be run.
verbose - Whether the procedure is verbose.
parseFromMessage - Whether to print a message indicating "Parsing from..."

stringSetup

public static void stringSetup(Model model,
                               Evidence evidence,
                               java.util.List queries,
                               java.lang.String modelString)
A version of setup(Model, Evidence, List, Collection, Collection, boolean, boolean) receiving a single string, no setup extenders, and not verbose.


outputPath

public static java.lang.String outputPath()

outputInterval

public static int outputInterval()

numSamples

public static int numSamples()

numTrials

public static int numTrials()

histOut

public static java.lang.String histOut()