use of anytimeExactBeliefPropagation.Model.Node.VariableNode in project aic-expresso by aic-sri-international.
the class PartitionTree method updateSetsOfFactorsAndVariables.
/*------------------------------------------------------------------------------------------------------------------------*/
public void updateSetsOfFactorsAndVariables() {
if (this.node.isFactor()) {
FactorNode newFactor = (FactorNode) this.node;
Set<VariableNode> newVariables = new HashSet<VariableNode>();
// Util.println(model);
if (this.model == null) {
this.model = this.parent.model;
}
Util.println(this.model);
// we look at the variables involved in the factor
newVariables.addAll(this.model.getExploredGraph().getAsOfB(newFactor));
// we remove the parent, which is already in the variable set
newVariables.remove(this.parent.node.getValue());
this.updateSetsOfFactorsAndVariables(newFactor, newVariables);
} else {
this.updateSetsOfVariables();
}
}
use of anytimeExactBeliefPropagation.Model.Node.VariableNode in project aic-expresso by aic-sri-international.
the class Model method ExpandModel.
public void ExpandModel(FactorNode newFactorNode) {
// BFS, DFS,...
for (Expression variable : Expressions.freeVariables(newFactorNode.getValue(), context)) {
VariableNode v = new VariableNode(variable, isExtensional, theory, context);
exploredGraphicalModel.add(v, newFactorNode);
}
}
use of anytimeExactBeliefPropagation.Model.Node.VariableNode in project aic-expresso by aic-sri-international.
the class Model method ExpandModel.
/**
* This method receives as input an {@code Iterator<FactorNode>} object and expands the
* {@code exploredGraphicalModel} by adding ONE FACTOR to it.
*
* There are various ways of doing such expansion, and it is then given to the User the
* choice on which way to go.
*
* @param it
*/
public void ExpandModel(Iterator<FactorNode> it) {
// BFS, DFS,...
if (it.hasNext()) {
FactorNode newFactorNode = it.next();
for (Expression variable : Expressions.freeVariables(newFactorNode.getValue(), context)) {
VariableNode v = new VariableNode(variable, isExtensional, theory, context);
exploredGraphicalModel.add(v, newFactorNode);
}
}
}
use of anytimeExactBeliefPropagation.Model.Node.VariableNode in project aic-expresso by aic-sri-international.
the class IncrementalBeliefPropagationWithConditioning method inference.
public Bound inference() {
VariableNode query = model.getQuery();
this.partitionTree = new PartitionTree(query, model);
AllExplored = model.AllExplored();
Bound result = variableMessage(partitionTree, new HashSet<VariableNode>());
return result;
}
use of anytimeExactBeliefPropagation.Model.Node.VariableNode in project aic-expresso by aic-sri-international.
the class PartitionTree method getArrayOfBoundsFromSetOfVariableNodes.
public Expression[] getArrayOfBoundsFromSetOfVariableNodes(Set<VariableNode> variableNodes) {
Iterator<VariableNode> it = variableNodes.iterator();
int n = variableNodes.size();
Expression[] tabExpression = new Expression[n];
int i = 0;
for (VariableNode v : in(it)) {
tabExpression[i] = v.getValue();
i++;
}
return tabExpression;
}
Aggregations