Search in sources :

Example 1 with AEBPVariableTreeNode

use of com.sri.ai.praise.core.inference.byinputrepresentation.interfacebased.core.exactbp.anytime.gabriel.aebptree.AEBPVariableTreeNode 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)1 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