edu.ucla.belief.rc2.structure
Class RC2

Object
  extended by RC2

public final class RC2
extends Object

This class represents Dtrees and Dgraphs.

setRoots may only be called once, future calls will cause an exception to be thrown.

Computations may be done by calls to compute_*.

Evidence can be changed through the following functions, however if you are using threads be careful: synchEvidWithBN, observe, unobserve

CPTs can be changed so long as the variables and their indexing remain the same (i.e. the only change allowed is parameter modifications). To do this, change the BeliefNetworks FiniteVariable.CPTShell and then call setCPT().

Author:
David Allen

Nested Class Summary
static interface RC2.CachingScheme
           
static class RC2.ComputationStats
           
static class RC2.RCCreationParams
           
static class RC2.StoredComputationStats
           
 
Field Summary
 KB_SAT kb_sat
           
 KBMap.Mapping map_kb
           
 PrintWriter outputConsole
           
 long rcCallsCounter
           
 double scalar
           
 
Constructor Summary
RC2(RC2.RCCreationParams param)
          An RC2 object should be created before any nodes are created, as it has to be passed into the node constructors.
 
Method Summary
 void close()
          This will clean up all resources used by RC (currently the SAT engine).
 RC2.StoredComputationStats compStats()
           
 Table compute_CutMarginal(int rt)
          If the root rt is a leaf node, it will return null.
 double compute_MPEValue()
          Does not run with scaling enabled.
 Table compute_ParDer(int rt)
           
 double compute_Pe_sat()
           
 double compute_Pe()
          This will return the scaled version if scaling is enabled, the caller is responsible for converting it, as that conversion could cause an underflow to occur.
 void flushCaches()
           
 double getComputationTotalTime_ms()
           
 ArrayList getElimOrder()
           
 int getNumRCNodes_All()
          Can use this and getRCNode_All to iterate through nodes.
 int getNumRCNodes_Pe()
          Can use this and getRCNode_Pe to iterate through nodes.
 RC2Node getPeRootNode()
           
 RC2Node getRCNode_All(int indx)
          Can use this and getNumRCNodes_All to iterate through nodes.
 RC2Node getRCNode_Pe(int indx)
          Can use this and getNumRCNodes_Pe to iterate through nodes.
 RC2Node[] getRootNodes()
           
 void observe(FiniteVariable var, Object value)
           
 void outputInfo(String str)
           
 void prePrepareToStartComputation()
          Attempt to do some preparation steps before computations are actually run.
 void setCachingScheme(RC2.CachingScheme cs)
          This function will set the caching in the RC2 object based on the caching scheme passed in, and will compute the current memory usage and expected RC calls based on the changes.
 void setCPT(FiniteVariable var, boolean resetDeterminism)
          Call this function after updating the CPTShell object for a FiniteVariable, however, RC2 can only handle parameter changes, the variables and their indexing must remain the same.
 void setRoots(RC2Node peNd, RC2Node[] rts, RC2Node[] pds, RC2.CachingScheme cs)
          Will set this objects root(s).
 void synchEvidWithBN()
           
 void unobserve(FiniteVariable var)
           
 List vars()
           
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outputConsole

public PrintWriter outputConsole

rcCallsCounter

public long rcCallsCounter

scalar

public final double scalar

map_kb

public final KBMap.Mapping map_kb

kb_sat

public KB_SAT kb_sat
Constructor Detail

RC2

public RC2(RC2.RCCreationParams param)
An RC2 object should be created before any nodes are created, as it has to be passed into the node constructors. Once the structure is complete, call setRoots once to initialize the RC2 object for computations and evidence.

Method Detail

close

public void close()
This will clean up all resources used by RC (currently the SAT engine). It is okay to call this as many times as you want.

Any future calls using kb_sat after this will cause problems!


setRoots

public void setRoots(RC2Node peNd,
                     RC2Node[] rts,
                     RC2Node[] pds,
                     RC2.CachingScheme cs)
Will set this objects root(s). It may only be called once, any further calls to it will cause an exception to be thrown.

Copies of rts and pds are used by this RC object.

User is responsible for calling the initialize functions on these nodes BEFORE calling this function.

peNd is also allowed to be a member of rts, however it does not have to be.

peNd will be used for Pe, Pe_log, and MPE calculations.


compute_Pe_sat

public double compute_Pe_sat()

compute_Pe

public double compute_Pe()
This will return the scaled version if scaling is enabled, the caller is responsible for converting it, as that conversion could cause an underflow to occur.


compute_MPEValue

public double compute_MPEValue()
Does not run with scaling enabled.


compute_CutMarginal

public Table compute_CutMarginal(int rt)
If the root rt is a leaf node, it will return null. It also cannot be used when the KB is allowed.


compute_ParDer

public Table compute_ParDer(int rt)

prePrepareToStartComputation

public void prePrepareToStartComputation()
Attempt to do some preparation steps before computations are actually run.


setCachingScheme

public void setCachingScheme(RC2.CachingScheme cs)
This function will set the caching in the RC2 object based on the caching scheme passed in, and will compute the current memory usage and expected RC calls based on the changes.


vars

public List vars()

getComputationTotalTime_ms

public double getComputationTotalTime_ms()

getElimOrder

public ArrayList getElimOrder()

getNumRCNodes_All

public int getNumRCNodes_All()
Can use this and getRCNode_All to iterate through nodes.


getRCNode_All

public RC2Node getRCNode_All(int indx)
Can use this and getNumRCNodes_All to iterate through nodes.


getNumRCNodes_Pe

public int getNumRCNodes_Pe()
Can use this and getRCNode_Pe to iterate through nodes.


getRCNode_Pe

public RC2Node getRCNode_Pe(int indx)
Can use this and getNumRCNodes_Pe to iterate through nodes.


getPeRootNode

public RC2Node getPeRootNode()

getRootNodes

public RC2Node[] getRootNodes()

compStats

public RC2.StoredComputationStats compStats()

flushCaches

public void flushCaches()

synchEvidWithBN

public void synchEvidWithBN()

observe

public final void observe(FiniteVariable var,
                          Object value)

unobserve

public final void unobserve(FiniteVariable var)

setCPT

public final void setCPT(FiniteVariable var,
                         boolean resetDeterminism)
Call this function after updating the CPTShell object for a FiniteVariable, however, RC2 can only handle parameter changes, the variables and their indexing must remain the same.


outputInfo

public final void outputInfo(String str)


Copyright 2010 UCLA Automated Reasoning Group