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