use of com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope in project aic-praise by aic-sri-international.
the class Polytopes method sumOut.
public static Polytope sumOut(List<? extends Variable> variablesToBeSummedOut, Collection<? extends Polytope> polytopes) {
List<Polytope> independentOfVariablesToBeSummedOut = list();
List<Polytope> dependentOfVariablesToBeSummedOut = list();
collect(getNonIdentityAtomicPolytopes(polytopes), isIndependentOf(variablesToBeSummedOut), independentOfVariablesToBeSummedOut, dependentOfVariablesToBeSummedOut);
Polytope projectedPolytope = makeProjectedPolytopeOfIntensionalConvexHull(variablesToBeSummedOut, dependentOfVariablesToBeSummedOut);
Polytope result = makeProductOfPolytopes(independentOfVariablesToBeSummedOut, projectedPolytope);
return result;
}
use of com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope in project aic-praise by aic-sri-international.
the class Polytopes method makeProjectedPolytopeOfIntensionalConvexHull.
private static Polytope makeProjectedPolytopeOfIntensionalConvexHull(List<? extends Variable> variablesToBeSummedOut, List<Polytope> dependentOfVariablesToBeSummedOut) {
List<Variable> simplexVariables = collectSimplexVariables(dependentOfVariablesToBeSummedOut);
List<Variable> indicesFromConvexHulls = collectIndicesFromIntensionalPolytopes(dependentOfVariablesToBeSummedOut);
List<Factor> factors = collectFactorsFromIntensionalPolytopes(dependentOfVariablesToBeSummedOut);
Factor productOfFactors = Factor.multiply(factors);
List<? extends Variable> variablesToBeSummedOutOnceSimplexesAreDealtWith = subtract(variablesToBeSummedOut, simplexVariables);
Factor projectedFactor = productOfFactors.sumOut(variablesToBeSummedOutOnceSimplexesAreDealtWith);
List<Variable> finalIndices = union(indicesFromConvexHulls, simplexVariables);
Polytope projectedPolytope = new IntensionalConvexHullOfFactors(finalIndices, projectedFactor);
return projectedPolytope;
}
use of com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope in project aic-praise by aic-sri-international.
the class Polytopes method BoxAPolytope.
public static Polytope BoxAPolytope(Polytope polytope, Predicate<Polytope> criteria) {
List<Polytope> toBeBoxed = list();
List<Polytope> notToBeBoxed = list();
collect(getNonIdentityAtomicPolytopes(list(polytope)), p -> p instanceof IntensionalConvexHullOfFactors && criteria.apply(p), toBeBoxed, notToBeBoxed);
Polytope boxedPolytopes = boxPolytopes(toBeBoxed);
Polytope result = makeProductOfPolytopes(notToBeBoxed, boxedPolytopes);
return result;
}
use of com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope in project aic-praise by aic-sri-international.
the class AnytimeExactBPTest3 method solveGabrielWithBoxing.
public static AEBPTestingDataFrame solveGabrielWithBoxing(Variable query, EditableFactorNetwork factorNetwork, long maximunTimeInSeconds, String PGMName) {
println("\nSolving with Gabriel's Anytime - boxing\n");
Predicate<Polytope> criteria = p -> ((IntensionalConvexHullOfFactors) p).getIndices().size() > 10;
AEBP aebp = new AEBP(factorNetwork, query, criteria, true);
/*while(aebp.hasNext()) {
Polytope p = aebp.next();
println(p);
}*/
return AEBPSolver.solve(aebp, query, maximunTimeInSeconds, 0, PGMName, "Boxing");
}
use of com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope in project aic-praise by aic-sri-international.
the class AEBPQueryTreeNode method messageSent.
@Override
public Polytope messageSent(Predicate<Polytope> boxIt) {
Polytope message = super.messageSent(boxIt);
Polytope result = Polytopes.getEquivalentAtomicPolytopeOn(this.root, message);
return result;
}
Aggregations