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 addFactorAtRootPolytope.
private void addFactorAtRootPolytope(List<Polytope> polytopesToMultiply) {
IntensionalConvexHullOfFactors singletonConvexHullOfFactorAtRoot = getFactorAtRootPolytope();
polytopesToMultiply.add(singletonConvexHullOfFactorAtRoot);
}
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 createNormalizedMinFactorWithoutOneSub.
private Factor createNormalizedMinFactorWithoutOneSub(Anytime<Factor> sub, Collection<? extends Variable> rootIndices) {
Polytope rootPolytopeWithoutOneSub = productWithoutOneSub(sub);
IntensionalConvexHullOfFactors rootConvexHullWithoutOneSub = (IntensionalConvexHullOfFactors) rootPolytopeWithoutOneSub;
Factor rootFactorWithoutOneSub = rootConvexHullWithoutOneSub.getFactor();
Factor minRootFactorWithoutOneSub = rootFactorWithoutOneSub.min(rootIndices);
Factor normalizedMinFactorWithoutOneSub = minRootFactorWithoutOneSub.normalize();
return normalizedMinFactorWithoutOneSub;
}
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 createNormalizedMaxFactorWithoutOneSub.
private Factor createNormalizedMaxFactorWithoutOneSub(Anytime<Factor> sub, Collection<? extends Variable> rootIndices) {
Polytope rootPolytopeWithoutOneSub = productWithoutOneSub(sub);
IntensionalConvexHullOfFactors rootConvexHullWithoutOneSub = (IntensionalConvexHullOfFactors) rootPolytopeWithoutOneSub;
Factor rootFactorWithoutOneSub = rootConvexHullWithoutOneSub.getFactor();
Factor maxRootFactorWithoutOneSub = rootFactorWithoutOneSub.max(rootIndices);
Factor normalizedMaxFactorWithoutOneSub = maxRootFactorWithoutOneSub.normalize();
return normalizedMaxFactorWithoutOneSub;
}
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 createNormalizedMinFactor.
private Factor createNormalizedMinFactor(Collection<? extends Variable> rootIndices) {
Approximation<Factor> rootApproximation = getCurrentApproximation();
IntensionalConvexHullOfFactors rootConvexHull = transformApproximationToConvexHullOrThrowsErrorIfNotPossible(rootApproximation);
Factor rootFactor = rootConvexHull.getFactor();
Factor minFactor = rootFactor.min(rootIndices);
Factor normalizedMinFactor = minFactor.normalize();
return normalizedMinFactor;
}
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 getAbsoluteVolumeVariationFromVariableToFactorWithRespectTo.
// implementation based on logVolume
private Double getAbsoluteVolumeVariationFromVariableToFactorWithRespectTo(Anytime<Factor> sub, Collection<? extends Variable> subAtomicPolytopeIndices) {
// root is a factor
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);
Factor normalizedMaxFactorWithoutOneSub = createNormalizedMaxFactorWithoutOneSub(sub, rootIndices);
Factor normalizedMinFactorWithoutOneSub = createNormalizedMinFactorWithoutOneSub(sub, rootIndices);
Factor minusNormalizedMinFactorWithoutOneSub = normalizedMinFactorWithoutOneSub.multiply(new ConstantFactor(1.));
Factor MaxMinusMinFactorWithoutOneSub = normalizedMaxFactorWithoutOneSub.add(minusNormalizedMinFactorWithoutOneSub);
Factor firstTermProduct = invertedMaxMinusMinFactor.multiply(MaxMinusMinFactorWithoutOneSub);
Factor firstTerm = firstTermProduct.sumOut(new ArrayList<>(rootConvexHull.getFreeVariables()));
return null;
}
Aggregations