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