Example #1
0
 private static double iccUpdate(ItemSet itemSet, Set<ItemSet> itemSets, double bestItemScore) {
   if (itemSet.ub() >= bestItemScore) {
     itemSets.add(itemSet);
     DataSet covered = data.matching(itemSet);
     double itemSetValue = var(covered.getTuples().length, covered.y());
     if (itemSetValue > bestItemScore) {
       return itemSetValue;
     }
   }
   return bestItemScore;
 }
Example #2
0
  private static ItemSet icc() {
    ItemSet bestItemSet = null;
    int itemNumber = data.getTuples()[0].getItemSet().getLength();
    double bestItemScore = 0.0;
    Set<ItemSet> Q1 = new HashSet<ItemSet>();
    Set<ItemSet> B1 = new HashSet<ItemSet>(Q1);
    System.out.println("ICC init, with " + itemNumber + " items");
    for (int j = 0; j < itemNumber; j++) {
      ItemSet itemSet = getData().getBluePrint().getOneItemSet(j, itemNumber);
      double newScore = iccUpdate(itemSet, Q1, bestItemScore);
      if (newScore != bestItemScore) {
        bestItemSet = itemSet;
        bestItemScore = newScore;
      }
    }

    System.out.println("ICC init finished");

    Set<ItemSet> QVorige = new HashSet<ItemSet>();
    QVorige.addAll(Q1);

    Set<ItemSet> QVolgende = QVorige;

    while (!QVolgende.isEmpty()) {
      QVolgende = new HashSet<ItemSet>();
      for (ItemSet B : Q1) {
        for (ItemSet Q : QVorige) {
          int lastSetBit = 0;
          for (int i = Q.getBitSet().nextSetBit(0); i >= 0; i = Q.getBitSet().nextSetBit(i + 1))
            lastSetBit = i;

          if (lastSetBit < B.getBitSet().nextSetBit(0) && Q.ub() >= bestItemScore) {
            if (B.ub() < bestItemScore) B1.remove(B);
            else {
              ItemSet itemSet = Q.union(B);
              double newScore = iccUpdate(itemSet, QVolgende, bestItemScore);
              if (newScore != bestItemScore) {
                bestItemSet = itemSet;
                bestItemScore = newScore;
              }
            }
          }
        }
      }
      QVorige = QVolgende;
    }
    return bestItemSet;
  }