use of com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope in project aic-praise by aic-sri-international.
the class GradientAnytimeExactBP method productWithoutOneSub.
private Polytope productWithoutOneSub(Anytime<Factor> sub) {
List<Approximation<Factor>> subsApproximations = getSubsApproximation();
Polytope product = getProductOfAllIncomingPolytopesButOne(sub, subsApproximations);
return product;
}
use of com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope in project aic-praise by aic-sri-international.
the class GradientAnytimeExactBP method getAbsoluteVolumeVariationFromFactorToVariableWithRespectTo.
private Double getAbsoluteVolumeVariationFromFactorToVariableWithRespectTo(Anytime<Factor> sub, Collection<? extends Variable> subAtomicPolytopeIndices) {
// root is a variable
Approximation<Factor> subApproximation = sub.getCurrentApproximation();
AtomicPolytope subAtomicPolytope = transformApproximationToAtomicPolytopeOrThrowsErrorIfNotPossible(subApproximation);
Approximation<Factor> rootApproximation = getCurrentApproximation();
IntensionalConvexHullOfFactors rootConvexHull = transformApproximationToConvexHullOrThrowsErrorIfNotPossible(rootApproximation);
Collection<? extends Variable> rootIndices = rootConvexHull.getIndices();
Factor rootFactor = rootConvexHull.getFactor();
Factor normalizedMaxFactor = createNormalizedMaxFactor(rootIndices);
Factor normalizedMinFactor = createNormalizedMinFactor(rootIndices);
Factor invertedMaxMinusMinFactor = computeInvertedMaxMinusMinFactor(rootFactor, subAtomicPolytopeIndices);
List<Variable> rootFreeVariables = new ArrayList<>(rootConvexHull.getFreeVariables());
Factor maxFactor = rootFactor.max(rootIndices);
Factor maxNormalizationConstant = maxFactor.sumOut(rootFreeVariables);
Factor invertedMaxNormalizationConstant = maxNormalizationConstant.invert();
Factor maxProduct = invertedMaxMinusMinFactor.multiply(invertedMaxNormalizationConstant);
Factor minFactor = rootFactor.min(rootIndices);
Factor minNormalizationConstant = minFactor.sumOut(rootFreeVariables);
Factor invertedMinNormalizationConstant = minNormalizationConstant.invert();
Factor minProduct = invertedMaxMinusMinFactor.multiply(invertedMinNormalizationConstant);
Polytope summedOutPolytopeWithoutOneSub = sumOutWithoutOneSub(sub);
IntensionalConvexHullOfFactors rootConvexHullWithoutOneSub = (IntensionalConvexHullOfFactors) summedOutPolytopeWithoutOneSub;
Factor rootFactorWithoutOneSub = rootConvexHullWithoutOneSub.getFactor();
Factor summedOutRootFactorWithoutOneSub = rootFactorWithoutOneSub.sumOut(rootFreeVariables);
return null;
// TODO
}
use of com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope in project aic-praise by aic-sri-international.
the class GradientAnytimeExactBP method getProductOfAllIncomingPolytopesAndFactorAtRoot.
private Polytope getProductOfAllIncomingPolytopesAndFactorAtRoot(List<Approximation<Factor>> subsApproximations) {
List<Polytope> polytopesToMultiply = getAllPolytopes(subsApproximations);
Polytope result = accumulate(polytopesToMultiply, Polytope::multiply, identityPolytope());
return result;
}
Aggregations