Search in sources :

Example 11 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 addFactorAtRootPolytope.

private void addFactorAtRootPolytope(List<Polytope> polytopesToMultiply) {
    IntensionalConvexHullOfFactors singletonConvexHullOfFactorAtRoot = getFactorAtRootPolytope();
    polytopesToMultiply.add(singletonConvexHullOfFactorAtRoot);
}
Also used : IntensionalConvexHullOfFactors(com.sri.ai.praise.core.representation.interfacebased.polytope.core.byexpressiveness.convexhull.IntensionalConvexHullOfFactors)

Example 12 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 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;
}
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) 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)

Example 13 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 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;
}
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) 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)

Example 14 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 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;
}
Also used : 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)

Example 15 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 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;
}
Also used : 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) ConstantFactor(com.sri.ai.praise.core.representation.interfacebased.factor.core.ConstantFactor) 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