/** * Sets the evidence at time T. * @param data a {@code List} of {@link DynamicDataInstance} objects. */ public void setEvidenceTimeT(List<DynamicDataInstance> data) { if (data.size()>nRepetitions) throw new IllegalArgumentException("The size of the data is bigger than the number of repetitions"); this.cloneNodesTimeT.forEach( node -> node.setAssignment(data.get(0))); for (int i = 0; i < nRepetitions && i<data.size(); i++) { final int slice = i; this.plateuNodesTimeT.get(i).forEach(node -> { node.setAssignment(data.get(slice)); node.setActive(true); //No barrent nodes if (!node.isObserved() && node.getChildren().isEmpty()) node.setActive(false); }); } for (int i = data.size(); i < nRepetitions; i++) { this.plateuNodesTimeT.get(i).forEach(node -> { node.setAssignment(null); node.setActive(false); }); } }
public void setConstraint(Node node){ for ( Constraint constraint : this.constraintMap.get(node.getMainVariable())) { Optional<Node> optional = node.getParents().stream().filter(nodeParent -> eu.amidst.core.constraints.Constraints.match(node.getPDist(), nodeParent.getMainVariable(), constraint)).findFirst(); if (!optional.isPresent()) throw new IllegalStateException("No constraint for the given parameter"); Node nodeParent = optional.get(); nodeParent.setActive(false); eu.amidst.core.constraints.Constraints.fixValue(nodeParent.getQDist(), constraint.getValue()); } } }
EF_UnivariateDistribution uni = temporalClone.getDistributionType().newUnivariateDistribution().toEFUnivariateDistribution(); Node node = new Node(uni); node.setActive(false); cloneVariablesToNode.put(temporalClone, node); return node;
/** * {@inheritDoc} */ @Override public void setModel(DynamicBayesianNetwork model_) { model = model_; ef_model = new EF_DynamicBayesianNetwork(this.model); this.vmpTime0.setEFModel(ef_model.getBayesianNetworkTime0()); nodesTimeT = this.ef_model.getBayesianNetworkTimeT().getDistributionList() .stream() .map(dist -> new Node(dist)) .collect(Collectors.toList()); nodesClone = this.ef_model.getBayesianNetworkTime0().getDistributionList() .stream() .map(dist -> { Variable temporalClone = this.model.getDynamicVariables().getInterfaceVariable(dist.getVariable()); EF_UnivariateDistribution uni = temporalClone.getDistributionType().newUnivariateDistribution().toEFUnivariateDistribution(); Node node = new Node(uni); node.setActive(false); return node; }) .collect(Collectors.toList()); List<Node> allNodes = new ArrayList(); allNodes.addAll(nodesTimeT); allNodes.addAll(nodesClone); this.vmpTimeT.setNodes(allNodes); this.vmpTimeT.updateChildrenAndParents(); }
@Override public void open(Configuration parameters) throws Exception { super.open(parameters); svb = Serialization.deserializeObject(parameters.getBytes(SVB, null)); this.prior = Serialization.deserializeObject(parameters.getBytes(PRIOR, null)); svb.initLearning(); this.svb.updateNaturalParameterPrior(prior); this.svb.updateNaturalParameterPosteriors(prior); svb.getPlateuStructure().getNonReplictedNodes().forEach(node -> node.setActive(false)); }
svb.getPlateuStructure().getNonReplictedNodes().forEach(node -> node.setActive(false)); svb.setOutput(false); SVB.BatchOutput outElbo = svb.updateModelOnBatchParallel(dataBatch); .getNonReplictedNodes() .forEach(node -> node.setActive(this.idenitifableModelling.isActiveAtEpoch(node.getMainVariable(), superstep)) );
svb.getPlateuStructure().getNonReplictedNodes().forEach(node -> node.setActive(false)); svb.setOutput(false); SVB.BatchOutput outElbo = svb.updateModelOnBatchParallel(dataBatch); .getNonReplictedNodes() .forEach(node -> node.setActive(this.idenitifableModelling.isActiveAtEpoch(node.getMainVariable(), superstep)) );
svb.getPlateuStructure().getNonReplictedNodes().forEach(node -> node.setActive(false)); svb.setOutput(false); SVB.BatchOutput outElbo = svb.updateModelOnBatchParallel(dataBatch); .getNonReplictedNodes() .filter(node -> this.idenitifableModelling.isActiveAtEpoch(node.getMainVariable(), superstep)) .forEach(node -> node.setActive(true)); svb.getPlateuStructure().getNonReplictedNodes().forEach(node -> node.setActive(true));
svb.getPlateuStructure().getNonReplictedNodes().forEach(node -> node.setActive(false)); SVB.BatchOutput outElbo = svb.updateModelOnBatchParallel(dataBatch); .getNonReplictedNodes() .filter(node -> this.idenitifableModelling.isActiveAtEpoch(node.getMainVariable(), superstep)) .forEach(node -> node.setActive(true)); svb.getPlateuStructure().getNonReplictedNodes().forEach(node -> node.setActive(true));