Commit 4ab510cb authored by Sebastian Vollbrecht's avatar Sebastian Vollbrecht

Updated InfeasibleMinII tests to recent changes (also purged RNG from all unit tests).

parent 28908a72
...@@ -165,7 +165,7 @@ public class FeasibleMinIIPropertyTest { ...@@ -165,7 +165,7 @@ public class FeasibleMinIIPropertyTest {
LayerCreator np = new FixedShapeLayerCreator(nodesPerLayer); LayerCreator np = new FixedShapeLayerCreator(nodesPerLayer);
GraphGenerator gg = new GraphGenerator(np, nc, ec, edgeIncluder, edgeIncluder, property); GraphGenerator gg = new GraphGenerator(np, nc, ec, edgeIncluder, edgeIncluder, property);
assertMinII(gg, TestUtils.seed(), minII, ModuloSchedulingFormulation.EICHENBERGER); assertMinII(gg, 42, minII, ModuloSchedulingFormulation.EICHENBERGER);
} }
...@@ -201,7 +201,7 @@ public class FeasibleMinIIPropertyTest { ...@@ -201,7 +201,7 @@ public class FeasibleMinIIPropertyTest {
GraphGenerator gg = new GraphGenerator(np, nc, ec, edgeIncluder, edgeIncluder, property); GraphGenerator gg = new GraphGenerator(np, nc, ec, edgeIncluder, edgeIncluder, property);
assertMinII(gg, TestUtils.seed(), minII, ModuloSchedulingFormulation.EICHENBERGER); assertMinII(gg, 42, minII, ModuloSchedulingFormulation.EICHENBERGER);
} }
...@@ -275,7 +275,7 @@ public class FeasibleMinIIPropertyTest { ...@@ -275,7 +275,7 @@ public class FeasibleMinIIPropertyTest {
GraphGenerator gg = new GraphGenerator(np, nc, ec, edgeIncluder, edgeIncluder, property); GraphGenerator gg = new GraphGenerator(np, nc, ec, edgeIncluder, edgeIncluder, property);
assertMinII(gg, TestUtils.seed(), minII, ModuloSchedulingFormulation.EICHENBERGER); assertMinII(gg, 42, minII, ModuloSchedulingFormulation.EICHENBERGER);
} }
...@@ -311,7 +311,7 @@ public class FeasibleMinIIPropertyTest { ...@@ -311,7 +311,7 @@ public class FeasibleMinIIPropertyTest {
GraphGenerator gg = new GraphGenerator(np, nc, ec, edgeIncluder, edgeIncluder, property); GraphGenerator gg = new GraphGenerator(np, nc, ec, edgeIncluder, edgeIncluder, property);
assertMinII(gg, TestUtils.seed(), minII, ModuloSchedulingFormulation.MOOVAC); assertMinII(gg, 42, minII, ModuloSchedulingFormulation.MOOVAC);
} }
......
...@@ -182,7 +182,7 @@ public class InfeasibleMinIIPropertyTest { ...@@ -182,7 +182,7 @@ public class InfeasibleMinIIPropertyTest {
LayerCreator lc = new FixedShapeLayerCreator(nodesPerLayer); LayerCreator lc = new FixedShapeLayerCreator(nodesPerLayer);
GraphGenerator gg = new GraphGenerator(lc, nc, ec, edgeIncluder, backedgeIncluder, property); GraphGenerator gg = new GraphGenerator(lc, nc, ec, edgeIncluder, backedgeIncluder, property);
Long seed = TestUtils.seed(); Long seed = 42L;
try { try {
gg.createGraph(seed); gg.createGraph(seed);
...@@ -502,7 +502,7 @@ public class InfeasibleMinIIPropertyTest { ...@@ -502,7 +502,7 @@ public class InfeasibleMinIIPropertyTest {
gg.createGraph(42); gg.createGraph(42);
} catch (InfeasibilityImpossibleException e) { } catch (InfeasibilityImpossibleException e) {
assertEquals(InfeasibilityImpossibleCause.NO_PROBLEMATIC_RESOURCE, e.cause); assertEquals(InfeasibilityImpossibleCause.NO_INFEASIBLE_ARRANGEMENT, e.cause);
} }
} }
...@@ -542,7 +542,7 @@ public class InfeasibleMinIIPropertyTest { ...@@ -542,7 +542,7 @@ public class InfeasibleMinIIPropertyTest {
LayerCreator lc = new FixedShapeLayerCreator(nodesPerLayer); LayerCreator lc = new FixedShapeLayerCreator(nodesPerLayer);
GraphGenerator gg = new GraphGenerator(lc, nc, ec, edgeIncluder, backedgeIncluder, property); GraphGenerator gg = new GraphGenerator(lc, nc, ec, edgeIncluder, backedgeIncluder, property);
Long seed = TestUtils.seed(); Long seed = 42L;
try { try {
gg.createGraph(seed); gg.createGraph(seed);
...@@ -550,7 +550,7 @@ public class InfeasibleMinIIPropertyTest { ...@@ -550,7 +550,7 @@ public class InfeasibleMinIIPropertyTest {
fail("This call should have failed. Seed: " + seed); fail("This call should have failed. Seed: " + seed);
} catch (InfeasibilityImpossibleException e) { } catch (InfeasibilityImpossibleException e) {
assertEquals(seed.toString(), InfeasibilityImpossibleCause.NO_PROBLEMATIC_RESOURCE, e.cause); assertEquals(seed.toString(), InfeasibilityImpossibleCause.NO_INFEASIBLE_ARRANGEMENT, e.cause);
} }
} }
...@@ -640,7 +640,7 @@ public class InfeasibleMinIIPropertyTest { ...@@ -640,7 +640,7 @@ public class InfeasibleMinIIPropertyTest {
LayerCreator lc = new FixedShapeLayerCreator(nodesPerLayer); LayerCreator lc = new FixedShapeLayerCreator(nodesPerLayer);
GraphGenerator gg = new GraphGenerator(lc, nc, ec, edgeIncluder, backedgeIncluder, property); GraphGenerator gg = new GraphGenerator(lc, nc, ec, edgeIncluder, backedgeIncluder, property);
assertInfeasibility(gg, minII, TestUtils.seed(), ModuloSchedulingFormulation.EICHENBERGER); assertInfeasibility(gg, minII, 42, ModuloSchedulingFormulation.EICHENBERGER);
} }
...@@ -838,7 +838,7 @@ public class InfeasibleMinIIPropertyTest { ...@@ -838,7 +838,7 @@ public class InfeasibleMinIIPropertyTest {
try { try {
gg.createGraph(42); gg.createGraph(42);
} catch (InfeasibilityImpossibleException e) { } catch (InfeasibilityImpossibleException e) {
assertEquals(InfeasibilityImpossibleCause.NO_PROBLEMATIC_RESOURCE, e.cause); assertEquals(InfeasibilityImpossibleCause.NO_INFEASIBLE_ARRANGEMENT, e.cause);
} }
} }
......
...@@ -19,7 +19,6 @@ package graphgen.generator.util.distribution; ...@@ -19,7 +19,6 @@ package graphgen.generator.util.distribution;
import graphgen.datastructures.SeededRandom; import graphgen.datastructures.SeededRandom;
import graphgen.util.DistributionUtils; import graphgen.util.DistributionUtils;
import graphgen.util.TestUtils;
import org.junit.Test; import org.junit.Test;
import java.util.Arrays; import java.util.Arrays;
...@@ -39,7 +38,7 @@ public class DistributionTest { ...@@ -39,7 +38,7 @@ public class DistributionTest {
// test setup // test setup
int samples = 100; int samples = 100;
List<Integer> pickings = Arrays.asList(0, 0, 0, 0, 0); List<Integer> pickings = Arrays.asList(0, 0, 0, 0, 0);
uniformDistribution.init(TestUtils.rng); uniformDistribution.init(new SeededRandom(42));
for (int i = 0; i < samples; i++) { for (int i = 0; i < samples; i++) {
Integer pickedNumber = uniformDistribution.pick(); Integer pickedNumber = uniformDistribution.pick();
pickings.set(pickedNumber, pickings.get(pickedNumber) + 1); pickings.set(pickedNumber, pickings.get(pickedNumber) + 1);
...@@ -65,7 +64,7 @@ public class DistributionTest { ...@@ -65,7 +64,7 @@ public class DistributionTest {
// test setup // test setup
int samples = 100_000; int samples = 100_000;
List<Integer> pickings = Arrays.asList(0, 0, 0, 0, 0); List<Integer> pickings = Arrays.asList(0, 0, 0, 0, 0);
uniformDistribution.init(TestUtils.rng); uniformDistribution.init(new SeededRandom(42));
for (int i = 0; i < samples; i++) { for (int i = 0; i < samples; i++) {
Integer pickedNumber = uniformDistribution.pick(); Integer pickedNumber = uniformDistribution.pick();
pickings.set(pickedNumber, pickings.get(pickedNumber) + 1); pickings.set(pickedNumber, pickings.get(pickedNumber) + 1);
...@@ -90,7 +89,7 @@ public class DistributionTest { ...@@ -90,7 +89,7 @@ public class DistributionTest {
// test setup // test setup
int samples = Arrays.stream(occurrences).sum(); int samples = Arrays.stream(occurrences).sum();
List<Integer> pickings = Arrays.asList(0, 0, 0, 0, 0); List<Integer> pickings = Arrays.asList(0, 0, 0, 0, 0);
distribution.init(TestUtils.rng); distribution.init(new SeededRandom(42));
for (int i = 0; i < samples; i++) { for (int i = 0; i < samples; i++) {
Integer pickedNumber = distribution.pick(); Integer pickedNumber = distribution.pick();
pickings.set(pickedNumber, pickings.get(pickedNumber) + 1); pickings.set(pickedNumber, pickings.get(pickedNumber) + 1);
......
...@@ -19,6 +19,8 @@ package graphgen.util; ...@@ -19,6 +19,8 @@ package graphgen.util;
import org.junit.Test; import org.junit.Test;
import graphgen.datastructures.SeededRandom;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.IntStream; import java.util.stream.IntStream;
...@@ -48,7 +50,7 @@ public class MathUtilsTest { ...@@ -48,7 +50,7 @@ public class MathUtilsTest {
long maxPicks = (max - min) * 100; long maxPicks = (max - min) * 100;
for (int n = 0; n <= maxPicks && !numbersLeft.isEmpty(); n++) { for (int n = 0; n <= maxPicks && !numbersLeft.isEmpty(); n++) {
int picked = MathUtils.pickBounded(min, max, TestUtils.rng); int picked = MathUtils.pickBounded(min, max, new SeededRandom(42));
assertTrue(min <= picked && picked <= max); assertTrue(min <= picked && picked <= max);
numbersLeft.remove(picked); numbersLeft.remove(picked);
......
...@@ -17,16 +17,9 @@ ...@@ -17,16 +17,9 @@
package graphgen.util; package graphgen.util;
import graphgen.datastructures.SeededRandom;
public class TestUtils { public class TestUtils {
public static final SeededRandom rng = new SeededRandom(System.currentTimeMillis());
public static long seed() {
return rng.getRandom().nextLong();
}
public static void assertEquals(Object expected, Object actual, Number seed) { public static void assertEquals(Object expected, Object actual, Number seed) {
if (!expected.equals(actual)) { if (!expected.equals(actual)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment