use of com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope in project aic-praise by aic-sri-international.
the class GradientAnytimeExactBP method getProductOfAllIncomingPolytopesButOneAndFactorAtRoot.
private Polytope getProductOfAllIncomingPolytopesButOneAndFactorAtRoot(Anytime<Factor> sub, List<Approximation<Factor>> subsApproximations) {
Polytope subApproximationToRemove = (Polytope) sub.getCurrentApproximation();
List<Polytope> polytopesToMultiply = getAllPolytopesButOneWithFactor(subApproximationToRemove, subsApproximations);
Polytope result = accumulate(polytopesToMultiply, Polytope::multiply, identityPolytope());
return result;
}
use of com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope in project aic-praise by aic-sri-international.
the class AEBP method calculateNext.
@Override
protected Polytope calculateNext() {
if (!getNextNodeToPutOnTheTree.hasNext()) {
return null;
}
expand();
Polytope result = computeInference();
return result;
}
use of com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope in project aic-praise by aic-sri-international.
the class AnytimeExactBPTest2 method solveAndStoreInDataFrame.
private static AEBPTestingDataFrame solveAndStoreInDataFrame(Iterator<? extends Approximation<Factor>> anytimeEBPIterator, TableVariable query, double maximunTimeInSeconds, int runNumber, String PGMName, String methodName) {
AEBPTestingDataFrame df = new AEBPTestingDataFrame();
int i = 0;
Double currentTotalTime = .0;
// long startTime = System.currentTimeMillis();
while (currentTotalTime < maximunTimeInSeconds) {
println(++i);
Long currentTime = System.currentTimeMillis();
if (!anytimeEBPIterator.hasNext()) {
break;
}
Polytope result = (Polytope) anytimeEBPIterator.next();
Pair<? extends List<Double>, ? extends List<Double>> maxAndMin = printPolytopeAndMaxAndMin(query, result);
Double currentPartialTime = .001 * (System.currentTimeMillis() - currentTime);
// currentTotalTime = .001*(System.currentTimeMillis() - startTime);
currentTotalTime += currentPartialTime;
println("time: " + currentTotalTime);
df.addRow(runNumber, i, maxAndMin.second.get(0), maxAndMin.first.get(0), currentPartialTime, currentTotalTime, methodName, PGMName);
println("...");
}
println("-----Done-----");
return df;
}
use of com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope in project aic-praise by aic-sri-international.
the class AbstractAtomicPolytope method multiplyByAnotherAtomicPolytope.
private Polytope multiplyByAnotherAtomicPolytope(Polytope another) {
Polytope result;
AtomicPolytope attempt = this.getProductIfItIsANonIdentityAtomicPolytopeOrNullOtherwise((AtomicPolytope) another);
if (attempt == null) {
result = new ProductPolytope(list(this, (AtomicPolytope) another));
} else {
result = attempt;
}
return result;
}
use of com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope in project aic-praise by aic-sri-international.
the class Polytopes method makeProductOfPolytopes.
private static Polytope makeProductOfPolytopes(List<Polytope> independentOfVariablesToBeSummedOut, Polytope projectedPolytope) {
List<Polytope> resultingPolytopes = independentOfVariablesToBeSummedOut;
resultingPolytopes.add(projectedPolytope);
Polytope result = Polytope.multiply(resultingPolytopes);
return result;
}
Aggregations