@Override public CompoundVector reduce(CompoundVector value1, CompoundVector value2) throws Exception { /* value2.sum(value1); return value2; */ CompoundVector newValue = Serialization.deepCopy(value1); newValue.sum(value2); return newValue; } }
@Override public CompoundVector reduce(CompoundVector value1, CompoundVector value2) throws Exception { /* value2.sum(value1); return value2; */ CompoundVector newValue = Serialization.deepCopy(value1); newValue.sum(value2); return newValue; } }
/** * Creates a new FactoredFrontierForDBN object. * @param inferenceAlgorithm an {@link InferenceAlgorithm} object. */ public FactoredFrontierForDBN(InferenceAlgorithm inferenceAlgorithm){ infAlgTime0 = inferenceAlgorithm; infAlgTimeT = Serialization.deepCopy(inferenceAlgorithm); timeID = -1; this.setSeed(0); }
@Override public CompoundVector reduce(CompoundVector value1, CompoundVector value2) throws Exception { /* value2.sum(value1); return value2; */ CompoundVector newValue = Serialization.deepCopy(value1); newValue.sum(value2); return newValue; } }
@Override public CompoundVector reduce(CompoundVector value1, CompoundVector value2) throws Exception { /* value2.sum(value1); return value2; */ CompoundVector newValue = Serialization.deepCopy(value1); newValue.sum(value2); return newValue; } }
/** * Returns the Bayesian network at Time 0. * @return a {@link BayesianNetwork} object. */ public BayesianNetwork toBayesianNetworkTime0(){ DAG dagTime0 = this.getDynamicDAG().toDAGTime0(); BayesianNetwork bnTime0 = new BayesianNetwork(dagTime0); for (Variable dynamicVar : this.getDynamicVariables()) { Variable staticVar = dagTime0.getVariables().getVariableByName(dynamicVar.getName()); ConditionalDistribution deepCopy = Serialization.deepCopy(this.getConditionalDistributionTime0(dynamicVar)); deepCopy.setVar(staticVar); List<Variable> newParents = deepCopy.getConditioningVariables().stream().map(var -> dagTime0.getVariables().getVariableByName(var.getName())).collect(Collectors.toList()); deepCopy.setConditioningVariables(newParents); bnTime0.setConditionalDistribution(staticVar,deepCopy); } return bnTime0; }
/** * Returns the Bayesian network at Time T. * @return a {@link BayesianNetwork} object. */ public BayesianNetwork toBayesianNetworkTimeT(){ DAG dagTimeT = this.getDynamicDAG().toDAGTimeT(); BayesianNetwork bnTimeT = new BayesianNetwork(dagTimeT); for (Variable dynamicVar : this.getDynamicVariables()) { Variable staticVar = dagTimeT.getVariables().getVariableByName(dynamicVar.getName()); ConditionalDistribution deepCopy = Serialization.deepCopy(this.getConditionalDistributionTimeT(dynamicVar)); deepCopy.setVar(staticVar); List<Variable> newParents = deepCopy.getConditioningVariables().stream().map(var -> dagTimeT.getVariables().getVariableByName(var.getName())).collect(Collectors.toList()); deepCopy.setConditioningVariables(newParents); bnTimeT.setConditionalDistribution(staticVar,deepCopy); } return bnTimeT; }
this.parallelVBTime0.setPlateuStructure(Serialization.deepCopy(plateuStructure)); if (transitionMethod!=null) this.parallelVBTime0.setTransitionMethod(Serialization.deepCopy(transitionMethod)); this.parallelVBTime0.setLocalThreshold(this.localThreshold); this.parallelVBTime0.setMaximumLocalIterations(this.maximumLocalIterations); this.svbTimeT.setPlateuStructure(Serialization.deepCopy(plateuStructure)); if (transitionMethod!=null) this.svbTimeT.setTransitionMethod(Serialization.deepCopy(transitionMethod)); this.svbTimeT.getPlateuStructure().getVMP().setMaxIter(this.maximumLocalIterations); this.svbTimeT.getPlateuStructure().getVMP().setThreshold(this.localThreshold);
Variables variables = Serialization.deepCopy(this.unfoldedStaticModel.getVariables()); Variable currentVar; if (variables.getVariableByName(MAPvarName + "_t" + Integer.toString(t))!=null) {
DynamicDAG dynamicDAG = Serialization.deepCopy(dynamicNB.getDynamicDAG());
CompoundVector referencePrior = Serialization.deepCopy(updatedPosterior); referencePrior.multiplyBy(factor); svb.updateNaturalParameterPrior(referencePrior); this.prior=Serialization.deepCopy(updatedPosterior); this.svb.updateNaturalParameterPrior(prior); if (randomStart) { this.svb.getPlateuStructure().setSeed(this.svb.getSeed()); this.svb.getPlateuStructure().resetQs(); initialPosterior = Serialization.deepCopy(this.svb.getPlateuStructure().getPlateauNaturalParameterPosterior()); initialPosterior.sum(prior); }else{ initialPosterior=Serialization.deepCopy(svb.getNaturalParameterPrior());
DynamicDAG dynamicDAG = Serialization.deepCopy(dynamicNB.getDynamicDAG());
this.prior=Serialization.deepCopy(updatedPrior); this.svb.updateNaturalParameterPrior(prior); if (randomStart) { this.svb.getPlateuStructure().setSeed(this.svb.getSeed()); this.svb.getPlateuStructure().resetQs(); initialPosterior = Serialization.deepCopy(this.svb.getPlateuStructure().getPlateauNaturalParameterPosterior()); initialPosterior.sum(prior); }else{ initialPosterior=Serialization.deepCopy(svb.getNaturalParameterPrior());
basedELBO = svb.getPlateuStructure().getNonReplictedNodes().mapToDouble(node -> svb.getPlateuStructure().getVMP().computeELBO(node)).sum(); }else{ this.prior=Serialization.deepCopy(updatedPrior); this.svb.updateNaturalParameterPrior(prior); if (randomStart) { this.svb.getPlateuStructure().setSeed(this.svb.getSeed()); this.svb.getPlateuStructure().resetQs(); initialPosterior = Serialization.deepCopy(this.svb.getPlateuStructure().getPlateauNaturalParameterPosterior()); initialPosterior.sum(prior); }else{ initialPosterior=Serialization.deepCopy(svb.getNaturalParameterPrior());
staticVar = variables.getVariableByName(dynamicVariables.getVariableById(j).getName() + "_t0"); cdist = Serialization.deepCopy(dbn.getConditionalDistributionsTime0().get(j)); cdist.getConditioningVariables().stream().forEachOrdered(cdvar -> parentList.add(variables.getVariableByName(cdvar.getName() + "_t0"))); staticVar = variables.getVariableByName(dynamicVariables.getVariableById(j).getName() + "_t" + Integer.toString(final_i)); cdist = Serialization.deepCopy(dbn.getConditionalDistributionsTimeT().get(j)); cdist.getConditioningVariables().stream().forEachOrdered(cdvar -> { parentList.add(((cdvar.isInterfaceVariable() || (cdvar.getName().contains("_t"))) ?
basedELBO = svb.getPlateuStructure().getNonReplictedNodes().mapToDouble(node -> svb.getPlateuStructure().getVMP().computeELBO(node)).sum(); }else{ this.prior=Serialization.deepCopy(updatedPosterior); this.svb.updateNaturalParameterPrior(prior); if (randomStart) { this.svb.getPlateuStructure().setSeed(this.svb.getSeed()); this.svb.getPlateuStructure().resetQs(); initialPosterior = Serialization.deepCopy(this.svb.getPlateuStructure().getPlateauNaturalParameterPosterior()); initialPosterior.sum(prior); }else{ initialPosterior=Serialization.deepCopy(svb.getNaturalParameterPrior());
CompoundVector newVector = Serialization.deepCopy(updatedPrior); newVector.substract(partialVectors.get(batchID)); this.svb.updateNaturalParameterPrior(newVector);
basedELBO = svb.getPlateuStructure().getNonReplictedNodes().mapToDouble(node -> svb.getPlateuStructure().getVMP().computeELBO(node)).sum(); }else{ this.prior=Serialization.deepCopy(updatedPosterior); this.svb.updateNaturalParameterPrior(prior); if (randomStart) { this.svb.getPlateuStructure().setSeed(this.svb.getSeed()); this.svb.getPlateuStructure().resetQs(); initialPosterior = Serialization.deepCopy(this.svb.getPlateuStructure().getPlateauNaturalParameterPosterior()); initialPosterior.sum(prior); }else{ initialPosterior=Serialization.deepCopy(svb.getNaturalParameterPrior());
List<Variable> originalVars = Serialization.deepCopy(vars.getListOfVariables());
CompoundVector newVector = Serialization.deepCopy(updatedPrior); newVector.substract(partialVectors.get(dataBatch.getBatchID())); this.svb.updateNaturalParameterPrior(newVector);