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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations