feat(marathon): use marathonArcInspector
This commit is contained in:
parent
b7012ee892
commit
7cc3c39211
1 changed files with 6 additions and 5 deletions
|
@ -2,6 +2,7 @@ package org.insa.graphs.algorithm.marathon;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.insa.graphs.algorithm.AbstractSolution.Status;
|
||||
import org.insa.graphs.algorithm.ArcInspector;
|
||||
import org.insa.graphs.algorithm.ArcInspectorFactory;
|
||||
import org.insa.graphs.algorithm.shortestpath.DijkstraAlgorithm;
|
||||
|
@ -53,18 +54,17 @@ public class MarathonAlgorithm extends ShortestPathAlgorithm {
|
|||
final Node originArcToRemove = arcToRemove.getOrigin();
|
||||
final Node destinationArcToRemove = arcToRemove.getDestination();
|
||||
|
||||
path.getArcs().remove(arcToRemove);
|
||||
originArcToRemove.removeArc(arcToRemove); // TODO and similar ?
|
||||
|
||||
// Creations du chemin entre les 2 noeuds dont l'arc a été supprimé
|
||||
final ArcInspector arcInspector = ArcInspectorFactory.getAllFilters().get(0);
|
||||
final ArcInspector arcInspector = new MarathonArcInspector(path, arcToRemove); // filters out cycles and current arc
|
||||
final ShortestPathData newData = new ShortestPathData(graph, originArcToRemove, destinationArcToRemove, arcInspector);
|
||||
Path newPath = (new DijkstraAlgorithm(newData)).run().getPath();
|
||||
final Path newPath = (new DijkstraAlgorithm(newData)).run().getPath();
|
||||
|
||||
// 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é
|
||||
path.getArcs().addAll(newPath.getArcs());
|
||||
path.replaceArc(arcToRemove, newPath.getArcs());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,8 +95,9 @@ public class MarathonAlgorithm extends ShortestPathAlgorithm {
|
|||
longestArc = arc;
|
||||
}
|
||||
}
|
||||
return arcs.get(Math.abs(rand.nextInt() % (arcs.size())));
|
||||
|
||||
return longestArc;
|
||||
//return longestArc;
|
||||
//int indiceArcToRemove = 0; //Math.abs(rand.nextInt() % (longueurPath - 1));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue