blog
Class PartialWorldDiff

java.lang.Object
  extended by blog.AbstractPartialWorld
      extended by blog.PartialWorldDiff
All Implemented Interfaces:
PartialWorld

public class PartialWorldDiff
extends AbstractPartialWorld

Represents a PartialWorld as a set of differences relative to an underlying "saved" PartialWorld. Note that the a PartialWorldDiff uses separate common ground identifiers than its underlying world, although the asserted identifiers in the underlying world are still asserted in the PartialWorldDiff unless they are removed with removeIdentifier.


Nested Class Summary
 
Nested classes/interfaces inherited from interface blog.PartialWorld
PartialWorld.EmptyPartialWorld
 
Field Summary
 
Fields inherited from class blog.AbstractPartialWorld
assertedIdToPOPApp, basicVarToValue, bayesNet, commIdToPOPApp, derivedVarToValue, dirtyVars, idTypes, listeners, objToUsesAsArg, objToUsesAsValue, popAppToAssertedIds, popAppToCommIds, varToLogProb, varToUninstParent
 
Fields inherited from interface blog.PartialWorld
EMPTY_INST, UNDET
 
Constructor Summary
PartialWorldDiff(PartialWorld underlying)
          Creates a new PartialWorldDiff with the given underlying world.
PartialWorldDiff(PartialWorld underlying, PartialWorld toCopy)
          Creates a new PartialWorldDiff whose underlying world is underlying, and whose current version is set equal to toCopy.
 
Method Summary
 void addDiffListener(WorldDiffListener listener)
          Adds the given object to the list of listeners that will be notified when this PartialWorldDiff is saved or reverted.
 java.util.Set getChangedVars()
          Returns the set of variables that have different values in the current world than they do in the saved world.
 java.util.Set getIdsWithChangedPOPApps()
          Returns the set of object identifiers that are asserted in either this world or the saved world, and that satisfy a different POP application in this world than in the saved world.
 java.util.Set getNewlyBarrenVars()
          Returns the set of variables that are barren in this world but either are not in the graph or are not barren in the saved world.
 java.util.Set getNewlyFloatingIds()
          Returns the set of identifiers that are floating in this world and not the saved world.
 java.util.Set getNewlyOverloadedNumberVars()
          Returns the set of number variables that are overloaded in this world but not the saved world.
 java.util.Set getObjsWithChangedUsesAsValue()
          Returns the set of objects that serve as values for a different set of basic RVs in this world than they do in the saved world.
 java.util.Set getPOPAppsWithChangedIds()
          Returns the set of POP applications whose set of asserted identifiers is different in this world from in the saved world.
 PartialWorld getSaved()
          Returns the saved version of this world.
 java.util.Set getVarsWithChangedMultipliers()
          Returns the set of number variables that yield different probability multipliers in this world than they do in the saved world.
 java.util.Set getVarsWithChangedProbs()
          Returns the Set of BayesNetVar objects V such that the probability P(V | parents(V)) is not the same in this world as in the saved world.
 void removeDiffListener(WorldDiffListener listener)
          Removes the given object from the list of listeners that will be notified when this PartialWorldDiff is saved or reverted.
 void revert()
          Changes this world to equal the saved version.
 void save()
          Changes the saved version of this world to equal the current version.
 
Methods inherited from class blog.AbstractPartialWorld
addDerivedVar, addIdentifierForPOPApp, addListener, assertedIdToPOPAppMap, assertIdentifier, assertIdentifier, basicVarToValueMap, cloneFields, derivedVarToValueMap, getAssertedIdentifiers, getAssertedIdsForPOPApp, getBayesNet, getDerivedVars, getIdTypes, getInstantiatedVars, getInverseTuples, getLogProbOfValue, getPOPAppSatisfied, getProbOfValue, getSatisfiers, getValue, getVarsWithArg, getVarsWithValue, isOverloaded, objToUsesAsArgMap, objToUsesAsValueMap, popAppToAssertedIdsMap, print, removeDerivedVar, removeIdentifier, removeListener, setValue, toString, truncateList, truncateNumberList, updateBayesNet, updateParentsAndProbs, varToLogProbMap, varToUninstParentMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PartialWorldDiff

