Package org.integratedmodelling.riskwiz.pt

Examples of org.integratedmodelling.riskwiz.pt.CPT


        }

    }

    public CPT createCPT() {
        CPT cpt = new CPT(domain, domainProduct);

        if (!isScalar) {
            int[] structureIterator = this.index2addr(0);
            boolean done = false;

            while (!done) {
                Dirichlet dist = getValue(structureIterator);

                for (int domIndex = 0; domIndex < domain.getOrder(); domIndex++) {
                    cpt.setValue(
                            TableFactory.getCptReference(domIndex,
                            structureIterator),
                            dist.getExpectedVal(domIndex));
                }
                done = this.addOne(structureIterator);
            }
        } else {
            Dirichlet dist = multiarray[0];

            for (int domIndex = 0; domIndex < domain.getOrder(); domIndex++) {
                cpt.setValue(domIndex, dist.getExpectedVal(domIndex));
            }
        }

        return cpt;
    }
View Full Code Here


        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);
            }
        }

        policyHash.put(dom, policy);
        System.out.println(
                dom.getName() + ":here it is\n" + policy.toString() + "\n");
        utilPotential = PT.divideSimTables(utilPotential, probPotential);
        return new JTPotential(probPotential, utilPotential);

    }
View Full Code Here

        }
        return pt;
    }

    private static CPT funcTableToCPT(DiscreteDomain dom, PT funcTable) {
        CPT cpt = new CPT(dom, funcTable.getDomainProduct());

        cpt.setAll(0.0);

        int[] structureIterator = funcTable.index2addr(0);
        boolean done = false;

        while (!done) {
            int domIndex = (int) funcTable.getValue(structureIterator);

            cpt.setValue(
                    TableFactory.getCptReference(domIndex, structureIterator), 1);
            done = funcTable.addOne(structureIterator);
        }

        return cpt;
View Full Code Here

    private static CPT discretizeContCPF(IFunction function,
            DiscretizationDomainMap dmap, BeliefNetwork bn)
        throws ParseException {

        CPT cPT = new CPT(dmap.getDiscretizedDomain(function.getDomain(), bn),
                dmap.getDiscretizedParentDomains());

        int[] productStructureIterator = cPT.index2addr(0);
        boolean done = false;

        while (!done) {
            setOneOutputProbabilisticTableValue(bn, productStructureIterator,
                    cPT, function, dmap);
            done = cPT.addOne(productStructureIterator);
        }
        return cPT;

    }
View Full Code Here

    }

    public static CPT convertTabularToCPT(TabularFunction cpf) {

        CPT pT = new CPT((DiscreteDomain) cpf.getDomain(),
                cpf.getParentsDomains());
    
        for (int i = 0; i < cpf.size(); i++) {
            double value = (Double) cpf.getValue(i);

            pT.setValue(i, value);
        }

        return pT;

    }
View Full Code Here

                // get probabilities for parents effects when act independently
                // and multiply them
                double probDistValue = 1;

                for (int i = 0; i < parentDists.size(); i++) {
                    CPT dist = parentDists.get(i);
                    int[] addres = new int[2];

                    addres[0] = domIndex;
                    addres[1] = conditionsIterator[i];
                    probDistValue *= dist.getValue(addres);
                }

                // set the probability density value
                cpf.setValue(map.getCPTAddress(domIndex, conditionsIterator),
                        probDistValue - previousValue);
View Full Code Here

    private void resetNoisyTable() {
        parentEffects = new Vector<CPT>();
        leack = new double[dom.getOrder()];

        for (Domain pDomain : parentDomains) {
            CPT c = new CPT(dom,
                    DomainFactory.createDomainProduct((DiscreteDomain) pDomain));

            parentEffects.add(c);
      
        }
View Full Code Here

    }

    private CPT toDistribution(CPT cpt) {
        DiscreteDomain dom = cpt.getDomain();
        DiscreteDomain parentDom = cpt.getParentsDomains().firstElement();
        CPT distribution = new CPT(dom, cpt.getParentsDomains());

        for (int parentIndex = 0; parentIndex < parentDom.getOrder(); parentIndex++) {
            double sum = 0;

            for (int domIndex = dom.getOrder() - 1; domIndex >= 0; domIndex--) {
                int[] addres = new int[2];

                addres[0] = domIndex;
                addres[1] = parentIndex;
                sum += cpt.getValue(addres);
                distribution.setValue(addres, sum);
            }
        }

        return distribution;
    }
View Full Code Here

TOP

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

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.