From 915e7e7da4c84b9a66bdb24ddb4fb4c123be9051 Mon Sep 17 00:00:00 2001 From: Bensouda Idriss Date: Wed, 24 May 2023 13:41:49 +0200 Subject: [PATCH] Implementation probleme ouvert rendu final --- .settings/org.eclipse.m2e.core.prefs | 4 + .../.settings/org.eclipse.m2e.core.prefs | 4 + .../graphs/algorithm/AlgorithmFactory.java | 3 + .../algorithm/shortestpath/Autonomie.java | 175 ++++++++++++++++++ .../shortestpath/DijkstraAlgorithm.java | 4 +- .../graphs/algorithm/shortestpath/Label.java | 56 +++++- .../graphs/algorithm/AlgorithmFactory.class | Bin 4205 -> 4287 bytes .../shortestpath/DijkstraAlgorithm.class | Bin 5411 -> 5546 bytes be-graphes-gui/.classpath | 25 +++ .../.settings/org.eclipse.jdt.apt.core.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 1 + .../.settings/org.eclipse.m2e.core.prefs | 4 + be-graphes-model/.classpath | 30 +++ .../.settings/org.eclipse.jdt.apt.core.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 1 + .../.settings/org.eclipse.m2e.core.prefs | 4 + 16 files changed, 312 insertions(+), 3 deletions(-) create mode 100644 .settings/org.eclipse.m2e.core.prefs create mode 100644 be-graphes-algos/.settings/org.eclipse.m2e.core.prefs create mode 100644 be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/Autonomie.java create mode 100644 be-graphes-gui/.settings/org.eclipse.jdt.apt.core.prefs create mode 100644 be-graphes-gui/.settings/org.eclipse.m2e.core.prefs create mode 100644 be-graphes-model/.settings/org.eclipse.jdt.apt.core.prefs create mode 100644 be-graphes-model/.settings/org.eclipse.m2e.core.prefs diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/be-graphes-algos/.settings/org.eclipse.m2e.core.prefs b/be-graphes-algos/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/be-graphes-algos/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/AlgorithmFactory.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/AlgorithmFactory.java index 4dde531..588444c 100644 --- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/AlgorithmFactory.java +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/AlgorithmFactory.java @@ -8,6 +8,7 @@ import java.util.Set; import java.util.TreeSet; import org.insa.graphs.algorithm.shortestpath.AStarAlgorithm; +import org.insa.graphs.algorithm.shortestpath.Autonomie; import org.insa.graphs.algorithm.shortestpath.BellmanFordAlgorithm; import org.insa.graphs.algorithm.shortestpath.DijkstraAlgorithm; import org.insa.graphs.algorithm.shortestpath.ShortestPathAlgorithm; @@ -32,6 +33,8 @@ public class AlgorithmFactory { registerAlgorithm(ShortestPathAlgorithm.class, "Bellman-Ford", BellmanFordAlgorithm.class); registerAlgorithm(ShortestPathAlgorithm.class, "Dijkstra", DijkstraAlgorithm.class); registerAlgorithm(ShortestPathAlgorithm.class, "A*", AStarAlgorithm.class); + registerAlgorithm(ShortestPathAlgorithm.class, "Autonomie", Autonomie.class); + // Register your algorithms here: // registerAlgorithm(CarPoolingAlgorithm.class, "My Awesome Algorithm", diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/Autonomie.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/Autonomie.java new file mode 100644 index 0000000..4825049 --- /dev/null +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/Autonomie.java @@ -0,0 +1,175 @@ +package org.insa.graphs.algorithm.shortestpath; + +import org.insa.graphs.algorithm.AbstractSolution.Status; + +import java.util.ArrayList; +import java.util.Collections; +import org.insa.graphs.algorithm.utils.BinaryHeap; +import org.insa.graphs.model.Arc; +import org.insa.graphs.model.Node; +import org.insa.graphs.model.Path; +import org.insa.graphs.model.Point; + +public class Autonomie extends ShortestPathAlgorithm { + + public Autonomie(ShortestPathData data) { + super(data); + + } + + public Label CreationLabel(Node x, Double cout, Arc parent){ + ShortestPathData data = getInputData(); + //On utilise Point.distance qui permet d'obtenir la distance à vol d'oiseau d'un point x vers un point destination + return new LabelStar(x,cout,parent,Point.distance(data.getGraph().get(x.getId()).getPoint(), data.getDestination().getPoint())); + } + + @Override + protected ShortestPathSolution doRun() { + final ShortestPathData data = getInputData(); + ShortestPathSolution solution = null; + int nombreRecharges = 0; + ArrayList