Search in sources :

Example 6 with VariableNode

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();
    }
}
Also used : VariableNode(anytimeExactBeliefPropagation.Model.Node.VariableNode) FactorNode(anytimeExactBeliefPropagation.Model.Node.FactorNode) HashSet(java.util.HashSet)

Example 7 with VariableNode

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);
    }
}
Also used : VariableNode(anytimeExactBeliefPropagation.Model.Node.VariableNode) Expression(com.sri.ai.expresso.api.Expression)

Example 8 with VariableNode

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);
        }
    }
}
Also used : VariableNode(anytimeExactBeliefPropagation.Model.Node.VariableNode) Expression(com.sri.ai.expresso.api.Expression) FactorNode(anytimeExactBeliefPropagation.Model.Node.FactorNode)

Example 9 with VariableNode

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;
}
Also used : VariableNode(anytimeExactBeliefPropagation.Model.Node.VariableNode) Bound(com.sri.ai.grinder.library.bounds.Bound)

Example 10 with VariableNode

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;
}
Also used : VariableNode(anytimeExactBeliefPropagation.Model.Node.VariableNode) Expression(com.sri.ai.expresso.api.Expression)

Aggregations

VariableNode (anytimeExactBeliefPropagation.Model.Node.VariableNode)13 FactorNode (anytimeExactBeliefPropagation.Model.Node.FactorNode)7 Expression (com.sri.ai.expresso.api.Expression)5 HashSet (java.util.HashSet)5 DefaultExtensionalMultiSet (com.sri.ai.expresso.core.DefaultExtensionalMultiSet)3 Bound (com.sri.ai.grinder.library.bounds.Bound)3 ArrayList (java.util.ArrayList)3 Set (java.util.Set)3 Node (anytimeExactBeliefPropagation.Model.Node.Node)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1