Skip to content
Snippets Groups Projects
Commit 3f956822 authored by Johannes Mey's avatar Johannes Mey
Browse files

make random solver more reliable

parent ce87f1ed
No related branches found
No related tags found
No related merge requests found
...@@ -27,12 +27,11 @@ public class RandomSolver implements BenchmarkableSolver { ...@@ -27,12 +27,11 @@ public class RandomSolver implements BenchmarkableSolver {
private long maxSolvingTime; private long maxSolvingTime;
private boolean timedOut; private boolean timedOut;
public RandomSolver() { private final Random random;
this(Long.MAX_VALUE);
}
public RandomSolver(long maxSolvingTime) { public RandomSolver(long maxSolvingTime, long seed) {
this.maxSolvingTime = maxSolvingTime; this.maxSolvingTime = maxSolvingTime;
this.random = new Random(seed);
reset(); reset();
} }
...@@ -50,8 +49,6 @@ public class RandomSolver implements BenchmarkableSolver { ...@@ -50,8 +49,6 @@ public class RandomSolver implements BenchmarkableSolver {
List<Solution> solutions = new ArrayList<>(); List<Solution> solutions = new ArrayList<>();
Random random = new Random();
do { do {
numTotalSoftwareSolutions++; numTotalSoftwareSolutions++;
......
...@@ -6,6 +6,6 @@ public class RandomHandwrittenTest extends HandwrittenTestSuite { ...@@ -6,6 +6,6 @@ public class RandomHandwrittenTest extends HandwrittenTestSuite {
@Override @Override
protected Solver getSolver() { protected Solver getSolver() {
return new RandomSolver(60000); return new RandomSolver(5000, 0);
} }
} }
...@@ -42,7 +42,7 @@ public class RandomSolverTest { ...@@ -42,7 +42,7 @@ public class RandomSolverTest {
ScenarioGenerator generator = new ScenarioGenerator(new ScenarioDescription(tlc, iac, isd, cac, csd, dep, imp, res, req, cpu, seed)); ScenarioGenerator generator = new ScenarioGenerator(new ScenarioDescription(tlc, iac, isd, cac, csd, dep, imp, res, req, cpu, seed));
Root model = generator.generate(); Root model = generator.generate();
RandomSolver solver = new RandomSolver(5000); RandomSolver solver = new RandomSolver(5000, 1337);
Solution solution = solver.solve(model); Solution solution = solver.solve(model);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment