|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object blog.DefaultEvalContext
public class DefaultEvalContext
Basic implementation of the EvalContext interface. When the underlying
partial world is not complete enough to support a call to
getValue
or getSatisfiers
, this implementation
either prints an error message and exits the program, or just returns
null. Returning null is the default behavior; the fatal error behavior
can be obtained by constructing a DefaultEvalContext with the
errorIfUndet
flag set to true.
Field Summary | |
---|---|
protected boolean |
errorIfUndet
|
protected PartialWorld |
world
|
Constructor Summary | |
---|---|
DefaultEvalContext(PartialWorld world)
Creates a new evaluation context using the given partial world. |
|
DefaultEvalContext(PartialWorld world,
boolean errorIfUndet)
Creates a new evaluation context using the given partial world. |
Method Summary | |
---|---|
void |
assign(LogicalVar var,
java.lang.Object value)
Assigns the given value to the given logical variable, overwriting any previous value. |
void |
assignTuple(LogicalVar[] vars,
java.lang.Object[] values)
Assigns values to a tuple of logical variables. |
java.lang.String |
getAssignmentStr()
Returns a string describing the assignment of values to variables in this context. |
java.lang.Object |
getLogicalVarValue(LogicalVar var)
Returns the value of the given logical variable in this context, or null if the given logical variable has no assigned value. |
java.util.Set |
getLogicalVarValues()
Returns the set of objects that are the value of some logical variable in this context. |
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. |
ObjectSet |
getSatisfiers(NumberVar popApp)
Returns the set of objects that satisfy the given POP in this world. |
java.lang.Object |
getValue(BasicVar var)
Returns the value of the given basic random variable in this partial world, or null if the given variable is not instantiated. |
protected void |
handleMissingVar(BayesNetVar var)
Handle the situation where an access method needs the value of the given variable, but it is not instantiated. |
java.lang.Boolean |
objectExists(java.lang.Object obj)
Returns Boolean.TRUE if obj exists in all worlds
consistent with this context's partial world. |
void |
popEvaluee()
Pops the top object from the stack of objects being evaluated. |
void |
printEvalTrace(java.io.PrintStream s)
Prints the sequence of objects being evaluated, in the order they were added to the stack, to the given stream. |
void |
pushEvaluee(java.lang.Object evaluee)
Pushes the given object onto the stack of objects being evaluated. |
void |
unassign(LogicalVar var)
Erases any value currently assigned to the given logical variable. |
void |
unassignTuple(LogicalVar[] vars)
Erases any values currently assigned to any of the given logical variables. |
boolean |
usesIdentifiers(Type type)
Returns true if the world that underlies this context uses object identifiers for the given type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected PartialWorld world
protected boolean errorIfUndet
Constructor Detail |
---|
public DefaultEvalContext(PartialWorld world)
public DefaultEvalContext(PartialWorld world, boolean errorIfUndet)
errorIfUndet
flag is true, the access
methods on this instance will print error messages and exit the
program if the world is not complete enough to determine the
correct return value.
Method Detail |
---|
public java.lang.Object getValue(BasicVar var)
EvalContext
getValue
in interface EvalContext
public ObjectSet getSatisfiers(NumberVar popApp)
EvalContext
The set returned by this method will remain correct if new basic random variables are instantiated. It may not remain correct if new identifiers are added or already-instantiated random variables are changed.
getSatisfiers
in interface EvalContext
public NumberVar getPOPAppSatisfied(java.lang.Object obj)
EvalContext
getPOPAppSatisfied
in interface EvalContext
public boolean usesIdentifiers(Type type)
EvalContext
usesIdentifiers
in interface EvalContext
public java.lang.Boolean objectExists(java.lang.Object obj)
EvalContext
obj
exists in all worlds
consistent with this context's partial world. This is true if
obj
is a guaranteed object, a concrete
non-guaranteed object whose number variable is instantiated to
a sufficiently large value, or an object identifier. Returns
Boolean.FALSE if obj
is a concrete non-guaranteed
object whose number variable is instantiated to a value that is
too small. If neither of the above cases holds, then this
method returns null.
objectExists
in interface EvalContext
public java.lang.Object getLogicalVarValue(LogicalVar var)
EvalContext
getLogicalVarValue
in interface EvalContext
public java.util.Set getLogicalVarValues()
EvalContext
getLogicalVarValues
in interface EvalContext
public java.lang.String getAssignmentStr()
EvalContext
getAssignmentStr
in interface EvalContext
public void assign(LogicalVar var, java.lang.Object value)
EvalContext
assign
in interface EvalContext
public void assignTuple(LogicalVar[] vars, java.lang.Object[] values)
EvalContext
assignTuple
in interface EvalContext
vars
- array of LogicalVar objectsvalues
- array of Objects, in one-to-one correspondence with
the elements of vars
, representing values
for those variablespublic void unassign(LogicalVar var)
EvalContext
unassign
in interface EvalContext
public void unassignTuple(LogicalVar[] vars)
EvalContext
unassignTuple
in interface EvalContext
public void pushEvaluee(java.lang.Object evaluee)
pushEvaluee
in interface EvalContext
public void popEvaluee()
popEvaluee
in interface EvalContext
java.lang.IllegalStateException
- if the stack of objects being evaluated
is emptypublic void printEvalTrace(java.io.PrintStream s)
printEvalTrace
in interface EvalContext
protected void handleMissingVar(BayesNetVar var)
errorIfUndet
field.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |