Beispiel #1
0
  protected static ArrayList<Clique> getMaxCliques(ArrayList<Clique> cliques) {
    Clique c1, c2;
    ArrayList<Clique> maxCliques = new ArrayList<Clique>();
    maxCliques.addAll(cliques);

    for (int i = 0; i < cliques.size(); i++) {
      c1 = cliques.get(i);

      for (int j = 0; j < cliques.size(); j++) {
        c2 = cliques.get(j);
        if ((i != j) && (c1.isSubSet(c2))) {
          maxCliques.remove(c1);
        }
      }
    }

    return maxCliques;
  }
Beispiel #2
0
  protected static void assignPotentials(BruseNetwork network, ArrayList<Clique> cliques) {
    Clique clique = null, bestClique = null;
    BruseNode node = null;
    BruseTable table = null;

    // Uniquely assign a potential to a clique that covers the domain of the potential
    // If there are several qualifying cliques we choose the first clique
    // TODO: Try a different hueristic where we assign the potential to the clique
    // with the min domain difference.
    // Ex: pot(A,B) matches Clique(A,B,C,D) and Clique(A,B,E)
    //		choose Clique(A,B,E) because it has the min domain difference
    for (int i = 0; i < network.getAllNodes().size(); i++) {
      node = network.getAllNodes().get(i);
      table = node.getTable();

      for (int j = 0; j < cliques.size(); j++) {
        clique = cliques.get(j);

        if (clique.containsNodes(
            table.getVariableNames())) { // getMembers().containsAll(table.getVariables())) {
          if ((bestClique == null)
              || (bestClique.getPotentials().size() > clique.getPotentials().size())) {
            bestClique = clique;
          }
          // clique.addPotential(table);
          // break;
        }
      }
      bestClique.addPotential(table);
      bestClique = null;
    }

    // all cliques now have initial potentials set - this is for resetting potentials
    for (int i = 0; i < cliques.size(); i++) {
      clique = cliques.get(i);
      clique.setInitPotentials();
    }
  }