public int[] solve() { // (0,1 or -1 for dont care)
    int rounds = 0, num_lits = cnf.num_lits;

    long starttime = System.currentTimeMillis();
    long endtime = starttime + maxtime;

    boolean[] minterm = new boolean[num_lits];
    int flips = Math.min(1000, 3 * num_lits);

    if (stack == null) {
      stack = new int[num_lits];
    }

    randomize(minterm);

    while (endtime > System.currentTimeMillis()) {
      rounds++;
      if (cnf.satisfies(minterm)) {
        JDDConsole.out.println("SAT/" + (System.currentTimeMillis() - starttime) + "ms");
        return toIntVector(minterm);
      }

      if ((rounds % flips) == 0) {
        randomize(minterm);
      } else {
        int choice = (Math.random() < p) ? choice = random(num_lits) : findLiteral(minterm);
        minterm[choice] = !minterm[choice];
      }
    }

    JDDConsole.out.println(
        "UNKNOWN(" + rounds + " rounds)/" + (System.currentTimeMillis() - starttime) + "ms");
    return null;
  }
  // -----------------------------------------------------------
  public static void main(String[] args) {
    try {
      Options.verbose = true; // DEBUG
      for (int i = 0; i < args.length; i++) {
        Automata agv = AutomataIO.loadXML(args[i]);

        long time = System.currentTimeMillis();
        BDDAutomata ba = new BDDAutomata(agv);
        DisjunctivePartitions part = new DisjunctivePartitions(ba);
        DisjunctiveSearch ds = new DisjunctiveSearch(part);

        int initial = BDDAutomataHelper.getI(ba);
        int x = ds.forward(initial);

        double states = BDDAutomataHelper.countStates(ba, x);
        part.cleanup();
        ds.cleanup();
        ba.cleanup();

        time = System.currentTimeMillis() - time;
        System.out.println("Found " + states + " states in " + args[i] + " in " + time + "ms.");
      }

    } catch (Exception exx) {
      exx.printStackTrace();
    }
  }
Example #3
0
  /** print out some info about the system and JVM etc. */
  public static void show() {
    Properties prop = System.getProperties();

    JDDConsole.out.println(
        "Using JDD build " + jdd.Version.build + " on " + (new Date()).toString() + "\n");
    JDDConsole.out.print(
        "Using " + prop.getProperty("java.vendor") + " JRE " + prop.getProperty("java.version"));
    String jit = prop.getProperty("java.compiler");
    if (jit != null) JDDConsole.out.print(", " + jit + " JIT in");
    JDDConsole.out.println(" " + prop.getProperty("java.vm.name"));

    JDDConsole.out.println(
        "OS "
            + prop.getProperty("os.name")
            + " on "
            + rt.availableProcessors()
            + " "
            + prop.getProperty("os.arch")
            + " CPU(s)");
    JDDConsole.out.print("Total JRE memory: ");
    Digits.printNumber1024(rt.maxMemory());
    JDDConsole.out.print(", memory currently reserved by the JRE: ");
    Digits.printNumber1024(usedMemory());
    JDDConsole.out.println("\n");
  }