ve
Class Factor

java.lang.Object
  |
  +--ve.Factor
Direct Known Subclasses:
FactorAssign, FactorDeterministic, FactorExpand, FactorNormalise, FactorObserved, FactorPlus, FactorStored, FactorStoredPretend, FactorTimes, FactorUniform

public abstract class Factor
extends java.lang.Object

A factor is a table that given a tuple of values returns a value. This is an abstract class that can be instantiated in many ways, for example the FactorTimes factor that is the product of other factors.


Field Summary
static int BY_ASSIGN
           
static int BY_CPT
          some constants so it can remember how it was created.
static int BY_DETERMINISTIC
           
static int BY_EXPANDING
           
static int BY_GENRULE
           
static int BY_MAXIMIZING
           
static int BY_MULTIPLYING
           
static int BY_NORMALIZING
           
static int BY_OBSERVED
           
static int BY_PLUS
           
static int BY_REORDERING
           
static int BY_SAVEIT
           
static int BY_SUM_OUT
           
static int BY_UNIFORM
           
static int BY_UPDATABLE
           
static int BY_V_ELIM
           
private  int howCreatedVal
           
private static boolean savingForTracing
           
private  int thesize
          the size of the factor table.
private  Variable[] variables
          variables is the tuple of variables, in order.
 
Constructor Summary
Factor(Variable[] vars, int how)
          constructs a factor for the variables given.
 
Method Summary
 boolean allOnes()
          Is true if the factor consists entirely of ones.
 boolean contains(Variable v)
          returns true if the factor contains variable v.
 void display()
          displays the resultant factor.
 java.lang.String getName()
          returns string the variables this is a factor on.
 boolean getSavingForTracing()
          returns true if the intermediate Factors are being saved to allow for tracing of how a value was computed.
 Variable[] getVariables()
          returns the tuple of variables, in order.
 int howCreated()
          returns the integer representing how it was created
 boolean isRedundant(Variable var)
          is true if the variable is redundant in the factor.
 boolean isRedundant(Variable var, double threshold)
          is true if the variable is redundant in the factor within a threshold.
abstract  EltsIterator iterator()
          Returns an iterator over the values of the factor.
 void print()
          prints the Factor in a table form.
 void print(java.lang.String indent)
          prints the Factor in a table form, with a string that is printed at the start of each line.
 void printVariables()
          prints the variables
 void setSavingForTracing(boolean val)
          sets the property that the intermediate Factors are being saved to allow for tracing of how a value was computed.
 int size()
          returns the size of a factor table.
 java.lang.String toString()
          returns a string representation of the Factor.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

BY_CPT

public static final int BY_CPT
some constants so it can remember how it was created.

BY_V_ELIM

public static final int BY_V_ELIM

BY_OBSERVED

public static final int BY_OBSERVED

BY_SUM_OUT

public static final int BY_SUM_OUT

BY_MULTIPLYING

public static final int BY_MULTIPLYING

BY_ASSIGN

public static final int BY_ASSIGN

BY_EXPANDING

public static final int BY_EXPANDING

BY_MAXIMIZING

public static final int BY_MAXIMIZING

BY_NORMALIZING

public static final int BY_NORMALIZING

BY_PLUS

public static final int BY_PLUS

BY_REORDERING

public static final int BY_REORDERING

BY_SAVEIT

public static final int BY_SAVEIT

BY_UPDATABLE

public static final int BY_UPDATABLE

BY_UNIFORM

public static final int BY_UNIFORM

BY_GENRULE

public static final int BY_GENRULE

BY_DETERMINISTIC

public static final int BY_DETERMINISTIC

howCreatedVal

private int howCreatedVal

savingForTracing

private static boolean savingForTracing

variables

private Variable[] variables
variables is the tuple of variables, in order.

thesize

private int thesize
the size of the factor table.
Constructor Detail

Factor

public Factor(Variable[] vars,
              int how)
constructs a factor for the variables given.
Method Detail

howCreated

public int howCreated()
returns the integer representing how it was created

getSavingForTracing

public boolean getSavingForTracing()
returns true if the intermediate Factors are being saved to allow for tracing of how a value was computed.

setSavingForTracing

public void setSavingForTracing(boolean val)
sets the property that the intermediate Factors are being saved to allow for tracing of how a value was computed. Setting it to true uses more space but allows for tracing; setting it to false allows the intermediate Factors to be garbage collected.

getName

public java.lang.String getName()
returns string the variables this is a factor on.

getVariables

public Variable[] getVariables()
returns the tuple of variables, in order.

iterator

public abstract EltsIterator iterator()
Returns an iterator over the values of the factor.

size

public int size()
returns the size of a factor table.

contains

public boolean contains(Variable v)
returns true if the factor contains variable v. This should probably do a binary search, although hopefully the factors aren't too big!
Parameters:
v - a variables
Returns:
true if v is in the current factor.

toString

public java.lang.String toString()
returns a string representation of the Factor.
Overrides:
toString in class java.lang.Object

printVariables

public void printVariables()
prints the variables

print

public void print()
prints the Factor in a table form.

print

public void print(java.lang.String indent)
prints the Factor in a table form, with a string that is printed at the start of each line.

allOnes

public boolean allOnes()
Is true if the factor consists entirely of ones.

isRedundant

public boolean isRedundant(Variable var)
is true if the variable is redundant in the factor. It is redundant if the function represented by the factor has the same value for all of the values of the other variables.

isRedundant

public boolean isRedundant(Variable var,
                           double threshold)
is true if the variable is redundant in the factor within a threshold. It is redundant if the function represented by the factor has the same value, within the treshold limit for all of the values of the other variables.

display

public void display()
displays the resultant factor.