Esempio n. 1
0
  public static void main(String[] args) {
    BDDFactory bdd = init(1000000, 100000);

    System.out.println("One: " + CUDDFactory.one);
    System.out.println("Zero: " + CUDDFactory.zero);

    BDDDomain[] doms = bdd.extDomain(new int[] {50, 10, 15, 20, 15});

    BDD b = bdd.one();
    for (int i = 0; i < doms.length - 1; ++i) {
      b.andWith(doms[i].ithVar(i));
    }

    for (int i = 0; i < bdd.numberOfDomains(); ++i) {
      BDDDomain d = bdd.getDomain(i);
      int[] ivar = d.vars();
      System.out.print("Domain #" + i + ":");
      for (int j = 0; j < ivar.length; ++j) {
        System.out.print(' ');
        System.out.print(j);
        System.out.print(':');
        System.out.print(ivar[j]);
      }
      System.out.println();
    }

    BDDPairing p = bdd.makePair(doms[2], doms[doms.length - 1]);
    System.out.println("Pairing: " + p);

    System.out.println("Before replace(): " + b);
    BDD c = b.replace(p);
    System.out.println("After replace(): " + c);

    c.printDot();
  }
Esempio n. 2
0
  /**
   * Builds a BDD which is true for all the possible assignments to the variable blocks that makes
   * the blocks equal.
   *
   * <p>Compare to fdd_equals/fdd_equ.
   *
   * @param that
   * @return BDD
   */
  public BDD buildEquals(BDDDomain that) {
    if (!this.size().equals(that.size())) {
      throw new BDDException(
          "Size of "
              + this
              + " != size of that "
              + that
              + "( "
              + this.size()
              + " vs "
              + that.size()
              + ")");
    }

    BDDFactory factory = getFactory();
    BDD e = factory.universe();

    int[] this_ivar = this.vars();
    int[] that_ivar = that.vars();

    for (int n = 0; n < this.varNum(); n++) {
      BDD a = factory.ithVar(this_ivar[n]);
      BDD b = factory.ithVar(that_ivar[n]);
      a.biimpWith(b);
      e.andWith(a);
    }

    return e;
  }