Search in sources :

Example 1 with AEBPFactorTreeNode

use of com.sri.ai.praise.core.inference.byinputrepresentation.interfacebased.core.exactbp.anytime.gabriel.aebptree.AEBPFactorTreeNode in project aic-praise by aic-sri-international.

the class AEBP method expand.

private void expand() {
    // Get next factor (and it's children variables)
    AEBPFactorTreeNode nextTreeNodeToAddToTheTree = getNextNodeToPutOnTheTree.next();
    // Add new factor to model
    model.ExpandModel(nextTreeNodeToAddToTheTree.getRoot());
    // Add new factor to the tree
    tree.addNodeToTheTree(nextTreeNodeToAddToTheTree, model.getMapFromNodeToPartition(), cleverTrueBruteForceFalse);
}
Also used : AEBPFactorTreeNode(com.sri.ai.praise.core.inference.byinputrepresentation.interfacebased.core.exactbp.anytime.gabriel.aebptree.AEBPFactorTreeNode)

Example 2 with AEBPFactorTreeNode

use of com.sri.ai.praise.core.inference.byinputrepresentation.interfacebased.core.exactbp.anytime.gabriel.aebptree.AEBPFactorTreeNode in project aic-praise by aic-sri-international.

the class BFS method next.

@Override
public AEBPFactorTreeNode next() {
    if (!hasNext()) {
        throw new NoSuchElementException();
    }
    AEBPFactorTreeNode next = queue.remove();
    for (Variable variableNeighbour : model.getEntireGraph().getNeighbors(next.getRoot())) {
        AEBPVariableTreeNode variableTreeNode;
        if (fromNodeToPartition.get(variableNeighbour) == null) {
            variableTreeNode = new AEBPVariableTreeNode(variableNeighbour, next, isExhausted);
            next.addChild(variableTreeNode);
            fromNodeToPartition.put(variableNeighbour, variableTreeNode);
        } else {
            variableTreeNode = (AEBPVariableTreeNode) fromNodeToPartition.get(variableNeighbour);
        }
        for (Factor factorNeighbour : model.getEntireGraph().getNeighbors(variableNeighbour)) {
            if (!visited.contains(factorNeighbour)) {
                AEBPFactorTreeNode factorTreeNode = new AEBPFactorTreeNode(factorNeighbour, variableTreeNode, isExhausted);
                // variableTreeNode.addChild(factorTreeNode);
                visited.add(factorNeighbour);
                queue.add(factorTreeNode);
            }
        }
    }
    return next;
}
Also used : Variable(com.sri.ai.praise.core.representation.interfacebased.factor.api.Variable) AEBPFactorTreeNode(com.sri.ai.praise.core.inference.byinputrepresentation.interfacebased.core.exactbp.anytime.gabriel.aebptree.AEBPFactorTreeNode) AEBPVariableTreeNode(com.sri.ai.praise.core.inference.byinputrepresentation.interfacebased.core.exactbp.anytime.gabriel.aebptree.AEBPVariableTreeNode) Factor(com.sri.ai.praise.core.representation.interfacebased.factor.api.Factor) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

AEBPFactorTreeNode (com.sri.ai.praise.core.inference.byinputrepresentation.interfacebased.core.exactbp.anytime.gabriel.aebptree.AEBPFactorTreeNode)2 AEBPVariableTreeNode (com.sri.ai.praise.core.inference.byinputrepresentation.interfacebased.core.exactbp.anytime.gabriel.aebptree.AEBPVariableTreeNode)1 Factor (com.sri.ai.praise.core.representation.interfacebased.factor.api.Factor)1 Variable (com.sri.ai.praise.core.representation.interfacebased.factor.api.Variable)1 NoSuchElementException (java.util.NoSuchElementException)1