edu.ksu.cis.bnj.bbn.inference.approximate.sampling
Class AIS

java.lang.Object
  extended byedu.ksu.cis.bnj.bbn.inference.Inference
      extended byedu.ksu.cis.bnj.bbn.inference.ApproximateInference
          extended byedu.ksu.cis.bnj.bbn.inference.approximate.sampling.MCMC
              extended byedu.ksu.cis.bnj.bbn.inference.approximate.sampling.AIS
All Implemented Interfaces:
DataGenerator, Optionable, java.lang.Runnable

public class AIS
extends MCMC
implements DataGenerator, java.lang.Runnable

Adaptive importance sampling gets samples by instantiating each node of the network (using the likelihood of each state given the state of the parent nodes) in topological order, using the probabilities in the importance function (which are initially set equal to the conditional probability tables). In this sampling process, evidence nodes are automatically instantiated to the value given in the evidence file. After 10% of the samples have been taken, the approximate probabilities for those samples are used to update the importance function. This allows the probabilities for each node to change to reflect the values of the evidence nodes.

Author:
Julie Thornton, Roby Joehanes

Field Summary
static int defaultUpdateIteration
           
static double defaultWeight
           
static java.lang.String ln
           
protected  java.util.HashSet needUpdated
           
protected  int updateIteration
           
protected  double weight
           
 
Fields inherited from class edu.ksu.cis.bnj.bbn.inference.approximate.sampling.MCMC
abort, abortTimer, defaultMaxIteration, generateSamples, listeners, maxIteration, NO_TIME_LIMIT, OPT_GENERATE_DATA, OPT_MAX_ITERATION, OPT_RUNNING_TIME_LIMIT, OPT_USE_MARKOV_BLANKET, random, runningTimeLimit, tuples, useMarkovBlanketScore
 
Fields inherited from class edu.ksu.cis.bnj.bbn.inference.ApproximateInference
rmseWriter
 
Fields inherited from class edu.ksu.cis.bnj.bbn.inference.Inference
graph, inferenceClassName, MAP, MARGINALS, marginalsResult, MPE, OPT_RUN_TYPE, options
 
Fields inherited from interface edu.ksu.cis.kdd.util.gui.Optionable
OPT_OUTPUT_FILE
 
Constructor Summary
AIS()
           
AIS(BBNGraph g)
          The constructor for AIS, which initializes the graph on which to run inference.
AIS(BBNGraph g, int i)
          An alternate constructor for AIS, which intializes the graph on which to run inference and the number of samples to use
 
Method Summary
 BBNCPF[] getICPT()
          This method is used in the bridge between AIS and BCC.
 InferenceResult getMarginals()
          Computes the AIS algorithm and calculates the posterior probabilities of the network
 java.lang.String getName()
          Gets the name of the inference algorithm
 BBNNode[] getNodes()
          This method returns the array of nodes in the network
 int getUpdateIteration()
          Gets the number of samples taken before updating the ICPTs
 double getWeight()
          Returns the weight of samples
static void main(java.lang.String[] args)
           
 void run()
          Runs the AIS algorithm without printing out the generated samples.
 void setUpdateIteration(int updateIteration)
          Sets the updateIteration
 void setWeight(double weight)
          Sets the weight.
 
Methods inherited from class edu.ksu.cis.bnj.bbn.inference.approximate.sampling.MCMC
abort, addListener, cancelAbortTimer, generateData, generateData, getData, getDefaultOptions, getMarkovBlanketScore, getMaxIteration, getOptionsDialog, getRunningTimeLimit, isUseMarkovBlanketScore, removeListener, sendEvent, setAbortTimer, setMaxIteration, setRunningTimeLimit, setUseMarkovBlanketScore
 
Methods inherited from class edu.ksu.cis.bnj.bbn.inference.ApproximateInference
computeRMSE, getRMSEWriter, setRMSEfile
 
Methods inherited from class edu.ksu.cis.bnj.bbn.inference.Inference
execute, getCurrentOptions, getGraph, getMAP, getMarginalsResult, getMPE, getOutputFile, getRunType, load, setGraph, setOption, setOptions, setOutputFile, setRunType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.ksu.cis.bnj.bbn.datagen.DataGenerator
generateData
 

Field Detail

defaultUpdateIteration

public static final int defaultUpdateIteration
See Also:
Constant Field Values

defaultWeight

public static final double defaultWeight
See Also:
Constant Field Values

ln

public static final java.lang.String ln

updateIteration

protected int updateIteration

weight

protected double weight

needUpdated

protected java.util.HashSet needUpdated
Constructor Detail

AIS

public AIS()

AIS

public AIS(BBNGraph g)
The constructor for AIS, which initializes the graph on which to run inference.

Parameters:
g - - the BBNGraph on which to run inference

AIS

public AIS(BBNGraph g,
           int i)
An alternate constructor for AIS, which intializes the graph on which to run inference and the number of samples to use

Parameters:
g - - the BBNGraph on which to run inference
i - - the number of samples to generate during inference
Method Detail

getName

public java.lang.String getName()
Gets the name of the inference algorithm

Specified by:
getName in interface DataGenerator
Specified by:
getName in class Inference
Returns:
String - the name of the inference algorithm (AIS)

getMarginals

public InferenceResult getMarginals()
Computes the AIS algorithm and calculates the posterior probabilities of the network

Specified by:
getMarginals in class Inference
Returns:
InferenceResult - contains the posterior probs
See Also:
edu.ksu.cis.bnj.bbn.inference.approximate.sampling.MCMC#getMarginalsImpl(boolean)

getICPT

public BBNCPF[] getICPT()
This method is used in the bridge between AIS and BCC. It returns the current array of ICPT values

Returns:
BBNCPF[] - the array of the ICPT values

getNodes

public BBNNode[] getNodes()
This method returns the array of nodes in the network

Returns:
- the array of nodes in the network

run

public void run()
Runs the AIS algorithm without printing out the generated samples.

Specified by:
run in interface java.lang.Runnable
See Also:
Runnable.run()

getUpdateIteration

public int getUpdateIteration()
Gets the number of samples taken before updating the ICPTs

Returns:
int - the ICPT update interval

getWeight

public double getWeight()
Returns the weight of samples

Returns:
int - the sample weight

setUpdateIteration

public void setUpdateIteration(int updateIteration)
Sets the updateIteration

Parameters:
updateIteration - - the updateIteration to set

setWeight

public void setWeight(double weight)
Sets the weight.

Parameters:
weight - - the weight to set

main

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