edu.ucla.belief.recursiveconditioning
Class RCDgraph

Object
  extended by RC
      extended by RCDgraph
All Implemented Interfaces:
KnowledgeBase.KnowledgeBaseListener

public final class RCDgraph
extends RC

This class represents "compiled" dgraph objects used in recursive conditioning (it is a set of dtree objects which can share structure).

Author:
David Allen

Nested Class Summary
 
Nested classes/interfaces inherited from class RC
RC.RCCounters, RC.RCCreationException, RC.RCCreationParams, RC.RCStats, RC.RCStats_All, RC.RCStats_Pe, RC.RecCondThreadListener
 
Field Summary
 
Fields inherited from class RC
allowKB, counters, DEBUG_RC_CALC, DEBUG_RC_EVID, DOUBLE_OUTOFMEMORY, outputConsole, scalar, STR_EXCEPTION_EVIDENCE, STR_OUTOFMEMORY_MSG, STR_STACKOVERFLOW_MSG, TODO_REMOVE_DO_EXTRA_LOOKAHEAD, TODO_REMOVE_DO_INDEX_CACHING_DURING_CREATION, TODO_REMOVE_DO_LEAF_CACHING_DURING_CREATION, TODO_REMOVE_DO_LOOKAHEAD_LOWERBOUND, TODO_REMOVE_DO_PROP_UP, TODO_REMOVE_REVERSE_ORDER, vars
 
Constructor Summary
RCDgraph(RC.RCCreationParams params)
          Warning: Using this constructor will not create the complete structure.
RCDgraph(RC.RCCreationParams params, CachingScheme cs, CachingScheme.RCCreateListener listnr, DecompositionStructureUtils.ParamsGraph crm_par)
          Creates a new RCDgraph based on the parameters.
 
Method Summary
static Thread allocateRCDgraphInThread(RCDgraph dg, CachingScheme cs, CachingScheme.RCCreateListener listnr, double seed_bestCost, Map seed_cf)
           
 boolean canComputeFamilyMarginals()
           
