Search in sources :

Example 16 with IntensionalConvexHullOfFactors

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
}
Also used : Polytopes.identityPolytope(com.sri.ai.praise.core.representation.interfacebased.polytope.core.byexpressiveness.convexhull.Polytopes.identityPolytope) AtomicPolytope(com.sri.ai.praise.core.representation.interfacebased.polytope.api.AtomicPolytope) Polytope(com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope) Variable(com.sri.ai.praise.core.representation.interfacebased.factor.api.Variable) IntensionalConvexHullOfFactors(com.sri.ai.praise.core.representation.interfacebased.polytope.core.byexpressiveness.convexhull.IntensionalConvexHullOfFactors) ConstantFactor(com.sri.ai.praise.core.representation.interfacebased.factor.core.ConstantFactor) Factor(com.sri.ai.praise.core.representation.interfacebased.factor.api.Factor) ArrayList(java.util.ArrayList) AtomicPolytope(com.sri.ai.praise.core.representation.interfacebased.polytope.api.AtomicPolytope)

Aggregations

IntensionalConvexHullOfFactors (com.sri.ai.praise.core.representation.interfacebased.polytope.core.byexpressiveness.convexhull.IntensionalConvexHullOfFactors)16 Factor (com.sri.ai.praise.core.representation.interfacebased.factor.api.Factor)9 ConstantFactor (com.sri.ai.praise.core.representation.interfacebased.factor.core.ConstantFactor)7 AtomicPolytope (com.sri.ai.praise.core.representation.interfacebased.polytope.api.AtomicPolytope)5 Variable (com.sri.ai.praise.core.representation.interfacebased.factor.api.Variable)4 Polytope (com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope)4 Polytopes.identityPolytope (com.sri.ai.praise.core.representation.interfacebased.polytope.core.byexpressiveness.convexhull.Polytopes.identityPolytope)3 ArrayList (java.util.ArrayList)3 TableFactor (com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor)2 TableVariable (com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableVariable)2 Simplex (com.sri.ai.praise.core.representation.interfacebased.polytope.core.byexpressiveness.convexhull.Simplex)2 Util.println (com.sri.ai.util.Util.println)2 LinkedHashSet (java.util.LinkedHashSet)2 List (java.util.List)2 Predicate (com.google.common.base.Predicate)1 AssignmentsIterator (com.sri.ai.grinder.helper.AssignmentsIterator)1 AEBP (com.sri.ai.praise.core.inference.byinputrepresentation.interfacebased.core.exactbp.anytime.gabriel.AEBP)1 TestCases (com.sri.ai.praise.core.inference.byinputrepresentation.interfacebased.core.exactbp.anytime.gabriel.TestCases)1 AnytimeExactBP (com.sri.ai.praise.core.inference.byinputrepresentation.interfacebased.core.exactbp.anytime.rodrigo.AnytimeExactBP)1 ExactBPNode (com.sri.ai.praise.core.inference.byinputrepresentation.interfacebased.core.exactbp.fulltime.api.ExactBPNode)1