|
@@ -1,22 +1,41 @@
|
1
|
1
|
package org.insa.graphs.algorithm.shortestpath;
|
2
|
2
|
|
3
|
3
|
|
|
4
|
+import org.insa.graphs.algorithm.AbstractInputData.Mode;
|
4
|
5
|
import org.insa.graphs.model.Arc;
|
5
|
6
|
import org.insa.graphs.model.Node;
|
6
|
7
|
|
7
|
8
|
public class AStarAlgorithm extends DijkstraAlgorithm {
|
8
|
9
|
|
|
10
|
+
|
|
11
|
+ private int sineg(int a, int b) {
|
|
12
|
+ int retour=a;
|
|
13
|
+ if (a<1)
|
|
14
|
+ retour=b;
|
|
15
|
+ return retour;
|
|
16
|
+ }
|
|
17
|
+
|
|
18
|
+ private int vitessemax=sineg(data.getMaximumSpeed(), data.getGraph().getGraphInformation().getMaximumSpeed());
|
|
19
|
+
|
9
|
20
|
|
10
|
21
|
public AStarAlgorithm(ShortestPathData data) {
|
11
|
22
|
super(data);
|
12
|
23
|
}
|
13
|
24
|
|
14
|
25
|
public Label LabelTyped(Node sommet, Arc padre, float prix) {
|
15
|
|
- return new LabelStar(sommet, padre, prix, (float)this.getInputData().getDestination().getPoint().distanceTo(sommet.getPoint()));
|
|
26
|
+
|
|
27
|
+ float difference=(float)this.getInputData().getDestination().getPoint().distanceTo(sommet.getPoint());
|
|
28
|
+ //prend la valeur de la distance à vol d'oiseau
|
|
29
|
+
|
|
30
|
+ if (data.getMode()==Mode.TIME)
|
|
31
|
+ difference=difference/this.vitessemax;
|
|
32
|
+
|
|
33
|
+ return new LabelStar(sommet, padre, prix, difference);
|
16
|
34
|
}
|
17
|
35
|
|
18
|
36
|
//particularités de A*:
|
19
|
37
|
//-comment trouver la distance à vol d'oiseau entre deux nodes?--------node.getpoint().distanceTo()?
|
|
38
|
+ //comment avoir (le temps min ou) la vitesse max?
|
20
|
39
|
//-comment initialiser le labelstar.estim de chaque node avec cette méthode
|
21
|
40
|
//-comment avoir des LabelStar et non des Label
|
22
|
41
|
|