static Thread createRCDgraphInThread(RC.RCCreationParams params, CachingScheme cs, CachingScheme.RCCreateListener listnr, DecompositionStructureUtils.ParamsGraph crm_par)
          This will create a thread in which an RCDgraph will be created (by using the listnr parameter, the search for CacheSchemes can be monitored and stopped which will return the best result found so far (if the cachingScheme supports it).
 Table familyJoint(FiniteVariable var)
           
 RCNode getAnyRoot()
           
 RCIterator getIteratorRoots()
           
 RCIteratorTraversal getIteratorTraversal()
           
 RCIterator getIteratorTree()
          Iterator only over the first root
static String getStaticTagName()
           
 String getTagName()
           
 Table joint(FiniteVariable var)
           
 double[] recCond_All()
          Run Recursive conditioning P(e) for each root node (special for testing & output of timing/memory...).
 double[] recCond_All(boolean runAllRoots, boolean runWithKB, boolean runNoKB)
          Run Recursive conditioning P(e) for each root node.
 void recCond_PreCompute()
          Run RC for each root node to "precompute" the marginals.
 void reduceToOnlyMarginals(Collection varsOfInterest)
          Reduce this graph to one which (possibly) has fewer roots, but can only compute variable marginals instead of being able to compute family marginals.
 void setRoots(Collection rts, boolean callInit, Map varToRoot, boolean canComputeFamilyMarginals)
           
 Map varToRoot()
           
 
Methods inherited from class RC
allContexts, allContextsMinusLeafs, allocRCCaches, allocRCMPE3Caches, allocRCMPE4Caches, allocRCMPECaches, assertLearnedPositive, assertUnLearnedPositive, clearKB, collOfFinVarsToStateSpace, createKB, generateNumParents, getCFMap, getIterator, getIteratorParentChild, getRoots, getStatistics, getStatistics, getThreadRunning, getVars, getVars, isRunning, kbCallAssertOnVar, kbDontCallAssertOnVar, knowledgeBase, limitedContexts, numCacheEntries_MPE, numRoots, observe, parentChildOrdering, pauseRecCondAsThread, recCond_MPE, recCond_MPE3, recCond_MPE4, recCond_MPEAsThread, recCond_Pe_Scaled, recCond_Pe_ScaledAsThread, recCond_Pe, recCond_PeAsThread, resetEvidence, resetRC, resetStatistics, resumeKB, resumeRecCondAsThread, reSynchEvidWithBN, root, setCPT, setInst, statsAll, statsPe, stopAndWaitRecCondAsThread, suspendKB, toRealPr, toRealPr, unobserve, useKB, useKBflag
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RCDgraph

public RCDgraph(RC.RCCreationParams params)
Warning: Using this constructor will not create the complete structure. You must eventually call setRoots to finish creating and initializing it.


RCDgraph

public RCDgraph(RC.RCCreationParams params,
                CachingScheme cs,
                CachingScheme.RCCreateListener listnr,
                DecompositionStructureUtils.ParamsGraph crm_par)
Creates a new RCDgraph based on the parameters.

Parameters:
bn - A valid BeliefNetwork to use.
cs - A valid CachingScheme to use.
listnr - A Listener or else null.
scalar - Usually 1.0, but for genetics can scale it (slowing down computations).
useKB - Uses UnitResolution in a KnowledgeBase during computations.
Throws:
RCCreationException - if could not create a RCDgraph.
Method Detail

setRoots

public void setRoots(Collection rts,
                     boolean callInit,
                     Map varToRoot,
                     boolean canComputeFamilyMarginals)

allocateRCDgraphInThread

public static Thread allocateRCDgraphInThread(RCDgraph dg,
                                              CachingScheme cs,
                                              CachingScheme.RCCreateListener listnr,
                                              double seed_bestCost,
                                              Map seed_cf)

createRCDgraphInThread

public static Thread createRCDgraphInThread(RC.RCCreationParams params,
                                            CachingScheme cs,
                                            CachingScheme.RCCreateListener listnr,
                                            DecompositionStructureUtils.ParamsGraph crm_par)
This will create a thread in which an RCDgraph will be created (by using the listnr parameter, the search for CacheSchemes can be monitored and stopped which will return the best result found so far (if the cachingScheme supports it).

It catches RCCreationException and will call rcCreateError() ------rcCreateDone(null) if that happens.


canComputeFamilyMarginals

public boolean canComputeFamilyMarginals()
Overrides:
canComputeFamilyMarginals in class RC

getIteratorRoots

public RCIterator getIteratorRoots()
Specified by:
getIteratorRoots in class RC

getIteratorTree

public RCIterator getIteratorTree()
Iterator only over the first root

Specified by:
getIteratorTree in class RC

getIteratorTraversal

public RCIteratorTraversal getIteratorTraversal()
Specified by:
getIteratorTraversal in class RC

getAnyRoot

public RCNode getAnyRoot()
Specified by:
getAnyRoot in class RC

varToRoot

public Map varToRoot()
Overrides:
varToRoot in class RC

reduceToOnlyMarginals

public void reduceToOnlyMarginals(Collection varsOfInterest)
Reduce this graph to one which (possibly) has fewer roots, but can only compute variable marginals instead of being able to compute family marginals. Cannot eliminate root[0] if it contains the MPE information.


recCond_PreCompute

public void recCond_PreCompute()
Description copied from class: RC
Run RC for each root node to "precompute" the marginals.

This is meant mostly for dgraphs, where the marginal is saved in the root. For a dtree, it will just fill up the caches, but not at the root node.

Note: It is possible for the returned value to be NaN if the network contains that in a cpt.

Specified by:
recCond_PreCompute in class RC

recCond_All

public double[] recCond_All()
Description copied from class: RC
Run Recursive conditioning P(e) for each root node (special for testing & output of timing/memory...).

Note: It is possible for the returned value to be NaN if the network contains that in a cpt.

Specified by:
recCond_All in class RC

recCond_All

public double[] recCond_All(boolean runAllRoots,
                            boolean runWithKB,
                            boolean runNoKB)
Run Recursive conditioning P(e) for each root node.

Note: It is possible for the returned value to be NaN if the network contains that in a cpt.


joint

public Table joint(FiniteVariable var)

familyJoint

public Table familyJoint(FiniteVariable var)

getTagName

public String getTagName()
Specified by:
getTagName in class RC

getStaticTagName

public static String getStaticTagName()


Copyright 2010 UCLA Automated Reasoning Group