* @param ssbn
* @throws Exception : this exception is inherent from the {@link ProbabilisticNetwork#updateEvidences()}
*/
public void compileSSBNAndPropagateFindings(SSBN ssbn) throws Exception {
// use DMP instead of Junction tree.
IInferenceAlgorithm dmp = getBNInferenceAlgorithm();
// if we are calling this algorithm from GUI, set up the whole BN module instead of just the inference algorithm
NetworkWindow bnModule = null; // this is going to hold the BN module (NetworkWindow is a UnBBayesModule)
if (getMediator() != null) {
// Instantiate a new BN module
bnModule = new NetworkWindow(ssbn.getNetwork());
// extract controller from BN module
NetworkController controller = bnModule.getController();
dmp.setMediator(controller);
controller.setInferenceAlgorithm(dmp);
// Make sure the tree (JTree in the left side of compilation panel) is updated with the network changes, if there is any.
controller.getScreen().getEvidenceTree().resetTree();
}
if (this.isToCompileFinalSSBN() ) {
// this is the actual BN (i.e. SSBN) to compile
Network bn = ssbn.getNetwork();
// If it is a SingleEntityNetwork, make sure all variables are properly initialized
if (bn instanceof SingleEntityNetwork) {
SingleEntityNetwork singleEntityNetwork = (SingleEntityNetwork) bn;
singleEntityNetwork.resetNodesCopy();
singleEntityNetwork.resetEvidences();
}
// actually compile network using dmp
dmp.setNetwork(bn);
dmp.run();
if (dmp.getNetwork() != null && (dmp.getNetwork() instanceof Network)) {
// dmp creates new network. SSBN must be linked to the new network
ssbn.setNetwork((Network) dmp.getNetwork());
}
// if we instantiated a BN module previously, then change it to the "compiled" view instead of "edit" view
if (bnModule != null) {
bnModule.changeToPNCompilationPane();