edu.ucla.belief.rc2.structure
Class RC2Utils

Object
  extended by RC2Utils

public class RC2Utils
extends Object

This class contains utility functions for RC2 objects.

Author:
David Allen

Nested Class Summary
static class RC2Utils.MiscStats
           
 
Method Summary
static Collection addAllNodes(RC2Node rt, Collection ret)
          Add rt and all descendants to ret (stops descending when any node is already in ret.
static Collection calculateCutsetFromChildren(RC2NodeInternal nd, Collection acutset)
          Calculates the cutset of a variable based only on its children.
static double collOfFinVarsToStateSpace(Collection col)
          Will return the state space of all the variables in the collection, and if the collection is empty it will return 1.
static void computeLeafs(RC2Node rt, Collection ret)
          Compute leaf nodes in the subtree rooted at rt (will include rt if it is a leaf node).
static void computeParentsInTree(RC2Node rt, Map ret)
          When finished, ret will include a mapping from all nodes to their parents in the subtree rooted at rt.
static RC2Utils.MiscStats computeStatsDtree(RC2 rc)
           
static void confirmUnitResolutionKB(RC2 rc, BeliefNetwork bn)
          If there is anything that is wrong, this will throw an IllegalStateException.
static void confirmUnitResolutionRSAT(RC2 rc, BeliefNetwork bn)
          If there is anything that is wrong, this will throw an IllegalStateException.
static double expectedRCCalls_All(RC2 rc, Collection nodesCached)
          If nodesCached is null, it will look to the nodes themselves to see if memory has been allocated, however if nodesCached is non-null, it will ignore the RC object and determine the number of calls based on nodesCached.
static double expectedRCCalls_Pe_inclEvid(RC2 rc, Collection nodesCached, Collection evidNodes)
           
static double expectedRCCalls_Pe(RC2 rc, Collection nodesCached)
          If nodesCached is null, it will look to the nodes themselves to see if memory has been allocated, however if nodesCached is non-null, it will ignore the RC object and determine the number of calls based on nodesCached.
static HashSet getSetOfAllCachedNodes(RC2 rc)
           
static Collection getSetOfAllNodes(RC2 rc)
           
static Collection getSetOfAllNonLeafNodes(RC2 rc)
           
static double logsub(double lna, double lnb)
          Compute ln(a-b) from ln(a) and ln(b) using the log sub equation.
static double logsub2(double lna, double lnb)
          Compute ln(a-b) from ln(a) and ln(b) using the log sub equation.
static void printRC2(PrintStream out, RC2 rc)
           
static void printRC2(PrintWriter out, RC2 rc)
           
static void writeDtreeToVCGFile(File outFile, RC2 rc)
           
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

computeParentsInTree

public static final void computeParentsInTree(RC2Node rt,
                                              Map ret)
When finished, ret will include a mapping from all nodes to their parents in the subtree rooted at rt.


computeLeafs

public static final void computeLeafs(RC2Node rt,
                                      Collection ret)
Compute leaf nodes in the subtree rooted at rt (will include rt if it is a leaf node).


addAllNodes

public static final Collection addAllNodes(RC2Node rt,
                                           Collection ret)
Add rt and all descendants to ret (stops descending when any node is already in ret.


calculateCutsetFromChildren

public static final Collection calculateCutsetFromChildren(RC2NodeInternal nd,
                                                           Collection acutset)
Calculates the cutset of a variable based only on its children. To calculate a "local cutset", acutset can be Collections.EMPTY_SET.


collOfFinVarsToStateSpace

public static final double collOfFinVarsToStateSpace(Collection col)
Will return the state space of all the variables in the collection, and if the collection is empty it will return 1.


logsub

public static final double logsub(double lna,
                                  double lnb)
Compute ln(a-b) from ln(a) and ln(b) using the log sub equation. Its possible that lna and/or lnb might be NaN, or pos/neg infin. If lna or lnb are NaN, the result is NaN. If lna=lnb=negInf, then (a=b=0 and ln(0)=negInf) return negInf. If lna=negInf or lnb=negInf return other one (possibly negated). If lna or lnb are posInf, then it is an error.


logsub2

public static final double logsub2(double lna,
                                   double lnb)
Compute ln(a-b) from ln(a) and ln(b) using the log sub equation. Its possible that lna and/or lnb might be NaN, or pos/neg infin. If lna or lnb are NaN, the result is NaN. If lna=lnb=negInf, then (a=b=0 and ln(0)=negInf) return negInf. If lna=negInf or lnb=negInf return other one (possibly negated). If lna or lnb are posInf, then it is an error.


getSetOfAllNodes

public static final Collection getSetOfAllNodes(RC2 rc)

getSetOfAllNonLeafNodes

public static final Collection getSetOfAllNonLeafNodes(RC2 rc)

getSetOfAllCachedNodes

public static final HashSet getSetOfAllCachedNodes(RC2 rc)

expectedRCCalls_All

public static final double expectedRCCalls_All(RC2 rc,
                                               Collection nodesCached)
If nodesCached is null, it will look to the nodes themselves to see if memory has been allocated, however if nodesCached is non-null, it will ignore the RC object and determine the number of calls based on nodesCached. This allows for computations to be determined even on Full Caching without ever allocating any memory.


expectedRCCalls_Pe

public static final double expectedRCCalls_Pe(RC2 rc,
                                              Collection nodesCached)
If nodesCached is null, it will look to the nodes themselves to see if memory has been allocated, however if nodesCached is non-null, it will ignore the RC object and determine the number of calls based on nodesCached. This allows for computations to be determined even on Full Caching without ever allocating any memory.


printRC2

public static final void printRC2(PrintStream out,
                                  RC2 rc)

printRC2

public static final void printRC2(PrintWriter out,
                                  RC2 rc)

writeDtreeToVCGFile

public static final void writeDtreeToVCGFile(File outFile,
                                             RC2 rc)
                                      throws IOException
Throws:
IOException

confirmUnitResolutionRSAT

public static void confirmUnitResolutionRSAT(RC2 rc,
                                             BeliefNetwork bn)
If there is anything that is wrong, this will throw an IllegalStateException.


confirmUnitResolutionKB

public static void confirmUnitResolutionKB(RC2 rc,
                                           BeliefNetwork bn)
If there is anything that is wrong, this will throw an IllegalStateException.


computeStatsDtree

public static RC2Utils.MiscStats computeStatsDtree(RC2 rc)

expectedRCCalls_Pe_inclEvid

public static final double expectedRCCalls_Pe_inclEvid(RC2 rc,
                                                       Collection nodesCached,
                                                       Collection evidNodes)


Copyright 2010 UCLA Automated Reasoning Group