|
@@ -125,7 +125,6 @@ public class DijkstraAlgorithm_et_AStarTest{
|
125
|
125
|
onenodijk = (new DijkstraAlgorithm(onenodata)).run();
|
126
|
126
|
emptydijk = (new DijkstraAlgorithm(emptydata)).run();
|
127
|
127
|
invalidijk = (new DijkstraAlgorithm(invalidata)).run();
|
128
|
|
- System.out.print(invalidijk.toString());//----------------------hey, look here
|
129
|
128
|
|
130
|
129
|
//initialisation des A*
|
131
|
130
|
asal = (new DijkstraAlgorithm(dataal)).run();
|
|
@@ -165,8 +164,8 @@ public class DijkstraAlgorithm_et_AStarTest{
|
165
|
164
|
assertTrue(dijkpt.getPath().isValid());
|
166
|
165
|
assertTrue(onenodijk.getPath().isValid());
|
167
|
166
|
assertTrue(emptydijk.getPath().isValid());
|
168
|
|
- assertFalse(invalidijk.getPath().isValid());
|
169
|
|
- }
|
|
167
|
+ assertTrue(invalidijk.getPath().isValid());
|
|
168
|
+ }//note: invalidata ne peut pas trouver de chemin et contient ainsi un path null, donc valide
|
170
|
169
|
|
171
|
170
|
@Test
|
172
|
171
|
public void cheminValideA() {
|
|
@@ -177,7 +176,7 @@ public class DijkstraAlgorithm_et_AStarTest{
|
177
|
176
|
assertTrue(aspt.getPath().isValid());
|
178
|
177
|
assertTrue(asonenod.getPath().isValid());
|
179
|
178
|
assertTrue(asempty.getPath().isValid());
|
180
|
|
- assertFalse(asinvalid.getPath().isValid());
|
|
179
|
+ assertTrue(asinvalid.getPath().isValid());
|
181
|
180
|
}
|
182
|
181
|
|
183
|
182
|
@Test
|
|
@@ -225,7 +224,7 @@ public class DijkstraAlgorithm_et_AStarTest{
|
225
|
224
|
|
226
|
225
|
//grand scénario avec oracle:
|
227
|
226
|
@Test
|
228
|
|
- public void testmap() throws FileNotFoundException, IOException{//A FAIRE
|
|
227
|
+ public void testMap() throws FileNotFoundException, IOException{//A FAIRE
|
229
|
228
|
|
230
|
229
|
String mapaddr = "/home/favary/Bureau/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps/haute-garonne.mapgr";
|
231
|
230
|
String pathaddr ="/home/favary/Bureau/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Paths/path_fr31_insa_aeroport_length.path";
|
|
@@ -244,23 +243,27 @@ public class DijkstraAlgorithm_et_AStarTest{
|
244
|
243
|
//comparaison de la longueur
|
245
|
244
|
}
|
246
|
245
|
|
247
|
|
- //TODO: sans oracle
|
|
246
|
+ //long car la map bretagne (sans oracle possible) est assez importante
|
248
|
247
|
@Test
|
249
|
248
|
public void testMapNoOracle() throws FileNotFoundException, IOException{//A FAIRE
|
250
|
249
|
|
251
|
|
- /*String mapaddr = "/home/favary/Bureau/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps/bretagne.mapgr";
|
|
250
|
+ String mapaddr = "/home/favary/Bureau/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps/bretagne.mapgr";
|
252
|
251
|
|
253
|
252
|
GraphReader graphread = new BinaryGraphReader(new DataInputStream(new BufferedInputStream(new FileInputStream(mapaddr))));
|
254
|
253
|
|
255
|
254
|
Graph graphmap = graphread.read();
|
256
|
|
- Node Origine = null;
|
257
|
|
- Node Destination = null;//ces trois lignes à faire!
|
258
|
|
- Path pathmap = Path.createShortestPathFromNodes(graphmap, null);
|
|
255
|
+ Node Origine = graphmap.getNodes().get(100000);//Brest
|
|
256
|
+ Node Destination = graphmap.getNodes().get(6000);//Rennes
|
|
257
|
+
|
|
258
|
+ //sans possibilité d'utiliser un pathmap, on fait une estimation arbitrairement basée sur la distance réelle
|
|
259
|
+ float estimation=1.2f*(float) (Origine.getPoint().distanceTo(Destination.getPoint()));
|
|
260
|
+ //1.2 très arbitraire, choisi car entre 1 (absurde) et sqrt(2)
|
|
261
|
+ //ne peut pas être adapté à tous les trajets, mais ici le graphe est assez couvrant et le trajet assez long
|
259
|
262
|
|
260
|
263
|
DijkstraAlgorithm dijkmap = new DijkstraAlgorithm(new ShortestPathData(graphmap, Origine, Destination, carlen));
|
261
|
264
|
AStarAlgorithm asmap = new AStarAlgorithm(new ShortestPathData(graphmap, Origine, Destination, carlen));
|
262
|
|
- assertTrue(dijkmap.run().getPath().getLength()<=pathmap.getLength());
|
263
|
|
- assertTrue(asmap.run().getPath().getLength()<=pathmap.getLength());
|
264
|
|
- //comparaison de la longueur */
|
|
265
|
+ assertTrue(dijkmap.run().getPath().getLength()<estimation);
|
|
266
|
+ assertTrue(asmap.run().getPath().getLength()<estimation);//<= car pas optimal sans oracle
|
|
267
|
+ //comparaison de la longueur
|
265
|
268
|
}
|
266
|
269
|
}
|