Test: sous pcc est un pcc : vérification arcs

This commit is contained in:
Clement Lacau 2024-05-24 13:58:56 +02:00
parent 45adcbeb8e
commit 44991cfab2

View file

@ -274,12 +274,7 @@ public abstract class ShortestPathAlgorithmTest {
int size_graph = myGraph.getNodes().size();
for (int i = 0 ; i < 100 ; i++) {
origin = myGraph.get(Math.abs(rand.nextInt()) % size_graph);
destination = myGraph.get(Math.abs(rand.nextInt()) % size_graph);
assertBellmanHasSameResult(myGraph, origin, destination, arcInspector);
}
nTestsWithBellman(myGraph, origin, destination, arcInspector, size_graph, 100);
}
//@Test
@ -301,12 +296,7 @@ public abstract class ShortestPathAlgorithmTest {
int size_graph = myGraph.getNodes().size();
for (int i = 0 ; i < 100 ; i++) {
origin = myGraph.get(Math.abs(rand.nextInt()) % size_graph);
destination = myGraph.get(Math.abs(rand.nextInt()) % size_graph);
assertBellmanHasSameResult(myGraph, origin, destination, arcInspector);
}
nTestsWithBellman(myGraph, origin, destination, arcInspector, size_graph, 100);
}
@Test
@ -372,7 +362,9 @@ public abstract class ShortestPathAlgorithmTest {
* -les sous-chemins d'un PCC sont des PCC. Sachant cela, on doit être sur
* qu'en appliquant un second Dijkstra sur 2 noeuds aléatoires dans le path
* renvoyé par le premier Dijkstra (hors origine et destination), on
* obtient un chemin de coût inférieur au premier.
* obtient :
* -un plus court chemin qui est le même que le sous chemin relevé (sous PCC).
* -un plus court chemin de coût inférieur au chemin dont il a été extrait.
* On teste 10 PCC et pour chaque PCC 25 sous PCC
* Mode: LENGTH
* Carte utilisée : ../Maps/midi_pyrenees.mapgr
@ -423,6 +415,9 @@ public abstract class ShortestPathAlgorithmTest {
final ShortestPathSolution pathSousPCC = algoSousPCC.doRun();
if (path.getPath() != null) {
for (int k = 0 ; k < pathSousPCC.getPath().size()-1; k++) {
assert(pathSousPCC.getPath().getArcs().get(k) == path.getPath().getArcs().get(indiceOrigine + k));
}
assert(pathSousPCC.getPath().isValid());
assert(pathSousPCC.isFeasible());
assert((Math.abs(algoSousPCC.getCostPath() - pathSousPCC.getPath().getLength())) < 1.0);
@ -443,7 +438,9 @@ public abstract class ShortestPathAlgorithmTest {
* -les sous-chemins d'un PCC sont des PCC. Sachant cela, on doit être sur
* qu'en appliquant un second Dijkstra sur 2 noeuds aléatoires dans le path
* renvoyé par le premier Dijkstra (hors origine et destination), on
* obtient un chemin de coût inférieur au premier.
* obtient :
* -un plus court chemin qui est le même que le sous chemin relevé.
* -un plus court chemin de coût inférieur au chemin dont il a été extrait.
* On teste 10 PCC et pour chaque PCC 25 sous PCC
* Mode: TIME
* Carte utilisée : ../Maps/midi_pyrenees.mapgr
@ -485,7 +482,6 @@ public abstract class ShortestPathAlgorithmTest {
int indiceDestination = milieu_path + Math.abs(rand.nextInt()) % milieu_path - 1;
noeudSelectionneOrigine = path.getPath().getArcs().get(indiceOrigine).getOrigin();
noeudSelectionneDestination = path.getPath().getArcs().get(indiceDestination).getOrigin();
ShortestPathData dataSousPCC = new ShortestPathData(myGraph, noeudSelectionneOrigine, noeudSelectionneDestination, arcInspector);
@ -494,6 +490,9 @@ public abstract class ShortestPathAlgorithmTest {
final ShortestPathSolution pathSousPCC = algoSousPCC.doRun();
if (path.getPath() != null) {
for (int k = 0 ; k < pathSousPCC.getPath().size()-1; k++) {
assert(pathSousPCC.getPath().getArcs().get(k) == path.getPath().getArcs().get(indiceOrigine + k));
}
assert(pathSousPCC.getPath().isValid());
assert(pathSousPCC.isFeasible());
assert((Math.abs(algoSousPCC.getCostPath() - pathSousPCC.getPath().getMinimumTravelTime())) < 1.0);
@ -506,3 +505,4 @@ public abstract class ShortestPathAlgorithmTest {
}
}
}