Package org.integratedmodelling.riskwiz.bn

Examples of org.integratedmodelling.riskwiz.bn.BNNode


        if (curNodeName == null) {
            throw new RuntimeException(
                    "Ill-formed <deterministic> tag, no names specified!");
        }

        BNNode curNode = graph.getBeliefNode(curNodeName);

        if (curNode == null) {
            throw new RuntimeException(
                    "Ill-formed <deterministic> tag, non-existant names specified!");
        }
View Full Code Here


        if (curNodeName == null) {
            throw new RuntimeException(
                    "Ill-formed <utility> tag, no names specified!");
        }

        BNNode curNode = graph.getBeliefNode(curNodeName);

        if (curNode == null) {
            throw new RuntimeException(
                    "Ill-formed <utility> tag, non-existant names specified!");
        }

        // Post processing
        for (Iterator i = parents.iterator(); i.hasNext();) {
            String parentNodeName = (String) i.next();

            graph.addEdge(parentNodeName, curNodeName);
        }

        IOUtil.parseCPFString(UtilitiesString,
                (TabularFunction) curNode.getFunction());

    }
View Full Code Here

    protected LinkedList<String> processParents(String parentsNames) {
        LinkedList<String> parents = new LinkedList<String>();
        Vector<String> parantsNamesVector = parseList(parentsNames);

        for (String parentName : parantsNamesVector) {
            BNNode parentNode = graph.getBeliefNode(parentName);

            if (parentNode == null) {
                throw new RuntimeException("Cannot resolve node " + parentName);
            }
            if (parentNode.isUtility()) {
                throw new RuntimeException(
                        "Utility nodes can never be parent nodes!");
            }
            if (parentNode != null) {
                parents.add(parentName);
View Full Code Here

            switch (node.getNodeType()) {
            case Node.ELEMENT_NODE:
                String name = node.getNodeName();

                if (name.equals("cpt")) {
                    BNNode bbnnode = visitStateNode(node,
                            BNNode.NodeType.probabilistic);

                    graph.addVertex(bbnnode);
                } else if (name.equals("noisymax")) {
                    BNNode bbnnode = visitStateNode(node,
                            BNNode.NodeType.noisymax);

                    graph.addVertex(bbnnode);
                } else if (name.equals("deterministic")) {
                    BNNode bbnnode = visitStateNode(node,
                            BNNode.NodeType.deterministic);

                    graph.addVertex(bbnnode);
                } else if (name.equals("utility")) {
                    BNNode bbnnode = visitStateNode(node,
                            BNNode.NodeType.utility);

                    graph.addVertex(bbnnode);
                } else if (name.equals("decision")) {
                    BNNode bbnnode = visitStateNode(node,
                            BNNode.NodeType.decision);

                    graph.addVertex(bbnnode);
                }
View Full Code Here

        return null;
    }

    protected BNNode visitStateNode(Node parent,
            BNNode.NodeType nodeType) {
        BNNode bbnnode = new BNNode("XXX", nodeType);

        bbnnode.setName(getElementID(parent));
        int max;
        NodeList l = parent.getChildNodes();

        if (l == null) {
            return null;
        }
        LinkedList<String> values = new LinkedList<String>();

        max = l.getLength();
        for (int i = 0; i < max; i++) {
            Node node = l.item(i);

            switch (node.getNodeType()) {
            case Node.ELEMENT_NODE:
                String name = node.getNodeName();

                if (name.equals("state")) { 
                    String value = getElementID(node);

                    if (value != null) {
                        values.add(value);
                    }
                } else if (name.equals("property")) { 
                    String elid = getElementID(node);
                    String elval = getElementValue(node);

                    bbnnode.setProperty(elid, elval);
         
                }
        
                break;

            case Node.DOCUMENT_NODE:
            case Node.COMMENT_NODE:
            case Node.TEXT_NODE:
                // Ignore this
                break;

            default:
                if (Setting.DEBUG) {
                    System.out.println("Unhandled node " + node.getNodeName());
                }
            }
        }

        LabelDomain dom = null;

        if (!(nodeType == BNNode.NodeType.utility)) {

            String[] valArr = new String[values.size()];

            values.toArray(valArr);
            dom = new LabelDomain(bbnnode.getName(), valArr);
            bbnnode.setDomain(dom);
        }

        return bbnnode;
    }
View Full Code Here

        if (curNodeName == null) {
            throw new RuntimeException(
                    "Ill-formed <cpt> tag, no names specified!");
        }

        BNNode curNode = graph.getBeliefNode(curNodeName);

        if (curNode == null) {
            throw new RuntimeException(
                    "Ill-formed <cpt> tag, non-existant names specified!");
        }

        if (CPTString == null) {
            throw new RuntimeException(
                    "Ill-formed <cpt> tag, no probabilities specified!");
        }

        // Post processing
        if (parents != null) {
            for (Iterator i = parents.iterator(); i.hasNext();) {
                String parentNodeName = (String) i.next();

                graph.addEdge(parentNodeName, curNodeName);
            }
        }

        // int domainOrder= curNode.getDomain().getOrder();
  
        IOUtil.parseTableString(CPTString,
                (TabularFunction) curNode.getFunction());
    
    }
View Full Code Here

    }

    @Override
  public void setDecision(String nodeName, int valueIndex) {
        BNNode node = bn.getBeliefNode(nodeName);

        setDecision(node, valueIndex);
    }
View Full Code Here

        if (curNodeName == null) {
            throw new RuntimeException(
                    "Ill-formed <cpt> tag, no names specified!");
        }

        BNNode curNode = graph.getBeliefNode(curNodeName);

        if (curNode == null) {
            throw new RuntimeException(
                    "Ill-formed <cpt> tag, non-existant names specified!");
        }

        if (ParamString == null) {
            throw new RuntimeException(
                    "Ill-formed <cpt> tag, no probabilities specified!");
        }

        // Post processing
        if (parents != null) {
            for (Iterator i = parents.iterator(); i.hasNext();) {
                String parentNodeName = (String) i.next();

                graph.addEdge(parentNodeName, curNodeName);
            }
        }

        // int domainOrder= curNode.getDomain().getOrder();
        IOUtil.parseNoisyParams(ParamString, curNode.getNoisyT());
   
        curNode.setFunction(curNode.getNoisyT().toCPF());
    }
View Full Code Here

        retraction = true;
    }

    @Override
  public void setDecision(String nodeName, String value) {
        BNNode node = bn.getBeliefNode(nodeName);

        setDecision(node, value);
    }
View Full Code Here

        retraction = true;
    }

    @Override
  public void setOptimalPolicy(String nodeName) {
        BNNode node = bn.getBeliefNode(nodeName);

        setOptimalPolicy(node);

    }
View Full Code Here

TOP

Related Classes of org.integratedmodelling.riskwiz.bn.BNNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.