/** * Sets the distribution of a normal variable with normal parents in the AMIDST model * from the corresponding distribution in the Hugin model. * @param huginVar the Hugin variable with the distribution to be converted. * @throws ExceptionHugin */ private void setNormal_NormalParents(Node huginVar) throws ExceptionHugin { int indexNode = this.huginBN.getNodes().indexOf(huginVar); Variable amidstVar = this.amidstBN.getVariables().getVariableById(indexNode); ConditionalLinearGaussian dist = this.amidstBN.getConditionalDistribution(amidstVar); double huginIntercept = ((ContinuousChanceNode)huginVar).getAlpha(0); dist.setIntercept(huginIntercept); NodeList huginParents = huginVar.getParents(); int numParents = huginParents.size(); double[] coefficients = new double[numParents]; for(int i=0;i<numParents;i++){ ContinuousChanceNode huginParent = (ContinuousChanceNode)huginParents.get(i); coefficients[i]= ((ContinuousChanceNode)huginVar).getBeta(huginParent,0); } dist.setCoeffParents(coefficients); double huginVariance = ((ContinuousChanceNode)huginVar).getGamma(0); dist.setVariance(huginVariance); }
/** * Sets the distribution of a normal variable with normal parents in the Hugin model from the corresponding * distribution in the AMIDST model. This method is designed for setting this distribution in a given position in * the list of distributions indexed by the multinomial parents assignments. * @param dist the AMIDST distribution to be converted. * @param i the position in which the distribution will be located. Note that <code>i</code> is equal to 0 when the * variable has no multinomial parents. * @throws ExceptionHugin */ private void setNormal_NormalParents(ConditionalLinearGaussian dist, int i) throws ExceptionHugin { Variable amidstVar = dist.getVariable(); List<Variable> normalParents = dist.getConditioningVariables(); int numNormalParents = normalParents.size(); Node huginVar = this.huginBN.getNodeByName(amidstVar.getName()); double variance = Math.pow(dist.getSd(), 2); ((ContinuousChanceNode)huginVar).setGamma(variance,i); double intercept = dist.getIntercept(); ((ContinuousChanceNode) huginVar).setAlpha(intercept, i); double[] coefficientsParents = dist.getCoeffParents(); for(int j=0;j<numNormalParents;j++) { ContinuousChanceNode huginParent = (ContinuousChanceNode)this.huginBN.getNodeByName(normalParents.get(j).getName()); ((ContinuousChanceNode)huginVar).setBeta(coefficientsParents[j],huginParent,i); } }
tempprob.getNormal_NormalParentsDistribution(0).setIntercept(0.0); tempprob.getNormal_NormalParentsDistribution(0).setCoeffForParent(temperatureBuilding,1.0); tempprob.getNormal_NormalParentsDistribution(0).setVariance(1); tempprob.getNormal_NormalParentsDistribution(1).setIntercept(10.0); tempprob.getNormal_NormalParentsDistribution(1).setCoeffForParent(temperatureBuilding,1.0); tempprob.getNormal_NormalParentsDistribution(1).setVariance(3); t1prob.setCoeffForParent(temperature[i], 1.0); t1prob.setIntercept(0.0); t1prob.setVariance(1.5); t2prob.setCoeffForParent(temperature[i], 1.0); t2prob.setIntercept(0.0); t2prob.setVariance(1.5);
dist.getNormal_NormalParentsDistribution(0).setCoeffParents(new double[]{1.0}); dist.getNormal_NormalParentsDistribution(0).setIntercept(10); dist.getNormal_NormalParentsDistribution(1).setCoeffParents(new double[]{1.0}); dist.getNormal_NormalParentsDistribution(1).setIntercept(10); dist.getNormal_NormalParentsDistribution(0).setCoeffParents(new double[]{1.0}); dist.getNormal_NormalParentsDistribution(0).setIntercept(0); dist.getNormal_NormalParentsDistribution(1).setCoeffParents(new double[]{1.0}); dist.getNormal_NormalParentsDistribution(1).setIntercept(0); dist.getNormal_NormalParentsDistribution(0).setCoeffParents(new double[]{1.0}); dist.getNormal_NormalParentsDistribution(0).setIntercept(-10); dist.getNormal_NormalParentsDistribution(1).setCoeffParents(new double[]{1.0}); dist.getNormal_NormalParentsDistribution(1).setIntercept(-10);
staticVarConDist = new ConditionalLinearGaussian(staticVariable, parentList); clg.setConditioningVariables(continuousParents); clg.setVar(staticVariable);
t1prob.setCoeffForParent(temperature, 1.0); t1prob.setIntercept(0.0); t1prob.setVariance(1.5); t2prob.setCoeffForParent(temperature, 1.0); t2prob.setIntercept(0.0); t2prob.setVariance(1.5); tempprobTimeT.getNormal_NormalParentsDistribution(0).setIntercept(0); tempprobTimeT.getNormal_NormalParentsDistribution(0).setCoeffForParent(temperature.getInterfaceVariable(),1); tempprobTimeT.getNormal_NormalParentsDistribution(0).setVariance(0.00001); t1probTimeT.setCoeffForParent(temperature, 1.0); t1probTimeT.setIntercept(0.0); t1probTimeT.setVariance(1.5); t2probTimeT.setCoeffForParent(temperature, 1.0); t2probTimeT.setIntercept(0.0); t2probTimeT.setVariance(1.5);
t1prob.setCoeffForParent(temperature, 1.0); t1prob.setIntercept(0.0); t1prob.setVariance(1.5); t2prob.setCoeffForParent(temperature, 1.0); t2prob.setIntercept(0.0); t2prob.setVariance(1.5);
/** * Sets the distribution of a normal variable with normal and multinomial parents in the AMIDST model from the * corresponding distribution in the Hugin model. * For each assignment of the multinomial parents, a CLG distribution is set. * @param huginVar the Hugin variable with the distribution to be converted. * @throws ExceptionHugin */ private void setNormal_MultinomialNormalParents(Node huginVar) throws ExceptionHugin { int indexNode = this.huginBN.getNodes().indexOf(huginVar); Variable amidstVar = this.amidstBN.getVariables().getVariableById(indexNode); Normal_MultinomialNormalParents dist = this.amidstBN.getConditionalDistribution(amidstVar); List<Variable> multinomialParents = dist.getMultinomialParents(); int numParentAssignments = MultinomialIndex.getNumberOfPossibleAssignments(multinomialParents); for(int i=0;i<numParentAssignments;i++) { ConditionalLinearGaussian normalNormal = dist.getNormal_NormalParentsDistribution(i); double huginIntercept = ((ContinuousChanceNode)huginVar).getAlpha(i); normalNormal.setIntercept(huginIntercept); List<Variable> normalParents = dist.getNormalParents(); int numParents = normalParents.size(); double[] coefficients = new double[numParents]; for(int j=0;j<numParents;j++){ String nameAmidstNormalParent = normalParents.get(j).getName(); ContinuousChanceNode huginParent = (ContinuousChanceNode)this.huginBN.getNodeByName(nameAmidstNormalParent); coefficients[j]= ((ContinuousChanceNode)huginVar).getBeta(huginParent,i); } normalNormal.setCoeffParents(coefficients); double huginVariance = ((ContinuousChanceNode)huginVar).getGamma(i); normalNormal.setVariance(huginVariance); } }
t1prob.setCoeffForParent(temperature, 1.0); t1prob.setIntercept(0.0); t1prob.setVariance(1.5); t2prob.setCoeffForParent(temperature, 1.0); t2prob.setIntercept(0.0); t2prob.setVariance(1.5);
tempTimeT.getNormal_NormalParentsDistribution(1).setIntercept(tempprob.getNormal(0).getMean()+10); tempTimeT.getNormal_NormalParentsDistribution(1).setCoeffForParent(temperature.getInterfaceVariable(),0.0); tempTimeT.getNormal_NormalParentsDistribution(1).setVariance(tempprob.getNormal(0).getVariance());