public PartialWorldDiff(PartialWorld underlying)
Creates a new PartialWorldDiff with the given underlying world. This world uses object identifiers for the same types as the underlying world does.


PartialWorldDiff

public PartialWorldDiff(PartialWorld underlying,
                        PartialWorld toCopy)
Creates a new PartialWorldDiff whose underlying world is underlying, and whose current version is set equal to toCopy.

Method Detail

getSaved

public PartialWorld getSaved()
Returns the saved version of this world. The returned PartialWorld object is updated as new versions are saved.


save

public void save()
Changes the saved version of this world to equal the current version.


revert

public void revert()
Changes this world to equal the saved version. Warning: WorldListener objects will not be notified of changes to the values of basic variables made by this method.


getChangedVars

public java.util.Set getChangedVars()
Returns the set of variables that have different values in the current world than they do in the saved world. This includes variables that are instantiated in this world and not the saved world, or vice versa.

Returns:
unmodifiable Set of BasicVar

getObjsWithChangedUsesAsValue

public java.util.Set getObjsWithChangedUsesAsValue()
Returns the set of objects that serve as values for a different set of basic RVs in this world than they do in the saved world. This may include objects that exist in this world but not the saved world, or vice versa.


getIdsWithChangedPOPApps

public java.util.Set getIdsWithChangedPOPApps()
Returns the set of object identifiers that are asserted in either this world or the saved world, and that satisfy a different POP application in this world than in the saved world. This includes object identifiers that are asserted in this world and not the saved world, or vice versa.


getPOPAppsWithChangedIds

public java.util.Set getPOPAppsWithChangedIds()
Returns the set of POP applications whose set of asserted identifiers is different in this world from in the saved world.


getVarsWithChangedProbs

public java.util.Set getVarsWithChangedProbs()
Returns the Set of BayesNetVar objects V such that the probability P(V | parents(V)) is not the same in this world as in the saved world. This may be because the value of V has changed or because the values of some of V's parents have changed. The returned set also includes any DerivedVars whose value has changed.

Returns:
unmodifiable Set of BayesNetVar

getNewlyBarrenVars

public java.util.Set getNewlyBarrenVars()
Returns the set of variables that are barren in this world but either are not in the graph or are not barren in the saved world. A barren variable is one with no children.

Returns:
unmodifiable Set of BayesNetVar

getNewlyFloatingIds

public java.util.Set getNewlyFloatingIds()
Returns the set of identifiers that are floating in this world and not the saved world. An identifier is floating if it is used as an argument of some basic variable, but is not the value of any basic variable.

Returns:
unmodifiable Set of ObjectIdentifier

getNewlyOverloadedNumberVars

public java.util.Set getNewlyOverloadedNumberVars()
Returns the set of number variables that are overloaded in this world but not the saved world. A number variable is overloaded if the number of identifiers asserted to satisfy it is greater than its value, or it is not instantiated and one or more identifiers are still asserted to satisfy it.

Returns:
unmodifiable Set of NumberVar

getVarsWithChangedMultipliers

public java.util.Set getVarsWithChangedMultipliers()
Returns the set of number variables that yield different probability multipliers in this world than they do in the saved world. These are the number variables that have different values or different numbers of asserted identifiers in this world and the saved world, and have at least one asserted identifier in this world or the saved world.

Returns:
unmodifiable Set of NumberVar

addDiffListener

public void addDiffListener(WorldDiffListener listener)
Adds the given object to the list of listeners that will be notified when this PartialWorldDiff is saved or reverted.


removeDiffListener

public void removeDiffListener(WorldDiffListener listener)
Removes the given object from the list of listeners that will be notified when this PartialWorldDiff is saved or reverted.