ve
Class FactorStore

java.lang.Object
  |
  +--ve.FactorStore

public class FactorStore
extends java.lang.Object

a place to store factors during computation. This is a naive implementation. A better implementation would do better indexing.


Constructor Summary
FactorStore()
          generate an empty store.
FactorStore(Factor[] initialFactors, int numFactors, Variable[] initialVariables, int numVars)
          generate a containing the given initial factors and initial variables.
 
Method Summary
 void add(Factor newFactor)
          add a new element to the store.
 FactorIterator emunFactors()
          Returns an iterator over the the remaining factors.
 FactorIterator emunFactorsContaining(Variable var)
          Returns an iterator over the factors that contain the variable var.
 void observe(Variable[] observedVars, int[] observedVals)
          update the factors to make the appropriate observations.
 void removeIrrelevantVariables()
          removes the irrelevant variables (and their associated factors) from the store.
 void setQuery(Variable[] queried)
          sets some variables as the query variable.
 VariableIterator variableSelector(java.lang.String how)
          returns an iterator over the variables that need to be eliminated.
 VariableIterator variableSelector(Variable[] eo)
          returns an iterator over the variables that need to be eliminated for the given elimination ordering.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FactorStore

public FactorStore()
generate an empty store.

FactorStore

public FactorStore(Factor[] initialFactors,
                   int numFactors,
                   Variable[] initialVariables,
                   int numVars)
generate a containing the given initial factors and initial variables.
Method Detail

observe

public void observe(Variable[] observedVars,
                    int[] observedVals)
update the factors to make the appropriate observations. This assumes that the observed variables are sorted, and we only observe variables that are in the store.

setQuery

public void setQuery(Variable[] queried)
sets some variables as the query variable. This assumes that the query variables are in the canonical order, and are all appear in the store.

removeIrrelevantVariables

public void removeIrrelevantVariables()
removes the irrelevant variables (and their associated factors) from the store.

add

public void add(Factor newFactor)
add a new element to the store.

variableSelector

public VariableIterator variableSelector(java.lang.String how)
returns an iterator over the variables that need to be eliminated. This code is based on the Iterator code in java.util.AbstractList. This may destroy the set of variables (and the factors).
Parameters:
how - one of "sequential" or "random"

variableSelector

public VariableIterator variableSelector(Variable[] eo)
returns an iterator over the variables that need to be eliminated for the given elimination ordering.
Parameters:
eo - an elimination ordering

emunFactorsContaining

public FactorIterator emunFactorsContaining(Variable var)
Returns an iterator over the factors that contain the variable var. Note that we remove the factors as we access them. We should really index properly so that this can be done in time proportional to the number of factors that contain the variable, not linear in the total number of factors.

emunFactors

public FactorIterator emunFactors()
Returns an iterator over the the remaining factors.