refactor(marathon): make constant references as final
This commit is contained in:
parent
de340c65dd
commit
f45f0027f0
1 changed files with 12 additions and 13 deletions
|
@ -47,25 +47,24 @@ public class MarathonAlgorithm extends ShortestPathAlgorithm {
|
||||||
if (!solution.isFeasible())
|
if (!solution.isFeasible())
|
||||||
return solution;
|
return solution;
|
||||||
|
|
||||||
while (path.getLength() < getDistance()) {
|
while (path.getLength() < distanceMarathon) {
|
||||||
// Recuperation Arc à supprimer
|
// Recuperation Arc à supprimer (cacher) et extremites
|
||||||
Arc arcToRemove = getLongestArc(path);
|
final Arc arcToRemove = getLongestArc(path);
|
||||||
Node originArcToRemove = arcToRemove.getOrigin();
|
final Node originArcToRemove = arcToRemove.getOrigin();
|
||||||
Node destinationArcToRemove = arcToRemove.getDestination();
|
final Node destinationArcToRemove = arcToRemove.getDestination();
|
||||||
|
|
||||||
// On le supprime dans une copie du tableau (getter Collections.unmodifiable dans Path.java)
|
|
||||||
path.getArcs().remove(arcToRemove);
|
path.getArcs().remove(arcToRemove);
|
||||||
originArcToRemove.removeArc(arcToRemove);
|
originArcToRemove.removeArc(arcToRemove); // TODO and similar ?
|
||||||
|
|
||||||
// Creations du chemin entre les 2 noeuds dont l'arc a été supprimé
|
// Creations du chemin entre les 2 noeuds dont l'arc a été supprimé
|
||||||
ArcInspector arcInspector = ArcInspectorFactory.getAllFilters().get(0);
|
final ArcInspector arcInspector = ArcInspectorFactory.getAllFilters().get(0);
|
||||||
ShortestPathData newData = new ShortestPathData(graph, originArcToRemove, destinationArcToRemove, arcInspector);
|
final ShortestPathData newData = new ShortestPathData(graph, originArcToRemove, destinationArcToRemove, arcInspector);
|
||||||
DijkstraAlgorithm newDijkstra = new DijkstraAlgorithm(newData);
|
Path newPath = (new DijkstraAlgorithm(newData)).run().getPath();
|
||||||
ShortestPathSolution newPath = newDijkstra.run();
|
|
||||||
|
|
||||||
if (newPath.getPath() != null) {
|
// could get stuck in a loop if no path is found, given the current arcToRemove strategy
|
||||||
|
if (newPath != null) {
|
||||||
// Ajout du path trouvé à l'indice où on l'a enlevé
|
// Ajout du path trouvé à l'indice où on l'a enlevé
|
||||||
path.getArcs().addAll(newPath.getPath().getArcs());
|
path.getArcs().addAll(newPath.getArcs());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue