@SuppressWarnings("unused")
 private void gcCallback(Integer pre, BDDFactory.GCStats stats) {
   if (logger.wouldBeLogged(LOG_LEVEL)) {
     switch (pre) {
       case 1:
         logger.log(LOG_LEVEL, "Starting BDD Garbage Collection");
         break;
       case 0:
         logger.log(LOG_LEVEL, "Finished BDD", stats);
         break;
       default:
         logger.log(LOG_LEVEL, stats);
     }
   }
 }
 @SuppressWarnings("unused")
 private void reorderCallback(Integer pre, BDDFactory.ReorderStats stats) {
   if (logger.wouldBeLogged(LOG_LEVEL)) {
     switch (pre) {
       case 1:
         logger.log(LOG_LEVEL, "Starting BDD Reordering");
         break;
       case 0:
         logger.log(LOG_LEVEL, "Finished BDD Reordering:", stats);
         break;
       default:
         logger.log(LOG_LEVEL, stats);
     }
   }
 }
  JavaBDDRegionManager(String bddPackage, Configuration config, LogManager pLogger)
      throws InvalidConfigurationException {
    config.inject(this);
    logger = pLogger;
    if (initTableRatio <= 0 || initTableRatio >= 1) {
      throw new InvalidConfigurationException(
          "Invalid value "
              + initTableRatio
              + " for option bdd.javabdd.initTableRatio, needs to be between 0 and 1.");
    }
    if (initTableSize == 0) {
      // JFactory uses 5 ints of 4 byte sizes for each entry in the BDD table
      double size = Runtime.getRuntime().maxMemory() * initTableRatio / 5 / 4;
      initTableSize = (size > Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int) size;
      logger.log(Level.CONFIG, "Setting value of bdd.javabdd.initTableSize to", initTableSize);
    }

    if (cacheRatio < 0) {
      throw new InvalidConfigurationException(
          "Invalid value "
              + cacheRatio
              + " for option bdd.javabdd.cacheRatio, cannot be negative.");
    }
    if (cacheSize == 0) {
      cacheSize = (int) (initTableSize * cacheRatio);
    }
    factory = BDDFactory.init(bddPackage.toLowerCase(), initTableSize, cacheSize);

    // register callbacks for logging
    try {
      Method gcCallback =
          JavaBDDRegionManager.class.getDeclaredMethod(
              "gcCallback", Integer.class, BDDFactory.GCStats.class);
      gcCallback.setAccessible(true);
      factory.registerGCCallback(this, gcCallback);

      Method resizeCallback =
          JavaBDDRegionManager.class.getDeclaredMethod(
              "resizeCallback", Integer.class, Integer.class);
      resizeCallback.setAccessible(true);
      factory.registerResizeCallback(this, resizeCallback);

      Method reorderCallback =
          JavaBDDRegionManager.class.getDeclaredMethod(
              "reorderCallback", Integer.class, BDDFactory.ReorderStats.class);
      reorderCallback.setAccessible(true);
      factory.registerReorderCallback(this, reorderCallback);

      // If we do not log, unregister the handlers to avoid the cost of
      // calling them with reflection.
      // Registering and immediately unregistering prevents the library
      // from printing stuff to stdout.
      if (!logger.wouldBeLogged(LOG_LEVEL)) {
        factory.unregisterGCCallback(this, gcCallback);
        factory.unregisterResizeCallback(this, resizeCallback);
        factory.unregisterReorderCallback(this, reorderCallback);
      }

    } catch (NoSuchMethodException e) {
      throw new AssertionError(e);
    }

    factory.setVarNum(varcount);
    factory.setCacheRatio(cacheRatio);

    trueFormula = new JavaBDDRegion(factory.one());
    falseFormula = new JavaBDDRegion(factory.zero());
  }