|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object blog.AbstractPartialWorld
public abstract class AbstractPartialWorld
An implementation of the PartialWorld interface that just requires concrete subclasses to initialize some protected variables.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface blog.PartialWorld |
---|
PartialWorld.EmptyPartialWorld |
Field Summary | |
---|---|
protected java.util.Map |
assertedIdToPOPApp
Map from asserted ObjectIdentifiers to the NumberVars that they satisfy. |
protected java.util.Map |
basicVarToValue
Map from instantiated basic variables to their values. |
protected DGraph |
bayesNet
Bayes net containing instantiated basic variables, origin variables, and those derived variables that have been explicitly added. |
protected java.util.Map |
commIdToPOPApp
Map from common ground ObjectIdentifiers (including asserted ones) to the NumberVars that they satisfy. |
protected java.util.Map |
derivedVarToValue
Map from derived variables in the Bayes net to their values. |
protected java.util.Set |
dirtyVars
Variables that have been added or removed, or have had their values changed, since the last call to updateParentsAndProbs. |
protected java.util.Set |
idTypes
|
protected java.util.List |
listeners
|
protected MultiMap |
objToUsesAsArg
Map from objects to the instantiated BasicVars that use them as arguments. |
protected MultiMap |
objToUsesAsValue
Map from objects to the instantiated BasicVars that have them as values. |
protected IndexedMultiMap |
popAppToAssertedIds
Map from NumberVars to IndexedSets of the ObjectIdentifiers that are asserted to satify them. |
protected IndexedMultiMap |
popAppToCommIds
Map from NumberVars to IndexedSets of the common ground ObjectIdentifiers (including asserted ones) that satisfy them. |
protected java.util.Map |
varToLogProb
Map from instantiated VarWithDistrib objects to Double values representing their log probabilities given their parents. |
protected MapWithPreimages |
varToUninstParent
MapWithPreimages from BayesNetVars to their first uninstantiated parents. |
Fields inherited from interface blog.PartialWorld |
---|
EMPTY_INST, UNDET |
Constructor Summary | |
---|---|
AbstractPartialWorld(java.util.Set idTypes)
Creates a new partial world. |
Method Summary | |
---|---|
boolean |
addDerivedVar(DerivedVar var)
Adds the given derived variable to this world's Bayes net, and sets its parents appropriately. |
ObjectIdentifier |
addIdentifierForPOPApp(NumberVar popApp)
Returns a new object identifier that is asserted to satisfy the given POP application in this world, and to be distinct from all other object identifiers in this world's common ground. |
void |
addListener(WorldListener listener)
Adds the given listener to a list of listeners to be notified when changes are made to this partial world. |
java.util.Map |
assertedIdToPOPAppMap()
Map from asserted ObjectIdentifiers to the POP applications (NumberVars) that they satisfy. |
void |
assertIdentifier(ObjectIdentifier id)
Asserts that the given object identifier satisfies the POP application that it satisfies in this world's common ground. |
void |
assertIdentifier(ObjectIdentifier id,
NumberVar newPOPApp)
Asserts that the given object identifier satisfies the given POP application. |
java.util.Map |
basicVarToValueMap()
Map from instantiated BasicVars to their values. |
void |
cloneFields(AbstractPartialWorld newWorld)
Replicates all fields into the fields of newWorld . |
java.util.Map |
derivedVarToValueMap()
Map from DerivedVars that are included in this world's Bayes net to their values. |
java.util.Set |
getAssertedIdentifiers()
Returns the set of object identifiers that are asserted to exist in this partial world. |
IndexedSet |
getAssertedIdsForPOPApp(NumberVar popApp)
Returns the set of object identifiers that are asserted to satisfy the given POP application in this partial world. |
DGraph |
getBayesNet()
Returns a directed graph where the nodes are variables, and there is an edge from variable X to variable Y if Y depends directly on X given the context represented by this partial world. |
java.util.Set |
getDerivedVars()
Returns the set of derived variables that are included in this world's Bayes net. |
java.util.Set |
getIdTypes()
Returns the set of types that are represented with object identifiers in this partial world. |
java.util.Set |
getInstantiatedVars()
Returns an unmodifiable Set representing the set of basic variables that are instantiated in this world. |
java.util.Set |
getInverseTuples(RandomFunction func,
java.lang.Object val)
Returns the set of argument lists that the function func
maps to the value val . |
double |
getLogProbOfValue(BayesNetVar var)
If var is an instantiated basic variable, this
method returns the log probability of var having the
value that it has in this world, given that its parents have
the values specified in this world. |
NumberVar |
getPOPAppSatisfied(java.lang.Object obj)
Returns the NumberVar (i.e., POP and generating objects) such that the given object satisfies that POP applied to those generating objects in this world. |
double |
getProbOfValue(BayesNetVar var)
Uses PartialWorld.getLogProbOfValue(BayesNetVar) in order to return the probability of a value given its parents. |
ObjectSet |
getSatisfiers(NumberVar popApp)
Returns the set of objects that satisfy the given POP application in this world. |
java.lang.Object |
getValue(BayesNetVar var)
Returns the value of the given variable in this partial world, or null if the given variable is an uninstantiated basic variable. |
java.util.Set |
getVarsWithArg(java.lang.Object arg)
Returns the set of instantiated basic variables that have the given object as an argument. |
java.util.Set |
getVarsWithValue(java.lang.Object value)
Returns the set of basic variables that have the given object as their value in this world. |
boolean |
isOverloaded(NumberVar popApp)
Returns true if the given POP application is overloaded: that is, the number of identifiers that are asserted to satisfy it is greater than the value of the corresponding number variable, or some identifiers are asserted to satisfy it and its number variable is not instantiated. |
MultiMap |
objToUsesAsArgMap()
MultiMap from objects to the instantiated BasicVars that have them as arguments. |
MultiMap |
objToUsesAsValueMap()
MultiMap from objects to the instantiated BasicVars that have them as values. |
IndexedMultiMap |
popAppToAssertedIdsMap()
Map from POP applications (NumberVars) to IndexedSets of the ObjectIdentifiers that are asserted to satisfy them. |
void |
print(java.io.PrintStream s)
Prints this partial world to the given stream. |
boolean |
removeDerivedVar(DerivedVar var)
Removes the given derived variable from this world's Bayes net. |
void |
removeIdentifier(ObjectIdentifier id)
Removes the given object identifier from the set of asserted identifiers in this partial world, and from this world's common ground. |
void |
removeListener(WorldListener listener)
Removes the given listener from the list of objects to be notified when changes are made to this partial world. |
void |
setValue(BasicVar var,
java.lang.Object value)
Instantiates the given variable to the given value (replacing any previous value), or uninstantiates the variable if the given value is null. |
java.lang.String |
toString()
|
void |
truncateList(RandomFunction f,
java.lang.Object[] initialArgs,
int len)
Uninstantiates the variables for the values of f on
all tuples of arguments of the form (arg1, ..., argK, i) where
(arg1, ..., argK) are given by initialArgs and
i is greater than or equal to len . |
void |
truncateNumberList(POP pop,
java.lang.Object[] initialArgs,
int len)
Uninstantiates the number variables for pop on
all tuples of arguments of the form (arg1, ..., argK, i) where
(arg1, ..., argK) are given by initialArgs and
i is greater than or equal to len . |
void |
updateBayesNet(DGraph newBayesNet,
MapWithPreimages newVarToUninstParent,
java.util.Map newVarLogProbs,
java.util.Map newDerivedVarValues)
Provides the Bayes net, the mapping from variables to uninstantiated parents, the mapping from basic variables to log probabilities, and the mapping from derived variables to values for this partial world. |
protected void |
updateParentsAndProbs()
Ensure that parent sets, basic variable log probabilities, and derived variable values are all up to date. |
java.util.Map |
varToLogProbMap()
Map from instantiated VarWithDistrib objects to Double values representing their log probabilities given their parents. |
MapWithPreimages |
varToUninstParentMap()
MapWithPreimages from BayesNetVars to their first uninstantiated parents. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.util.Map basicVarToValue
protected MultiMap objToUsesAsValue
protected MultiMap objToUsesAsArg
protected java.util.Map assertedIdToPOPApp
protected IndexedMultiMap popAppToAssertedIds
protected java.util.Map commIdToPOPApp
protected IndexedMultiMap popAppToCommIds
protected DGraph bayesNet
protected MapWithPreimages varToUninstParent
protected java.util.Map varToLogProb
protected java.util.Map derivedVarToValue
protected java.util.Set dirtyVars
protected java.util.List listeners
protected java.util.Set idTypes
Constructor Detail |
---|
public AbstractPartialWorld(java.util.Set idTypes)
idTypes
- Set of Type objectsMethod Detail |
---|
public java.util.Set getInstantiatedVars()
PartialWorld
getInstantiatedVars
in interface PartialWorld
public java.lang.Object getValue(BayesNetVar var)
PartialWorld
getValue
in interface PartialWorld
public void setValue(BasicVar var, java.lang.Object value)
PartialWorld
If the variable is a number variable and the given value is less than its old value, then all variables defined on concrete non-guaranteed objects that no longer exist are uninstantiated. Variables defined on object identifiers that satisfy this number variable are not affected (we don't know which identifiers to remove). We also don't do anything about variables whose values no longer exist.
setValue
in interface PartialWorld
public void truncateList(RandomFunction f, java.lang.Object[] initialArgs, int len)
PartialWorld
f
on
all tuples of arguments of the form (arg1, ..., argK, i) where
(arg1, ..., argK) are given by initialArgs
and
i is greater than or equal to len
. Assumes that in the
current world, there are no instantiated variables beyond the first
uninstantiated variable in this sequence.
truncateList
in interface PartialWorld
public void truncateNumberList(POP pop, java.lang.Object[] initialArgs, int len)
PartialWorld
pop
on
all tuples of arguments of the form (arg1, ..., argK, i) where
(arg1, ..., argK) are given by initialArgs
and
i is greater than or equal to len
. Assumes that in the
current world, there are no instantiated variables beyond the first
uninstantiated variable in this sequence.
truncateNumberList
in interface PartialWorld
public java.util.Set getVarsWithValue(java.lang.Object value)
PartialWorld
getVarsWithValue
in interface PartialWorld
public java.util.Set getVarsWithArg(java.lang.Object arg)
PartialWorld
getVarsWithArg
in interface PartialWorld
public java.util.Set getInverseTuples(RandomFunction func, java.lang.Object val)
PartialWorld
func
maps to the value val
. This method requires
func
to be a random function, since the values of
non-random and origin functions may not be represented explicitly.
getInverseTuples
in interface PartialWorld
public double getLogProbOfValue(BayesNetVar var)
PartialWorld
var
is an instantiated basic variable, this
method returns the log probability of var
having the
value that it has in this world, given that its parents have
the values specified in this world. Otherwise returns 0 (log of 1),
because uninstantiated variables and non-basic variables do not
contribute to the joint distribution. This method yields a
fatal error if the world is not complete enough to determine
the given variable's distribution.
getLogProbOfValue
in interface PartialWorld
public double getProbOfValue(BayesNetVar var)
PartialWorld
PartialWorld.getLogProbOfValue(BayesNetVar)
in order to return the probability of a value given its parents.
getProbOfValue
in interface PartialWorld
public ObjectSet getSatisfiers(NumberVar popApp)
PartialWorld
The set returned by this method will remain correct if new basic random variables are instantiated or new object identifiers are added (to this world's common ground or its set of asserted identifiers). The set may not remain correct if already-instantiated random variables are changed, or if object identifiers are moved from one number variable to another or removed from the world.
getSatisfiers
in interface PartialWorld
public NumberVar getPOPAppSatisfied(java.lang.Object obj)
PartialWorld
obj
is an object identifier that is not valid in this
world).
getPOPAppSatisfied
in interface PartialWorld
public java.util.Set getIdTypes()
PartialWorld
getIdTypes
in interface PartialWorld
public java.util.Set getAssertedIdentifiers()
PartialWorld
getAssertedIdentifiers
in interface PartialWorld
public IndexedSet getAssertedIdsForPOPApp(NumberVar popApp)
PartialWorld
getAssertedIdsForPOPApp
in interface PartialWorld
public void assertIdentifier(ObjectIdentifier id, NumberVar newPOPApp)
PartialWorld
assertIdentifier
in interface PartialWorld
public void assertIdentifier(ObjectIdentifier id)
PartialWorld
id
to the set of
asserted identifiers in this world.
assertIdentifier
in interface PartialWorld
public ObjectIdentifier addIdentifierForPOPApp(NumberVar popApp)
PartialWorld
addIdentifierForPOPApp
in interface PartialWorld
public void removeIdentifier(ObjectIdentifier id)
PartialWorld
removeIdentifier
in interface PartialWorld
public boolean isOverloaded(NumberVar popApp)
PartialWorld
isOverloaded
in interface PartialWorld
public DGraph getBayesNet()
PartialWorld
If a variable var
is not supported in this
world, then its parents in the returned graph are those
variables accessed by var.getDistrib
(or
var.getValue
if var
is a derived
variable) before the first uninstantiated variable.
getBayesNet
in interface PartialWorld
public void updateBayesNet(DGraph newBayesNet, MapWithPreimages newVarToUninstParent, java.util.Map newVarLogProbs, java.util.Map newDerivedVarValues)
PartialWorld
updateBayesNet
in interface PartialWorld
newBayesNet
- DGraph whose nodes are BayesNetVar objectsnewVarToUninstParent
- Map from BayesNetVar to BasicVarnewVarLogProbs
- Map from BasicVar to DoublenewDerivedVarValues
- Map from DerivedVar to Objectpublic java.util.Set getDerivedVars()
PartialWorld
getDerivedVars
in interface PartialWorld
public boolean addDerivedVar(DerivedVar var)
PartialWorld
addDerivedVar
in interface PartialWorld
public boolean removeDerivedVar(DerivedVar var)
PartialWorld
removeDerivedVar
in interface PartialWorld
public void print(java.io.PrintStream s)
PartialWorld
print
in interface PartialWorld
public java.util.Map basicVarToValueMap()
PartialWorld
basicVarToValueMap
in interface PartialWorld
public MultiMap objToUsesAsValueMap()
PartialWorld
objToUsesAsValueMap
in interface PartialWorld
public MultiMap objToUsesAsArgMap()
PartialWorld
objToUsesAsArgMap
in interface PartialWorld
public java.util.Map assertedIdToPOPAppMap()
PartialWorld
assertedIdToPOPAppMap
in interface PartialWorld
public IndexedMultiMap popAppToAssertedIdsMap()
PartialWorld
popAppToAssertedIdsMap
in interface PartialWorld
public MapWithPreimages varToUninstParentMap()
PartialWorld
varToUninstParentMap
in interface PartialWorld
public java.util.Map varToLogProbMap()
PartialWorld
varToLogProbMap
in interface PartialWorld
public java.util.Map derivedVarToValueMap()
PartialWorld
derivedVarToValueMap
in interface PartialWorld
public void addListener(WorldListener listener)
PartialWorld
addListener
in interface PartialWorld
public void removeListener(WorldListener listener)
PartialWorld
removeListener
in interface PartialWorld
protected void updateParentsAndProbs()
public void cloneFields(AbstractPartialWorld newWorld)
newWorld
.
This is meant to be invoked by clone methods of extending classes,
allowing their writing without access to all, and detailed knowledge
of, AbstractPartialWorld
fields.
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |