Favary Pierre 2 years ago
parent
commit
71cee153fc

+ 27
- 0
be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/AStar.java View File

@@ -0,0 +1,27 @@
1
+package org.insa.graphs.algorithm.shortestpath;
2
+
3
+import org.insa.graphs.model.Arc;
4
+import org.insa.graphs.model.Path;//trier tout ça
5
+
6
+public class AStar extends DijkstraAlgorithm {
7
+	
8
+	
9
+	public void initLabel() {
10
+		int placeholder=0;
11
+		
12
+	}
13
+	
14
+	
15
+    public AStar(ShortestPathData data) {
16
+        super(data);
17
+    }
18
+
19
+    public void proc1modifDijk() {
20
+    	this.getInputData().getDestination();
21
+    }
22
+    
23
+    //particularités de A*:
24
+    //-comment trouver la distance à vol d'oiseau entre deux nodes?--------node.getpoint().distanceTo()?
25
+    //-comment initialiser le labelstar.estim de chaque node avec cette méthode
26
+    //-comment avoir des LabelStar et non des Label
27
+}

+ 7
- 1
be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/DijkstraAlgorithm.java View File

@@ -89,8 +89,14 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
89 89
         		}
90 90
         	
91 91
         	Collections.reverse(bonsarcs);
92
-        	//Path chemin= new Path(data.getGraph(),bonsarcs);//y'a t-il un retour si le chemin est infaisable? éviterait la condition précédente si oui
93 92
         	solution = new ShortestPathSolution(data,Status.OPTIMAL,new Path(data.getGraph(),bonsarcs));
93
+        	
94
+        	//Path chemin= new Path(data.getGraph(),bonsarcs);//y'a t-il un retour si le chemin est infaisable? 
95
+        	//System.out.printf("valide: %b, longueur: %f\n",chemin.isValid(), chemin.getLength());
96
+        	//System.out.printf("distance réelle origine-destination (test): %f", (float)this.getInputData().getOrigin().getPoint().distanceTo(this.getInputData().getDestination().getPoint()));
97
+        	
98
+        	
99
+        	//comparer le coût avec celui de la méthode Path en utilisant equals ou compareTo, mais Dijkstra ne renvoie pas de coût de lui-même, ni ShortestPathSolution?
94 100
         	}
95 101
         
96 102
         return solution;

+ 8
- 1
be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/Label.java View File

@@ -34,13 +34,19 @@ public class Label implements Comparable<Label>{
34 34
 		
35 35
 	}
36 36
 	
37
+	//est-ce que cette fonction est utilisée?
37 38
 	public float getCost() {
38 39
 		return this.cout;
39 40
 	}
40 41
 	
42
+	//fonction utilse pour LabelStar (permet d'hériter de compareTo)
43
+	public float getTotalCost() {
44
+		return this.cout;
45
+	}
46
+	
41 47
 	//fonction de comparaison
42 48
 	public int compareTo(Label comp) {
43
-		float diff= this.cout-comp.cout;
49
+		float diff= this.getTotalCost()-comp.getTotalCost();
44 50
 		if (diff>0) {
45 51
 			return 1;
46 52
 		}else if (diff<0) {
@@ -49,4 +55,5 @@ public class Label implements Comparable<Label>{
49 55
 			return 0;
50 56
 		}
51 57
 	}
58
+	
52 59
 }

+ 34
- 0
be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/LabelStar.java View File

@@ -0,0 +1,34 @@
1
+package org.insa.graphs.algorithm.shortestpath;
2
+
3
+import org.insa.graphs.model.Arc;
4
+import org.insa.graphs.model.Node;
5
+
6
+public class LabelStar extends Label{
7
+	
8
+	protected float estim;
9
+
10
+	public LabelStar(Node sommet, Arc padre, float prix, float estimation) {
11
+		super(sommet, padre, prix);
12
+		this.estim=estimation;
13
+	}
14
+	
15
+	public LabelStar(Node sommet, Arc padre, float prix, float estimation, boolean mark) {
16
+		super(sommet, padre, prix, mark);
17
+		this.estim=estimation;
18
+	}
19
+	
20
+	public float getEstimation() {
21
+		return this.estim;//même remarque que pour son pendant dans Label
22
+	}
23
+	
24
+	public float getTotalCost() {
25
+		return this.cout+this.estim;
26
+	}
27
+	
28
+	//...
29
+	public void setEstimation(Node destination) {
30
+		this.estim=(float)destination.getPoint().distanceTo(this.sommet_courant.getPoint());
31
+	}
32
+	
33
+	//note: pourquoi l'icône de ce fichier de eclipse est-elle un peu différente?
34
+}

Loading…
Cancel
Save