Dijkstra et A* corrigé2.1
This commit is contained in:
parent
5d45a5dc02
commit
4e07fd986e
2 changed files with 5 additions and 8 deletions
|
@ -56,7 +56,7 @@ public class AStarAlgorithm extends DijkstraAlgorithm {
|
||||||
|
|
||||||
maxSpeed = graph.getGraphInformation().getMaximumSpeed()/3.6;
|
maxSpeed = graph.getGraphInformation().getMaximumSpeed()/3.6;
|
||||||
|
|
||||||
System.out.println(maxSpeed);
|
//System.out.println(maxSpeed);
|
||||||
|
|
||||||
for(Node node : graph.getNodes()){
|
for(Node node : graph.getNodes()){
|
||||||
nodeId = node.getId();
|
nodeId = node.getId();
|
||||||
|
@ -67,7 +67,7 @@ public class AStarAlgorithm extends DijkstraAlgorithm {
|
||||||
|
|
||||||
else{ // Mode TEMPS sans vitesse max
|
else{ // Mode TEMPS sans vitesse max
|
||||||
|
|
||||||
System.err.println("uh");
|
//System.err.println("uh");
|
||||||
|
|
||||||
for(Node node : graph.getNodes())
|
for(Node node : graph.getNodes())
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ public class AStarAlgorithm extends DijkstraAlgorithm {
|
||||||
|
|
||||||
IdxNewOrigin = minHeap.deleteMin().currentNode.getId();
|
IdxNewOrigin = minHeap.deleteMin().currentNode.getId();
|
||||||
labels[IdxNewOrigin].mark = true;
|
labels[IdxNewOrigin].mark = true;
|
||||||
notifyNodeMarked(labels[IdxNewOrigin].currentNode);
|
//notifyNodeMarked(labels[IdxNewOrigin].currentNode);
|
||||||
|
|
||||||
for (Arc arc : labels[IdxNewOrigin].currentNode.getSuccessors()) { // le arrayList de getSucessors, ça ne retourne que des arc forward. donc pas besoin de vérifier qui est l'origine o`u la destination
|
for (Arc arc : labels[IdxNewOrigin].currentNode.getSuccessors()) { // le arrayList de getSucessors, ça ne retourne que des arc forward. donc pas besoin de vérifier qui est l'origine o`u la destination
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,6 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
@Override
|
@Override
|
||||||
protected ShortestPathSolution doRun() {
|
protected ShortestPathSolution doRun() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// retrieve data from the input problem (getInputData() is inherited from the
|
// retrieve data from the input problem (getInputData() is inherited from the
|
||||||
// parent class ShortestPathAlgorithm)
|
// parent class ShortestPathAlgorithm)
|
||||||
final ShortestPathData data = getInputData();
|
final ShortestPathData data = getInputData();
|
||||||
|
@ -66,7 +64,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
IdxNewOrigin = minHeap.deleteMin().currentNode.getId();
|
IdxNewOrigin = minHeap.deleteMin().currentNode.getId();
|
||||||
labels[IdxNewOrigin].mark = true;
|
labels[IdxNewOrigin].mark = true;
|
||||||
|
|
||||||
notifyNodeMarked(labels[IdxNewOrigin].currentNode);
|
//notifyNodeMarked(labels[IdxNewOrigin].currentNode);
|
||||||
|
|
||||||
for (Arc arc : labels[IdxNewOrigin].currentNode.getSuccessors()) { // le arrayList de getSucessors, ça ne retourne que des arc forward. donc pas besoin de vérifier si le chemin est empruntable
|
for (Arc arc : labels[IdxNewOrigin].currentNode.getSuccessors()) { // le arrayList de getSucessors, ça ne retourne que des arc forward. donc pas besoin de vérifier si le chemin est empruntable
|
||||||
|
|
||||||
|
@ -80,8 +78,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
|
||||||
NewCost = labels[IdxNewOrigin].computedCost + data.getCost(arc); // calcul de la nouvelle distance
|
NewCost = labels[IdxNewOrigin].computedCost + data.getCost(arc); // calcul de la nouvelle distance
|
||||||
OldCost = labels[arc.getDestination().getId()].computedCost; // lecture de l'ancienne
|
OldCost = labels[arc.getDestination().getId()].computedCost; // lecture de l'ancienne
|
||||||
|
|
||||||
if (Double.isInfinite(OldCost)
|
if (Double.isInfinite(OldCost) && Double.isFinite(NewCost)) {
|
||||||
&& Double.isFinite(NewCost)) {
|
|
||||||
notifyNodeReached(arc.getDestination());
|
notifyNodeReached(arc.getDestination());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue