use of anytimeExactBeliefPropagation.Model.Node.FactorNode in project aic-expresso by aic-sri-international.
the class Tests method testFunction.
private static void testFunction(String modelName, Model m, boolean printAll) {
Iterator<FactorNode> bfsExpander = new BFS(m);
IncrementalBeliefPropagationWithConditioning sbp = new IncrementalBeliefPropagationWithConditioning(m);
println("Exploring " + modelName);
Bound inferenceResult = null;
double totalTime = 0;
while (bfsExpander.hasNext()) {
long tStart = System.currentTimeMillis();
inferenceResult = sbp.expandAndComputeInference(bfsExpander);
long tEnd = System.currentTimeMillis();
long tDelta = tEnd - tStart;
double time = tDelta / 1000.0;
totalTime += time;
// ModelGenerator.printModel(m, false);
if (printAll) {
println("Number of ExtremePoints : " + inferenceResult.getArguments().size());
Pair<Double, Double> minAndMaxProbabilityofQueryequalsTrue = ModelGenerator.maxMinProbability(inferenceResult, m);
println("Minimal probability of Query = true : " + minAndMaxProbabilityofQueryequalsTrue.first + "\nMaximal probability of Query = true :" + minAndMaxProbabilityofQueryequalsTrue.second + "\nLength of interval (that is, (max - min)) : " + (minAndMaxProbabilityofQueryequalsTrue.second - minAndMaxProbabilityofQueryequalsTrue.first) + "\nTime to compute this iteration:" + time + ". Toatal time : " + totalTime);
println("----------------- AllExplored : " + m.AllExplored() + "-----------------");
}
}
if (!printAll)
println(inferenceResult);
println("Computation with SGDPLL");
long tStart = System.currentTimeMillis();
Expression LVE = ModelGenerator.lveCalculation(m);
long tEnd = System.currentTimeMillis();
long tDelta = tEnd - tStart;
double time = tDelta / 1000.0;
println(LVE + "\n" + "\nTime to compute:" + time);
}
Aggregations