com.cra.figaro.experimental.collapsedgibbs
A sample is a map from elements to their values.
A sample is a map from elements to their values.
Number of samples to throw away initially.
Number of samples to throw away initially.
Method to create a blocking scheme given information about the model and factors.
Method to create a blocking scheme given information about the model and factors.
The algorithm to compute probability of specified evidence in a dependent universe.
The algorithm to compute probability of specified evidence in a dependent universe. We use () => Double to represent this algorithm instead of an instance of ProbEvidenceAlgorithm. Typical usage is to return the result of ProbEvidenceAlgorithm.computeProbEvidence when invoked.
A list of universes that depend on this universe such that evidence on those universes should be taken into account in this universe.
A list of universes that depend on this universe such that evidence on those universes should be taken into account in this universe.
Iterations thrown away between samples.
Iterations thrown away between samples.
Elements whose samples will be recorded at each iteration.
Elements whose samples will be recorded at each iteration.
add a factor to the list
add a factor to the list
Only variables with alpha or fewer neighbors in the primal graph are candidates for collapsing.
Only variables with alpha or fewer neighbors in the primal graph are candidates for collapsing.
We use ( alpha C 2 ) often, may as well store it.
We use ( alpha C 2 ) often, may as well store it.
Called when the algorithm is killed.
Called when the algorithm is killed. By default, does nothing. Can be overridden.
Perform the collapsing step.
Perform the collapsing step.
We want to alter the original blocks so that we filter out any variables which have been eliminated.
We want to alter the original blocks so that we filter out any variables which have been eliminated. If the original blocks overlapped a lot, then there'll be a lot of redundancy in the filtered blocks, so we take a further step of eliminating any block xs which is fully contained in another block ys.
The most recent set of samples, used for sampling variables conditioned on the values of other variables.
The most recent set of samples, used for sampling variables conditioned on the values of other variables.
Hellinger distance is defined in the source paper (amongst other places).
Hellinger distance is defined in the source paper (amongst other places). It's the sum over all values of X1 and X2 of (sqrt(P(X1,X2)) - sqrt(P(X1)*P(X2)))^2
Eliminate a variable.
Eliminate a variable. This follows the same approach as in VariableElimination.scala. }
List of all factors.
List of all factors.
All implementations of factored algorithms must specify a way to get the factors from the given universe and dependent universes.
All implementations of factored algorithms must specify a way to get the factors from the given universe and dependent universes.
Get the elements that are needed by the query target variables and the evidence variables.
Get the elements that are needed by the query target variables and the evidence variables. Also compute the values of those variables to the given depth. Only get factors for elements that are actually used by the target variables. This is more efficient. Also, it avoids problems when values of unused elements have not been computed.
In addition to getting all the needed elements, it determines if any of the conditioned, constrained, or dependent universe parent elements has * in its range. If any of these elements has * in its range, the lower and upper bounds of factors will be different, so we need to compute both. If they don't, we don't need to compute bounds.
Number of samples taken
Number of samples taken
globalGraph lets us traverse the primal graph.
globalGraph lets us traverse the primal graph.
Compute the score of a given variable.
Compute the score of a given variable.
Returns how many edges would be added to the primal graph by removing var1.
Returns how many edges would be added to the primal graph by removing var1. Note: this is number of edges added, NOT net edges added and removed. Source paper is somewhat ambiguous on whether this should be added or net.
Called when the algorithm is started before running any steps.
Called when the algorithm is started before running any steps. By default, does nothing. Can be overridden.
Kill the algorithm so that it is inactive.
Kill the algorithm so that it is inactive. It will no longer be able to provide answers.Throws AlgorithmInactiveException if the algorithm is not active.
Combine all the remaining factors into one 'result factor', as in VE.
Combine all the remaining factors into one 'result factor', as in VE.
Marginalize all factors to their component variables.
Marginalize all factors to their component variables.
Marginalize a factor to a particular variable.
Marginalize a factor to a particular variable.
remove a factor from the list
remove a factor from the list
Reset all the marginal and p.m.
Reset all the marginal and p.m. maps to empty maps.
Resume the computation of the algorithm, if it has been stopped.
Resume the computation of the algorithm, if it has been stopped. Throws AlgorithmInactiveException if the algorithm is not active.
Produce a single sample.
Produce a single sample.
Sample all blocks, then store that sample in the marginal and p.m.
Sample all blocks, then store that sample in the marginal and p.m. maps.
Semiring for use in factors.
Semiring for use in factors.
Sort variables by the target heuristic, if they have fewer than alpha neighbors and are not targets.
Sort variables by the target heuristic, if they have fewer than alpha neighbors and are not targets.
Start the algorithm and make it active.
Start the algorithm and make it active. After it returns, the algorithm must be ready to provide answers. Throws AlgorithmActiveException if the algorithm is already active.
Stop the algorithm from computing.
Stop the algorithm from computing. The algorithm is still ready to provide answers after it returns. Throws AlgorithmInactiveException if the algorithm is not active.
List of variables corresponding to target elements.
List of variables corresponding to target elements. Creating these is memoized, so we don't need to worry about duplicates.
Store which elements are our target variables so that subclasses can make use of them.
Store which elements are our target variables so that subclasses can make use of them.
Use the marginal maps to compute Hellinger maps.
Store which elements are our target variables so that subclasses can make use of them.
Store which elements are our target variables so that subclasses can make use of them.
Variables to sample at each time step.
Variables to sample at each time step.
We need a list of variables in order so we can access them by index.
We need a list of variables in order so we can access them by index.
HeuristicCollapsedGibbs adds the Hellinger-distance-based term to the elimination heuristic. So the heuristic is now based on the marginal probabilities and pairwise marginals. These have to be estimated by some number of saved samples.