From 1eef4d26564ecf411fee08d925abd9ee35477d56 Mon Sep 17 00:00:00 2001 From: pfaure Date: Tue, 2 Jun 2020 17:35:15 +0200 Subject: [PATCH] =?UTF-8?q?Remise=20Du=20BE=20-=20Version=20fonctionnelle?= =?UTF-8?q?=20:=20Correction=20de=20l'erreur=20sur=20l'estimation=20dans?= =?UTF-8?q?=20A*,=20finalisation=20des=20tests=20d'optimalit=C3=A9,=20ajou?= =?UTF-8?q?t=20des=20tests=20de=20performances?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shortestpath/AStarAlgorithm.java | 14 +-- .../shortestpath/DijkstraAlgorithm.java | 8 +- .../graphs/algorithm/shortestpath/Label.java | 9 +- .../algorithm/shortestpath/LabelStar.java | 2 +- .../graphs/algorithm/utils/BinaryHeap.java | 20 +++-- .../shortestpath/OptimaliteTest.java | 22 ----- .../shortestpath/PerformancesTest.java | 85 +++++++++++++++++++ 7 files changed, 107 insertions(+), 53 deletions(-) create mode 100644 be-graphes-algos/src/test/java/org/insa/graphs/algorithm/shortestpath/PerformancesTest.java diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.java index 45f73ed..2e7e1b9 100644 --- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.java +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/AStarAlgorithm.java @@ -19,26 +19,14 @@ public class AStarAlgorithm extends DijkstraAlgorithm { } if (data.getMode() == Mode.LENGTH) { - MaxSpeed = 1; + MaxSpeed = 1.01; } else { MaxSpeed = MaxSpeed / 3.6; } - //double longueurArc = 0.0; - for (Node node: data.getGraph().getNodes()) { double estimation = Point.distance(node.getPoint(), data.getDestination().getPoint())/MaxSpeed; labels[node.getId()] = new LabelStar(node, estimation); - /*if (node.getId() == 6800) { - for (Arc arc: node.getSuccessors()) { - if (arc.getDestination().getId() == 6299) { - longueurArc = arc.getLength(); - } - } - }*/ } - - //System.out.println("La distance entre les nodes " + data.getGraph().getNodes().get(6800).getId() + " et " + data.getGraph().getNodes().get(6299).getId() + " est : " + Point.distance(data.getGraph().getNodes().get(6800).getPoint(), data.getGraph().getNodes().get(6299).getPoint()) + " et la longeur de l'arc est : " + longueurArc); - } } diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java index ec59011..0293f0d 100644 --- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java @@ -55,10 +55,9 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm { notifyNodeMarked(current.getSommetCourant()); // POUR LE TEST SUR LES COUTS CROISSANTS - //System.out.println("Test sur le coût : " + labels[currentID].getTotalCost()); if (labels[currentID].compareTo(labels[ancienID]) == -1) { - System.out.println("Erreur : Couts non croissants : noeud" + ancienID + " contre " + currentID); - } + System.out.println("Erreur : Couts non croissants : noeud " + ancienID + " (" + labels[ancienID].getTotalCost() + "; " + labels[ancienID].getEstimation() + ") contre " + currentID + " (" + labels[currentID].getTotalCost() + "; " + labels[currentID].getEstimation() + ") "); + } ancienID = currentID; //nbNonMarque--; @@ -93,8 +92,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm { if (compteur_successeurs != labels[currentID].getSommetCourant().getNumberOfSuccessors()) { System.out.println("ERREUR Nombre de successeurs visités : " + compteur_successeurs + "/" + labels[currentID].getSommetCourant().getNumberOfSuccessors()); } - //System.out.println("Nombre de successeurs visités : " + compteur_successeurs + "/" + labels[currentID].getSommetCourant().getNumberOfSuccessors()); - } + } catch (EmptyPriorityQueueException e) { encore = false; } diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/Label.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/Label.java index 78d70b4..b176f4c 100644 --- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/Label.java +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/Label.java @@ -51,16 +51,17 @@ public class Label implements Comparable