use of com.sri.ai.praise.core.representation.interfacebased.polytope.core.byexpressiveness.convexhull.IntensionalConvexHullOfFactors 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
}
Aggregations