Search in sources :

Example 11 with Variable

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

the class DefaultDatapoint method getValuesOfVariables.

@Override
public List<? extends Object> getValuesOfVariables(List<? extends Variable> variables) {
    ArrayList<Object> valueOfVariables = new ArrayList<Object>();
    for (Variable variable : variables) {
        Object valueOfCurrentVariable = getValueOfVariable(variable);
        valueOfVariables.add(valueOfCurrentVariable);
    }
    return valueOfVariables;
}
Also used : Variable(com.sri.ai.praise.core.representation.interfacebased.factor.api.Variable) ArrayList(java.util.ArrayList)

Example 12 with Variable

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

the class AEBPQueryTreeNode method updateNonExhaustedNodes.

// NOT TESTED
private void updateNonExhaustedNodes(AEBPFactorTreeNode newFactorNode, HashMap<Object, AEBPTreeNode<?, ?>> mapFromNodeToPartition) {
    // Get the intersection of the non exhausted variables and the variables of the new factor. Those variables were for sure non exhausted (by definition)
    LinkedHashSet<Variable> nonExhaustedVariablesFromNewFactorBeforeAddingTheNewFactor = getNonExhaustedVariablesFromNewFactorBeforeAddingNewFactor(newFactorNode);
    // For each one of them, if they are exhausted now, recompute messages
    for (Variable v : nonExhaustedVariablesFromNewFactorBeforeAddingTheNewFactor) {
        // set "recompute message" = true
        if (this.isExhausted.apply(v)) {
            AEBPVariableTreeNode varTreeNode = (AEBPVariableTreeNode) mapFromNodeToPartition.get(v);
            setRecomputeNeededForItAndAllAncestors(varTreeNode);
        }
    }
}
Also used : Variable(com.sri.ai.praise.core.representation.interfacebased.factor.api.Variable)

Example 13 with Variable

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

the class GradientAnytimeExactBP method getFreeVariable.

private static Variable getFreeVariable(Polytope subPolytope) {
    Collection<? extends Variable> freeVariables = subPolytope.getFreeVariables();
    if (freeVariables.size() != 1) {
        throw new Error("BP messages should have one and only one free variable");
    }
    Variable freeVariable = null;
    for (Variable variable : freeVariables) {
        freeVariable = variable;
    }
    return freeVariable;
}
Also used : Variable(com.sri.ai.praise.core.representation.interfacebased.factor.api.Variable)

Example 14 with Variable

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

the class GradientAnytimeExactBP method getIndices.

private static Set<? extends Variable> getIndices(AtomicPolytope subAtomicPolytope) {
    Set<Variable> result = new HashSet<>();
    if (subAtomicPolytope instanceof Simplex) {
        Simplex subSimplex = (Simplex) subAtomicPolytope;
        result.add(subSimplex.getVariable());
    } else if (subAtomicPolytope instanceof IntensionalConvexHullOfFactors) {
        IntensionalConvexHullOfFactors subConvexHull = (IntensionalConvexHullOfFactors) subAtomicPolytope;
        result.addAll(subConvexHull.getIndices());
    } else {
        throw new Error("New unsupported type of atomic polytope added");
    }
    return result;
}
Also used : Simplex(com.sri.ai.praise.core.representation.interfacebased.polytope.core.byexpressiveness.convexhull.Simplex) Variable(com.sri.ai.praise.core.representation.interfacebased.factor.api.Variable) IntensionalConvexHullOfFactors(com.sri.ai.praise.core.representation.interfacebased.polytope.core.byexpressiveness.convexhull.IntensionalConvexHullOfFactors) HashSet(java.util.HashSet)

Example 15 with Variable

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

the class LazyExactBPNodeFromFactorToVariableEvaluator method isRelevantForCurrentResult.

private boolean isRelevantForCurrentResult(ExactBPNodeFromVariableToFactor subFromVariableToFactor) {
    Variable variable = subFromVariableToFactor.getRoot();
    boolean result = currentProduct.getVariables().contains(variable);
    return result;
}
Also used : Variable(com.sri.ai.praise.core.representation.interfacebased.factor.api.Variable)

Aggregations

Variable (com.sri.ai.praise.core.representation.interfacebased.factor.api.Variable)23 Factor (com.sri.ai.praise.core.representation.interfacebased.factor.api.Factor)11 ArrayList (java.util.ArrayList)10 TableFactor (com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactor)9 TableVariable (com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableVariable)9 ExpressionFactor (com.sri.ai.praise.core.representation.interfacebased.factor.core.expression.api.ExpressionFactor)4 AtomicPolytope (com.sri.ai.praise.core.representation.interfacebased.polytope.api.AtomicPolytope)4 Polytope (com.sri.ai.praise.core.representation.interfacebased.polytope.api.Polytope)4 Util.mapIntoArrayList (com.sri.ai.util.Util.mapIntoArrayList)4 List (java.util.List)4 Expression (com.sri.ai.expresso.api.Expression)3 TableFactorNetwork (com.sri.ai.praise.core.representation.interfacebased.factor.core.table.TableFactorNetwork)3 TableBoxVariable (com.sri.ai.praise.core.representation.interfacebased.polytope.core.byexpressiveness.box.TableBoxVariable)3 IntensionalConvexHullOfFactors (com.sri.ai.praise.core.representation.interfacebased.polytope.core.byexpressiveness.convexhull.IntensionalConvexHullOfFactors)3 Predicate (com.google.common.base.Predicate)2 AnytimeExactBP (com.sri.ai.praise.core.inference.byinputrepresentation.interfacebased.core.exactbp.anytime.rodrigo.AnytimeExactBP)2 ExactBP (com.sri.ai.praise.core.inference.byinputrepresentation.interfacebased.core.exactbp.fulltime.core.ExactBP)2 ExpressionVariable (com.sri.ai.praise.core.representation.interfacebased.factor.core.expression.api.ExpressionVariable)2 ExpressionExactBP (com.sri.ai.praise.core.representation.interfacebased.factor.core.expression.core.ExpressionExactBP)2 RandomTableFactorMaker.makeRandomTableFactor (com.sri.ai.praise.core.representation.interfacebased.factor.core.table.helper.RandomTableFactorMaker.makeRandomTableFactor)2