forked from lebotlan/BE-Graphes
Compare commits
No commits in common. "6874d8da00cbb10a5dc2448a30febf11c7ad35c0" and "771dfb96b26f6e778bb9290e9923b884538c6cb3" have entirely different histories.
6874d8da00
...
771dfb96b2
1 changed files with 6 additions and 25 deletions
|
|
@ -12,7 +12,6 @@ import java.util.List;
|
||||||
import org.insa.graphs.algorithm.AbstractSolution.Status;
|
import org.insa.graphs.algorithm.AbstractSolution.Status;
|
||||||
import org.insa.graphs.algorithm.ArcInspector;
|
import org.insa.graphs.algorithm.ArcInspector;
|
||||||
import org.insa.graphs.algorithm.ArcInspectorFactory;
|
import org.insa.graphs.algorithm.ArcInspectorFactory;
|
||||||
import org.insa.graphs.algorithm.shortestpath.AStarAlgorithm;
|
|
||||||
import org.insa.graphs.algorithm.shortestpath.BellmanFordAlgorithm;
|
import org.insa.graphs.algorithm.shortestpath.BellmanFordAlgorithm;
|
||||||
import org.insa.graphs.algorithm.shortestpath.DijkstraAlgorithm;
|
import org.insa.graphs.algorithm.shortestpath.DijkstraAlgorithm;
|
||||||
import org.insa.graphs.algorithm.shortestpath.ShortestPathAlgorithm;
|
import org.insa.graphs.algorithm.shortestpath.ShortestPathAlgorithm;
|
||||||
|
|
@ -85,23 +84,18 @@ public class ShortestPathTest {
|
||||||
// System.out.println("" + insaBikiniCanal.getOrigin().getId() +" "+ insaBikiniCanal.getDestination().getId());
|
// System.out.println("" + insaBikiniCanal.getOrigin().getId() +" "+ insaBikiniCanal.getDestination().getId());
|
||||||
ShortestPathAlgorithm bellmanFord = new BellmanFordAlgorithm(insaBikiniCanalPathData);
|
ShortestPathAlgorithm bellmanFord = new BellmanFordAlgorithm(insaBikiniCanalPathData);
|
||||||
ShortestPathAlgorithm dijkstra = new DijkstraAlgorithm(insaBikiniCanalPathData);
|
ShortestPathAlgorithm dijkstra = new DijkstraAlgorithm(insaBikiniCanalPathData);
|
||||||
ShortestPathAlgorithm aStar = new AStarAlgorithm(insaBikiniCanalPathData);
|
|
||||||
|
|
||||||
ShortestPathSolution solutionBellmanFord = bellmanFord.run();
|
ShortestPathSolution solutionBellmanFord = bellmanFord.run();
|
||||||
ShortestPathSolution solutionDijkstra = dijkstra.run();
|
ShortestPathSolution solutionDijkstra = dijkstra.run();
|
||||||
ShortestPathSolution solutionAStar = aStar.run();
|
|
||||||
|
|
||||||
assertEquals(Status.OPTIMAL, solutionBellmanFord.getStatus());
|
assertEquals(Status.OPTIMAL, solutionBellmanFord.getStatus());
|
||||||
assertEquals(Status.OPTIMAL, solutionDijkstra.getStatus());
|
assertEquals(Status.OPTIMAL, solutionDijkstra.getStatus());
|
||||||
assertEquals(Status.OPTIMAL, solutionAStar.getStatus());
|
|
||||||
|
|
||||||
assertEquals(insaBikiniCanal.getLength(), solutionBellmanFord.getPath().getLength(),1.0);
|
assertEquals(insaBikiniCanal.getLength(), solutionBellmanFord.getPath().getLength(),1.0);
|
||||||
assertEquals(insaBikiniCanal.getLength(), solutionDijkstra.getPath().getLength(), 1.0);
|
assertEquals(insaBikiniCanal.getLength(), solutionDijkstra.getPath().getLength(), 1.0);
|
||||||
assertEquals(insaBikiniCanal.getLength(), solutionAStar.getPath().getLength(), 1.0);
|
|
||||||
|
|
||||||
assertEquals(insaBikiniCanal.getTravelTime(120), solutionBellmanFord.getPath().getTravelTime(120),1.0);
|
assertEquals(insaBikiniCanal.getTravelTime(120), solutionBellmanFord.getPath().getTravelTime(120),1.0);
|
||||||
assertEquals(insaBikiniCanal.getTravelTime(120), solutionDijkstra.getPath().getTravelTime(120), 1.0);
|
assertEquals(insaBikiniCanal.getTravelTime(120), solutionDijkstra.getPath().getTravelTime(120), 1.0);
|
||||||
assertEquals(insaBikiniCanal.getTravelTime(120), solutionAStar.getPath().getTravelTime(120), 1.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -109,54 +103,41 @@ public class ShortestPathTest {
|
||||||
ShortestPathData cheminInexistant = new ShortestPathData(insa, insa.get(940), insa.get(702), onlyCarsByLengthArcInspector);
|
ShortestPathData cheminInexistant = new ShortestPathData(insa, insa.get(940), insa.get(702), onlyCarsByLengthArcInspector);
|
||||||
ShortestPathAlgorithm bellmanFord = new BellmanFordAlgorithm(cheminInexistant);
|
ShortestPathAlgorithm bellmanFord = new BellmanFordAlgorithm(cheminInexistant);
|
||||||
ShortestPathAlgorithm dijkstra = new DijkstraAlgorithm(cheminInexistant);
|
ShortestPathAlgorithm dijkstra = new DijkstraAlgorithm(cheminInexistant);
|
||||||
ShortestPathAlgorithm aStar = new AStarAlgorithm(cheminInexistant);
|
|
||||||
|
|
||||||
ShortestPathSolution solutionBellmanFord = bellmanFord.run();
|
ShortestPathSolution solutionBellmanFord = bellmanFord.run();
|
||||||
ShortestPathSolution solutionDijkstra = dijkstra.run();
|
ShortestPathSolution solutionDijkstra = dijkstra.run();
|
||||||
ShortestPathSolution solutionAStar = aStar.run();
|
|
||||||
|
|
||||||
assertEquals(Status.INFEASIBLE, solutionBellmanFord.getStatus());
|
assertEquals(Status.INFEASIBLE, solutionBellmanFord.getStatus());
|
||||||
assertEquals(Status.INFEASIBLE, solutionDijkstra.getStatus());
|
assertEquals(Status.INFEASIBLE, solutionDijkstra.getStatus());
|
||||||
assertEquals(Status.INFEASIBLE, solutionAStar.getStatus());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCheminLongueurNulle() {
|
public void testCheminLongueurNulle() {
|
||||||
ShortestPathData cheminNul = new ShortestPathData(insa, insa.get(940), insa.get(940), noFilterByLengthArcInspector);
|
ShortestPathData cheminInexistant = new ShortestPathData(insa, insa.get(940), insa.get(940), noFilterByLengthArcInspector);
|
||||||
ShortestPathAlgorithm bellmanFord = new BellmanFordAlgorithm(cheminNul);
|
ShortestPathAlgorithm bellmanFord = new BellmanFordAlgorithm(cheminInexistant);
|
||||||
ShortestPathAlgorithm dijkstra = new DijkstraAlgorithm(cheminNul);
|
ShortestPathAlgorithm dijkstra = new DijkstraAlgorithm(cheminInexistant);
|
||||||
ShortestPathAlgorithm aStar = new AStarAlgorithm(cheminNul);
|
|
||||||
|
|
||||||
ShortestPathSolution solutionBellmanFord = bellmanFord.run();
|
ShortestPathSolution solutionBellmanFord = bellmanFord.run();
|
||||||
ShortestPathSolution solutionDijkstra = dijkstra.run();
|
ShortestPathSolution solutionDijkstra = dijkstra.run();
|
||||||
ShortestPathSolution solutionAStar = aStar.run();
|
|
||||||
|
|
||||||
assertEquals(Status.INFEASIBLE, solutionBellmanFord.getStatus());
|
assertEquals(Status.INFEASIBLE, solutionBellmanFord.getStatus());
|
||||||
assertEquals(Status.INFEASIBLE, solutionDijkstra.getStatus());
|
assertEquals(Status.INFEASIBLE, solutionDijkstra.getStatus());
|
||||||
assertEquals(Status.INFEASIBLE, solutionAStar.getStatus());
|
|
||||||
|
|
||||||
assertNull(solutionBellmanFord.getPath());
|
assertNull(solutionBellmanFord.getPath());
|
||||||
assertNull(solutionDijkstra.getPath());
|
assertNull(solutionDijkstra.getPath());
|
||||||
assertNull(solutionAStar.getPath());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCheminLong() { // En comparant les deux algos
|
public void testCheminLong() { // En comparant les deux algos
|
||||||
ShortestPathData cheminLong = new ShortestPathData(belgique, belgique.get(956754), belgique.get(842938), noFilterByLengthArcInspector);
|
ShortestPathData cheminInexistant = new ShortestPathData(belgique, belgique.get(956754), belgique.get(842938), noFilterByLengthArcInspector);
|
||||||
ShortestPathAlgorithm bellmanFord = new BellmanFordAlgorithm(cheminLong);
|
ShortestPathAlgorithm bellmanFord = new BellmanFordAlgorithm(cheminInexistant);
|
||||||
ShortestPathAlgorithm dijkstra = new DijkstraAlgorithm(cheminLong);
|
ShortestPathAlgorithm dijkstra = new DijkstraAlgorithm(cheminInexistant);
|
||||||
ShortestPathAlgorithm aStar = new AStarAlgorithm(cheminLong);
|
|
||||||
|
|
||||||
ShortestPathSolution solutionBellmanFord = bellmanFord.run();
|
ShortestPathSolution solutionBellmanFord = bellmanFord.run();
|
||||||
ShortestPathSolution solutionDijkstra = dijkstra.run();
|
ShortestPathSolution solutionDijkstra = dijkstra.run();
|
||||||
ShortestPathSolution solutionAStar = aStar.run();
|
|
||||||
|
|
||||||
assertEquals(solutionBellmanFord.getStatus(), solutionDijkstra.getStatus());
|
assertEquals(solutionBellmanFord.getStatus(), solutionDijkstra.getStatus());
|
||||||
assertEquals(solutionBellmanFord.getPath().getLength(), solutionDijkstra.getPath().getLength(), 1.0);
|
assertEquals(solutionBellmanFord.getPath().getLength(), solutionDijkstra.getPath().getLength(), 1.0);
|
||||||
assertEquals(solutionBellmanFord.getPath().getTravelTime(120), solutionDijkstra.getPath().getTravelTime(120), 1.0);
|
assertEquals(solutionBellmanFord.getPath().getTravelTime(120), solutionDijkstra.getPath().getTravelTime(120), 1.0);
|
||||||
|
|
||||||
assertEquals(solutionAStar.getStatus(), solutionDijkstra.getStatus());
|
|
||||||
assertEquals(solutionAStar.getPath().getLength(), solutionDijkstra.getPath().getLength(), 1.0);
|
|
||||||
assertEquals(solutionAStar.getPath().getTravelTime(120), solutionDijkstra.getPath().getTravelTime(120), 1.0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue