Compare commits
No commits in common. "d6f469e32f95bcea08cb3aac9d89c7af1c29e5a7" and "3f7a1543fd82b7a80d520f026d91954d8bf340ac" have entirely different histories.
d6f469e32f
...
3f7a1543fd
1 changed files with 26 additions and 32 deletions
|
@ -15,46 +15,40 @@ import org.insa.graphs.model.io.BinaryGraphReader;
|
||||||
import org.insa.graphs.model.io.GraphReader;
|
import org.insa.graphs.model.io.GraphReader;
|
||||||
|
|
||||||
public class RunTimeTrial {
|
public class RunTimeTrial {
|
||||||
final static int TEST_COUNT_PER_MAP = 30;
|
final static int TEST_COUNT = 100;
|
||||||
|
|
||||||
/*
|
|
||||||
* Runs TEST_COUNT_PER_MAP performance test iterations for every map and
|
|
||||||
* outputs as CSV to stdout. Bellman is performed only for smaller maps.
|
|
||||||
* When running with VSC, paths are relative to the BE_Graphes directory.
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
System.out.println("N,P,D,A,B");
|
final Graph graph = readGraph("./Maps/midi-pyrenees.mapgr");
|
||||||
runTest("./Maps/midi-pyrenees.mapgr", false);
|
|
||||||
runTest("./Maps/france.mapgr", false);
|
|
||||||
runTest("./Maps/belgium.mapgr", false);
|
|
||||||
runTest("./Maps/bretagne.mapgr", false);
|
|
||||||
runTest("./Maps/bordeaux.mapgr", true);
|
|
||||||
runTest("./Maps/carre.mapgr", true);
|
|
||||||
runTest("./Maps/fractal.mapgr", true);
|
|
||||||
runTest("./Maps/insa.mapgr", true);
|
|
||||||
runTest("./Maps/toulouse.mapgr", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void runTest(String mapName, boolean runBellman) throws IOException {
|
long totalDijkstraTime = 0;
|
||||||
final Graph graph = readGraph(mapName);
|
long totalAStarTime = 0;
|
||||||
|
long totalBellmanTime = 0;
|
||||||
|
|
||||||
for (int i = 0; i < TEST_COUNT_PER_MAP; i++) {
|
System.err.println("N D A B");
|
||||||
|
|
||||||
|
for (int i = 0; i < TEST_COUNT; i++) {
|
||||||
|
//System.out.println("Running time trial " + i + "/" + TEST_COUNT);
|
||||||
final ShortestPathData data = getRandomShortestPathData(graph);
|
final ShortestPathData data = getRandomShortestPathData(graph);
|
||||||
|
|
||||||
final ShortestPathSolution dijkstraSolution = new DijkstraAlgorithm(data).run();
|
ShortestPathSolution dijkstraSolution = new DijkstraAlgorithm(data).run();
|
||||||
final ShortestPathSolution aStarSolution = new AStarAlgorithm(data).run();
|
ShortestPathSolution aStarSolution = new AStarAlgorithm(data).run();
|
||||||
final ShortestPathSolution bellmanSolution = runBellman ? new BellmanFordAlgorithm(data).run() : null;
|
//ShortestPathSolution bellmanSolution = new BellmanFordAlgorithm(data).run();
|
||||||
|
|
||||||
|
totalDijkstraTime += dijkstraSolution.getSolvingTime().toMillis();
|
||||||
|
totalAStarTime += aStarSolution.getSolvingTime().toMillis();
|
||||||
|
//totalBellmanTime += bellmanSolution.getSolvingTime().toMillis();
|
||||||
|
|
||||||
final int pathSize = dijkstraSolution.getPath() == null ? -1 : dijkstraSolution.getPath().getArcs().size();
|
final int pathSize = dijkstraSolution.getPath() == null ? -1 : dijkstraSolution.getPath().getArcs().size();
|
||||||
|
System.out.println(pathSize + " "
|
||||||
System.out.println(
|
+ dijkstraSolution.getSolvingTime().toMillis() + " "
|
||||||
graph.size() + ","
|
+ aStarSolution.getSolvingTime().toMillis() + " "
|
||||||
+ pathSize + ","
|
//+ bellmanSolution.getSolvingTime().toMillis() + " "
|
||||||
+ dijkstraSolution.getSolvingTime().toMillis() + ","
|
|
||||||
+ aStarSolution.getSolvingTime().toMillis() + ","
|
|
||||||
+ (runBellman ? bellmanSolution.getSolvingTime().toMillis() : "")
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("Dijkstra took " + totalDijkstraTime + " ms");
|
||||||
|
System.out.println("A* took " + totalAStarTime + " ms");
|
||||||
|
System.out.println("Bellman took " + totalBellmanTime + " ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,10 +59,10 @@ public class RunTimeTrial {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArcInspector getRandomArcFilter() {
|
private static ArcInspector getRandomArcFilter() {
|
||||||
// final Random rand = new Random();
|
final Random rand = new Random();
|
||||||
final List<ArcInspector> filters = ArcInspectorFactory.getAllFilters();
|
final List<ArcInspector> filters = ArcInspectorFactory.getAllFilters();
|
||||||
//return filters.get(Math.abs(rand.nextInt()) % filters.size());
|
//return filters.get(Math.abs(rand.nextInt()) % filters.size());
|
||||||
return filters.get(0); // all arcs
|
return filters.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ShortestPathData getRandomShortestPathData(Graph graph) {
|
private static ShortestPathData getRandomShortestPathData(Graph graph) {
|
||||||
|
|
Loading…
Reference in a new issue