Search in sources :

Example 6 with Polytope

use of com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope in project aic-praise by aic-sri-international.

the class AbstractAEBPTreeNode method computeProductOfFactorAtRootTimesTheIncomingMessages.

private Polytope computeProductOfFactorAtRootTimesTheIncomingMessages(Predicate<Polytope> boxIt) {
    List<Polytope> polytopesToMultiply = new ArrayList<>(children.size());
    for (AEBPTreeNode<ParentNode, RootNode> child : children) {
        polytopesToMultiply.add(child.messageSent(boxIt));
    }
    // P.S: if the root is a factor: add {(on:) root} to the list; if is a non exhausted variable, add a Simplex(root)
    this.addSimplexOrFactortoTheListOfProducts(polytopesToMultiply);
    Polytope result = accumulate(polytopesToMultiply, Polytope::multiply, identityPolytope());
    return result;
}
Also used : Polytope(com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope) Polytopes.identityPolytope(com.sri.ai.praise.core.representation.interfacebased.polytope.core.byexpressiveness.convexhull.Polytopes.identityPolytope) ArrayList(java.util.ArrayList)

Example 7 with Polytope

use of com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope in project aic-praise by aic-sri-international.

the class AnytimeExactBP method getProductOfAllIncomingPolytopesAndFactorAtRoot.

private Polytope getProductOfAllIncomingPolytopesAndFactorAtRoot(List<Approximation<Factor>> subsApproximations) {
    List<Polytope> polytopesToMultiply = getAllPolytopes(subsApproximations);
    Polytope result = accumulate(polytopesToMultiply, Polytope::multiply, identityPolytope());
    return result;
}
Also used : Polytope(com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope) Polytopes.identityPolytope(com.sri.ai.praise.core.representation.interfacebased.polytope.core.byexpressiveness.convexhull.Polytopes.identityPolytope)

Example 8 with Polytope

use of com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope in project aic-praise by aic-sri-international.

the class GradientAnytimeExactBP method function.

@Override
public Approximation<Factor> function(List<Approximation<Factor>> subsApproximations) {
    Polytope product = getProductOfAllIncomingPolytopesAndFactorAtRoot(subsApproximations);
    Collection<? extends Variable> freeVariables = product.getFreeVariables();
    List<? extends Variable> variablesSummedOut = getBase().determinedVariablesToBeSummedOut(freeVariables);
    Approximation<Factor> result = sumOut(variablesSummedOut, product);
    return result;
}
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) ConstantFactor(com.sri.ai.praise.core.representation.interfacebased.factor.core.ConstantFactor) Factor(com.sri.ai.praise.core.representation.interfacebased.factor.api.Factor)

Example 9 with Polytope

use of com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope in project aic-praise by aic-sri-international.

the class GradientAnytimeExactBP method getProductOfAllIncomingPolytopesButOne.

private Polytope getProductOfAllIncomingPolytopesButOne(Anytime<Factor> sub, List<Approximation<Factor>> subsApproximations) {
    Polytope subApproximationToRemove = (Polytope) sub.getCurrentApproximation();
    List<Polytope> polytopesToMultiply = getAllPolytopesButOne(subApproximationToRemove, subsApproximations);
    Polytope result = accumulate(polytopesToMultiply, Polytope::multiply, identityPolytope());
    return result;
}
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)

Example 10 with Polytope

use of com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope in project aic-praise by aic-sri-international.

the class GradientAnytimeExactBP method sumOutWithoutOneSub.

private Polytope sumOutWithoutOneSub(Anytime<Factor> sub) {
    List<Approximation<Factor>> subsApproximations = getSubsApproximation();
    Polytope product = getProductOfAllIncomingPolytopesButOneAndFactorAtRoot(sub, subsApproximations);
    Collection<? extends Variable> freeVariables = product.getFreeVariables();
    List<? extends Variable> variablesSummedOut = getBase().determinedVariablesToBeSummedOut(freeVariables);
    Polytope result = sumOut(variablesSummedOut, product);
    return result;
}
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) Approximation(com.sri.ai.util.computation.anytime.api.Approximation)

Aggregations

Polytope (com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope)28 AtomicPolytope (com.sri.ai.praise.core.representation.interfacebased.polytope.api.AtomicPolytope)20 Polytopes.identityPolytope (com.sri.ai.praise.core.representation.interfacebased.polytope.core.byexpressiveness.convexhull.Polytopes.identityPolytope)15 Factor (com.sri.ai.praise.core.representation.interfacebased.factor.api.Factor)9 Variable (com.sri.ai.praise.core.representation.interfacebased.factor.api.Variable)5 TableFactor (com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor)5 ArrayList (java.util.ArrayList)5 ConstantFactor (com.sri.ai.praise.core.representation.interfacebased.factor.core.ConstantFactor)4 TableVariable (com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableVariable)4 IntensionalConvexHullOfFactors (com.sri.ai.praise.core.representation.interfacebased.polytope.core.byexpressiveness.convexhull.IntensionalConvexHullOfFactors)4 Predicate (com.google.common.base.Predicate)3 Box (com.sri.ai.praise.core.representation.interfacebased.polytope.core.byexpressiveness.box.Box)3 TableBoxVariable (com.sri.ai.praise.core.representation.interfacebased.polytope.core.byexpressiveness.box.TableBoxVariable)3 Util.list (com.sri.ai.util.Util.list)3 List (java.util.List)3 IDENTITY_FACTOR (com.sri.ai.praise.core.representation.interfacebased.factor.core.IdentityFactor.IDENTITY_FACTOR)2 Util.collect (com.sri.ai.util.Util.collect)2 Util.getFirst (com.sri.ai.util.Util.getFirst)2 Util.getFirstSatisfyingPredicateOrNull (com.sri.ai.util.Util.getFirstSatisfyingPredicateOrNull)2 Util.in (com.sri.ai.util.Util.in)2