public class Evidence
extends java.lang.Object
OnlineEngine
. An evidence object is linked to a
specific OnlineEngine
. This object performs no
inference. It merely stores weights in a form that can be used
efficiently by the engine. When evidence is constructed, it assigns all
weights to defaults, as stored in the literal map. After construction,
weights may be changed.
There are two types of weights in the AC. Each value x of each variable X may have a corresponding indicator weight in the AC. There will exist such a weight iff X is not a part of evidence used *during compilation*. When such a weight exists, it is initially set to its default value, typically 1.0, as defined in the literal map. The default value typically indicates that X=x is possible. If the weight is changed to 0.0, then that is equivalent to saying that X=x is not possible. Asserting traditional evidence X=x on a variable is equivalent to setting weights for all the variable's values to 0.0 except for the weight corresponding to x, which is set to its default value.
Each parameter P in the network may have a corresponding parameter weight in the AC. There will exist such a weight iff the particular compilation strategy does not commit the parameter to a specific value to make compilation more efficient. The main point is that different strategies will commit different variables, and so different strategies will make different sets of parameter weights available. For example, tabular variable elimination will not produce any parameter weights, but logical compilation using the -cd06 encoding will produce a parameter weight for each non-zero parameter that is unique within its CPT (there is no other parameter having equal value). When such a weight exists, it is initially set to its default value, typically the value of the corresponding parameter, as defined in the literal map. This weight may be changed however, which is equivalent to changing the value of the parameter in the network.
In some cases, it is advantageous to utilize multiple evidence objects. For example, if one wanted to isolate online inference in order to obtain accurate timing, one could construct all evidence sets to be used in queries before performing online inference. As another example, consider a situation where we execute a loop, and in each iteration, we compute probability of evidence for each of N identical systems, where each system has its own set of observations. Since the systems are identical, we can use the same OnlineEngine for each. Moreover, rather than reconstruct the evidence from scratch for each system in each iteration, we could maintain one evidence object for each system, and in each iteration, only update each evidence object with changes in the corresponding system, which would be simpler and somewhat more efficient. In other cases, a single evidence set may work best. For example, if performing a branch-and-bound search for an instantiation of MAP variables, one may wish to commit a single assignment and retract a single assignment at each search node.
A major goal when performing arithmetic circuit inference is efficiency.
When the arithmetic circuit is sufficiently large, the time to set up
evidence will be insignificant, even when care is not taken. However,
when an arithmetic circuit is small compared to the number of variables, the
time to set up evidence may be more significant. If the time to set up
evidence turns out to be significant, then there are several things that
could be done to improve the situation. First, try to reduce the number of
invocations of
OnlineEngine.varForName(String)
(
OnlineEngine.potForName(String)
),
calling it at most once for a given variable (potential) if at all
possible during initialization rather than once (or multiple times) inference
is performed. It may also help to reduce the number of calls to methods
within this class, especially Evidence(OnlineEngine)
and retractAll()
, each of which
executes in time that is linear in the number of AC variables, which can be
as large as the Bayesian network from which the AC was produced. Strategies
for improving efficiency include making use of multiple evidence objects
where doing so will help, updating evidence instead of creating it from
scratch where doing so will help, and reusing evidence objects instead of
creating new ones where doing so will help.
Constructor and Description |
---|
Evidence(edu.ucla.belief.ace.OnlineEngine engine)
Constructs empty evidence that may be used with the given OnlineEngine
by assigning each weight its default as stored in the literal map.
|
Modifier and Type | Method and Description |
---|---|
edu.ucla.belief.ace.OnlineEngine |
engine() |
void |
parmCommit(int pot,
int pos,
double weight)
Redefines the value of the parameter defined by the given potential and
given position.
|
void |
parmRetract(int pot,
int pos)
Retracts any redefinition of the value of the parameter defined by the
given potential and given position.
|
void |
retractAll()
Retracts all changes to weights by resetting each weight to its default,
as defined in the literal map.
|
java.lang.String |
toString() |
void |
valCommit(int var,
int val,
double weight)
Redefines the weight of the indicator defined by the given variable and
value to the given weight.
|
void |
valRetract(int var,
int val)
Sets the weight of the indicator defined by the given variable and value
to its default weight.
|
void |
varCommit(int var,
int val)
Commits the given variable to the given value.
|
void |
varRetract(int var)
Retracts evidence on the given variable.
|
public Evidence(edu.ucla.belief.ace.OnlineEngine engine)
engine
- the given engine.public void retractAll()
public void varCommit(int var, int val)
var
- the given variable.val
- the given value.public void varRetract(int var)
var
- the given variable.public void valCommit(int var, int val, double weight)
var
- the given variable.val
- the given value.weight
- the given weight.public void valRetract(int var, int val)
var
- the given variable.val
- the given value.public void parmCommit(int pot, int pos, double weight)
pot
- the given potential.pos
- the given position.weight
- the given weight.public void parmRetract(int pot, int pos)
pot
- the given potential.pos
- the given position.public java.lang.String toString()
toString
in class java.lang.Object
public edu.ucla.belief.ace.OnlineEngine engine()