Better tests for the square map

This commit is contained in:
Yohan Simard 2020-05-31 20:26:42 +02:00
parent 25e08fc7f0
commit 5e75797cda

View file

@ -66,15 +66,21 @@ public abstract class ShortestPathTest {
assertTrue(sol.isFeasible());
Path path = sol.getPath();
assertTrue(path.isValid());
// skip these tests for the square map where there may be several arcs with the same cost
// check the optimality locally
if (arcInspector == arcInspectors[0])
assertEquals(path, Path.createShortestPathFromNodes(data.getGraph(), path.getNodes()));
if (arcInspector == arcInspectors[1])
assertEquals(path, Path.createFastestPathFromNodes(data.getGraph(), path.getNodes()));
// skip this test for the square map where there may be several paths with the same cost
if (i != 0) {
// check the optimality locally
if (arcInspector == arcInspectors[0])
assertEquals(path, Path.createShortestPathFromNodes(data.getGraph(), path.getNodes()));
if (arcInspector == arcInspectors[1])
assertEquals(path, Path.createFastestPathFromNodes(data.getGraph(), path.getNodes()));
// Check result against Bellman Ford algorithm
assertEquals(sol.getPath(), oracle.getPath());
} else { // in the square map case, compare only the costs
if (arcInspector == arcInspectors[0])
assertEquals(sol.getPath().getLength(), oracle.getPath().getLength(), 1e-5);
if (arcInspector == arcInspectors[1])
assertEquals(sol.getPath().getMinimumTravelTime(), oracle.getPath().getMinimumTravelTime(), 1e-1);
}
}
}