示例#1
0
文件: IJGP.java 项目: acares/ProbCog
 public Cluster getReducedCluster(HashSet<BeliefNode> nodes) throws CloneNotSupportedException {
   // deletes all functions and arcs in the cluster whose scope
   // contains the given nodes
   Cluster redCluster = this.copy();
   for (BeliefNode bn : nodes) {
     HashSet<BeliefNode> foo = (HashSet<BeliefNode>) cpts.clone();
     for (BeliefNode n : foo) {
       BeliefNode[] domProd = n.getCPF().getDomainProduct();
       /*
        * if (bn.equals(n)){ redCluster.cpts.remove(n); }
        */
       for (int i = 0; i < domProd.length; i++) {
         if (bn.equals(domProd[i])) {
           redCluster.cpts.remove(n);
           break;
         }
       }
     }
     for (MessageFunction m : ((HashSet<MessageFunction>) functions.clone())) {
       if (m.scope.contains(bn)) redCluster.functions.remove(m);
     }
   }
   return redCluster;
 }