Ejemplo n.º 1
0
	public static void dump(Search search) {
		solvingDiff.print();
		try {
			String targetName = search.getConfig().getStringArray("target")[0];
			String solverName = ProblemCompare.class.getSimpleName();
			String fileName = TablePrinter.TABLE_DIR + targetName + "." + solverName + ".ser";
			SolvingDiff.writeToFile(fileName, solvingDiff);
		} catch (IOException _) {
			throw new RuntimeException(TablePrinter.ERR_MSG);
		}
	}
Ejemplo n.º 2
0
	public ProblemCompare(PathCondition pc,SymbolicConstraintsGeneral scg) {
		p = pc;
		this.scg = scg;

		alwaysPrint = false;
		numSolvers = 7;
		solutions = new boolean[numSolvers];
		probs = new ProblemGeneral[numSolvers];
		intVars = new HashMap<String, SolverObjects>();
		realVars = new HashMap<String, SolverObjects>();

		probs[0] = new ProblemCoral(SolverKind.PSO_OPT4J, true);
		probs[1] = new ProblemCoral(SolverKind.PSO_OPT4J, false);
		probs[2] = new ProblemCoral(SolverKind.RANDOM, true);
		probs[3] = new ProblemCoral(SolverKind.RANDOM, false);
		probs[4] = new ProblemChoco();
		probs[5] = new ProblemCVC3();
		probs[6] = new ProblemYices();

		solvingDiff.init(numSolvers);
		ignoredSolvers = new boolean[numSolvers];
	}
Ejemplo n.º 3
0
	@Override
	public Boolean solve() {

		for (int i = 0; i < numSolvers; i++) {
			try{
				if (ignoredSolvers[i]) {
					System.out.println("ignoring solver " + probs[i].toString() + ": unsupported operation");
				} else {
					Boolean s = probs[i].solve();
					if (i > 0 && s != null && s) { // skip coral
						Env check = this.check(intVars, realVars, i);
						boolean s2 = (check.getResult() == Result.SAT) ? true : false;
						if (s2) {
							solutions[i] = s;
						} else {
							System.out
									.println("## Symlib of Coral does not agree with  " + i + " posted solution");
							solutions[i] = false;
						}
					} else {
						solutions[i] = (s == null) ? false : s;
					}
					// if (s == null) {
					// solutions[i] = false;
					// } else {
					// solutions[i] = s;
					// }
				}
			}
			catch(Exception _){
				solutions[i] = false;
				System.out.println("Solver " + i + " threw an exception");
				_.printStackTrace();
			}

			if (alwaysPrint) {
				System.out.println("Solver " + Integer.toString(i) + ": " + Boolean.toString(solutions[i]));
			}
		}

		// matrix update
		solvingDiff.update(solutions);

		if (!alwaysPrint) {
			boolean first = solutions[0];
			boolean print = false;
			for (int j = 1; j < numSolvers; j++) {
				if (solutions[j] != first) {
					print = true;
					break;
				}
			}
			if (print) {
				System.out.println("---- SOLVERS DISAGREE! ------");
				System.out.println(p.toString());
				for (int i = 0; i < numSolvers; i++) {
					System.out.println("   Solver " + Integer.toString(i) + ": "
							+ Boolean.toString(solutions[i]));
				}
			}
		}
		for (int i = 0; i < numSolvers; i++){
			if(solutions[i]){
				selected = i;
				break;
			}
		}

		return solutions[selected];
	}