Package org.integratedmodelling.riskwiz.pt

Examples of org.integratedmodelling.riskwiz.pt.PT


        for (BNNode node : bNNodes) {
            if (node.isNature() || node.isDecision()) {
                ClusterBundle cbundle = clusterHash.get(node);
                SJTVertex jtcluster = cbundle.jtcluster;
                FMarginalizationMap mfmap = cbundle.mfmap;
                PT likelihood = new PT(mfmap.getProjectionDomainProduct());

                PT.marginalizeDomainsFast(likelihood,
                        jtcluster.getPotential().getProbabilityPotential(),
                        mfmap);
                likelihood.normalize();
                node.setMarginal(likelihood);
            } else if (node.isUtility()) {
                ClusterBundle cbundle = clusterHash.get(node);
                SJTVertex jtcluster = cbundle.jtcluster;
                PT utility = jtcluster.getPotential().getProbabilityPotential().clone();

                utility.normalize();
                utility.multiplyBySubtable(node.getDiscreteCPT(), cbundle.fopmap);
                node.setMarginalUtility(utility.sum());

            }

        }
    }
View Full Code Here


            SJTVertex parentCluster = assignParentCluster(node);

            if (node.isNature()) {
        
                JTPotential clusterPT = parentCluster.getPotential();
                PT nodePT = node.getDiscreteCPT();
                FastMap2 fmap = clusterPT.createSubtableFastMap(nodePT);
                FMarginalizationMap mfmap = clusterPT.createFMarginalizationMap(
                        node.getDiscretizedDomain());
                FastMap2 liklihoodfmap = clusterPT.createSubtableFastMap(
                        DomainFactory.createDomainProduct(
View Full Code Here

    private void updateMarginals() {
        for (int i = 0; i < orderedNodes.size(); i++) {
            BNNode node = orderedNodes.elementAt(i);

            if (!node.hasEvidence()) {
                PT marginal = new PT(
                        DomainFactory.createDomainProduct(
                                node.getDiscretizedDomain()));
                double[] counter = node.getSamplesCounter();

                for (int j = 0; j < counter.length; j++) {
                    double val = counter[j];

                    marginal.setValue(j, val);
                }
                marginal.normalize();
                node.setMarginal(marginal);
            }
        }
    }
View Full Code Here

        this.precisionFactor = precisionFactor;
    }
 
    public boolean isConsistent(BNNode node, int aSample) {
        if (node.hasEvidence()) {
            PT evidence = node.getEvidence();      

            // int[] query = new int[1];
            // query[0]=aSample;
            // if(evidence.getValue(query)!=1.0){
            // return false;
            // } else {
            // return true;
            // } 
      
            if (evidence.getValue(aSample) != 1.0) {
                return false;
            } else {
                return true;
           
     
View Full Code Here

    // }

    public void createPotentials(Set<BNNode> nodeSet) {
        // this.nodeSet=nodeSet;
        this.domainProduct = DomainFactory.createDirectProduct(nodeSet);
        probabilityPotential = new PT(this.domainProduct);
        utilityPotential = new PT(this.domainProduct);
    }
View Full Code Here

    }

    public static JTPotential marginalizeDomainsFast(JTPotential pt,
            FMarginalizationMap mmap) {
    
        PT probPotential = new PT(mmap.getProjectionDomainProduct());

        PT.marginalizeDomainsFast(probPotential, pt.getProbabilityPotential(),
                mmap);
        PT weightedUtil = PT.multiplySimTables(pt.getUtilityPotential(),
                pt.getProbabilityPotential());
        PT utilPotentialTemp = new PT(mmap.getProjectionDomainProduct());

        PT.marginalizeDomainsFast(utilPotentialTemp, weightedUtil, mmap);
        PT utilPotential = PT.divideSimTables(utilPotentialTemp, probPotential);

        return new JTPotential(probPotential, utilPotential);
    }
View Full Code Here

        // System.out.print (dom.getName()+", ");
        // }
        // System.out.println();

        Vector<DiscreteDomain> projectionDomainProduct = mdmap.getProjectionDomainProduct();
        PT probPotential = new PT(projectionDomainProduct);
        PT utilPotential = new PT(projectionDomainProduct);

        System.out.println(
                "Utility Potential:\n" + pt.getUtilityPotential().toString()
                + "\n");

        CPT policy = new CPT(dom, parentDomains);

        policy.setAll(0);
   
        PT weightedUtil = PT.multiplySimTables(pt.getUtilityPotential(),
                pt.getProbabilityPotential());

        if (probPotential.isSingleValue) {
            int[] fiber = new int[] { -1 };
            int[] maxReference = weightedUtil.getMaxReference(fiber);
            double probScalar = pt.getProbabilityPotential().getValue(
                    maxReference);

            probPotential.setScalarValue(probScalar);
     
            utilPotential.setScalarValue(
                    weightedUtil.getValue(maxReference) / probScalar);
            policy.setValue(maxReference, 1);

        } else {
     
            int[] productStructureIterator = utilPotential.index2addr(0);
            boolean done = false;

            while (!done) {
                int[] fiber = mdmap.getFiber(productStructureIterator);
                int[] maxReference = weightedUtil.getMaxReference(fiber);
                double probVal = pt.getProbabilityPotential().getValue(
                        maxReference);

                probPotential.setValue(productStructureIterator, probVal);
                utilPotential.setValue(productStructureIterator,
                        weightedUtil.getValue(maxReference) / probVal);
                policy.setValue(maxReference, 1);
                done = utilPotential.addOne(productStructureIterator);
            }
        }
View Full Code Here

        return uT;
    }

    private static CPT convertTbaularDetFToCPT(BNNode node,
            BeliefNetwork bn) {
        PT funcTable = detFtoPT(node);

        return funcTableToCPT(node.getDiscretizedDomain(), funcTable);
   
    }
View Full Code Here

    }
 
    private static CPT convertContDeterministicToCPT(BNNode node,
            BeliefNetwork bn) throws Exception {

        PT funcTable = contDetFtoPT(node, bn);

        return funcTableToCPT(node.getDiscretizedDomain(), funcTable);
    }
View Full Code Here

        return funcTableToCPT(node.getDiscretizedDomain(), funcTable);
    }

    private static PT detFtoPT(BNNode node) {
        TabularFunction detf = (TabularFunction) node.getFunction();
        PT pT = new PT(detf.getParentsDomains());
        DiscreteDomain dom = (DiscreteDomain) node.getDomain();
   
        for (int i = 0; i < detf.size(); i++) {

            String sstate = (String) detf.getValue(i);
            int value = dom.findState(sstate);

            pT.setValue(i, value);

        }
   
        return pT;
    }
View Full Code Here

TOP

Related Classes of org.integratedmodelling.riskwiz.pt.PT

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.