Encore un PCCTest

This commit is contained in:
Marie Brunetto 2023-04-19 17:47:47 +02:00
parent 9b191810c4
commit 41f1b62d26

View file

@ -2,7 +2,6 @@ package org.insa.graphs.algorithm.utils;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList; import java.util.ArrayList;
@ -56,14 +55,6 @@ public class PCCTest{
graphs.add(new BinaryGraphReader(new DataInputStream(new BufferedInputStream(new FileInputStream(mapNames.get(i))))).read()); graphs.add(new BinaryGraphReader(new DataInputStream(new BufferedInputStream(new FileInputStream(mapNames.get(i))))).read());
paths.add(new BinaryPathReader(new DataInputStream(new BufferedInputStream(new FileInputStream(pathNames.get(i))))).readPath(graphs.get(i))); paths.add(new BinaryPathReader(new DataInputStream(new BufferedInputStream(new FileInputStream(pathNames.get(i))))).readPath(graphs.get(i)));
} }
/*
graphs.add(new BinaryGraphReader(new DataInputStream(new BufferedInputStream(new FileInputStream(mapNames.get(0))))).read());
graphs.add(new BinaryGraphReader(new DataInputStream(new BufferedInputStream(new FileInputStream(mapNames.get(1))))).read());
paths.add(new BinaryPathReader(new DataInputStream(new BufferedInputStream(new FileInputStream(pathNames.get(0))))).readPath(graphs.get(0)));
paths.add(new BinaryPathReader(new DataInputStream(new BufferedInputStream(new FileInputStream(pathNames.get(1))))).readPath(graphs.get(1)));
paths.add(new BinaryPathReader(new DataInputStream(new BufferedInputStream(new FileInputStream(pathNames.get(2))))).readPath(graphs.get(2)));*/
// Creation des filtres
arcInspectors.add(ArcInspectorFactory.getAllFilters().get(0)) ; //Sans Filtres arcInspectors.add(ArcInspectorFactory.getAllFilters().get(0)) ; //Sans Filtres
arcInspectors.add(ArcInspectorFactory.getAllFilters().get(1)); //Voiture, longueur arcInspectors.add(ArcInspectorFactory.getAllFilters().get(1)); //Voiture, longueur
@ -72,11 +63,11 @@ public class PCCTest{
//Créations des données pour les algos //Créations des données pour les algos
DataSF_INSA = new ShortestPathData(graphs.get(0), paths.get(0).getOrigin(), paths.get(0).getDestination(), arcInspectors.get(0)); DataSF_INSA = new ShortestPathData(graphs.get(0), paths.get(0).getOrigin(), paths.get(0).getDestination(), arcInspectors.get(0));
DataSF_HauteGaronne = new ShortestPathData(graphs.get(2), paths.get(2).getOrigin(), paths.get(2).getDestination(), arcInspectors.get(0)); DataSF_HauteGaronne = new ShortestPathData(graphs.get(1), paths.get(1).getOrigin(), paths.get(1).getDestination(), arcInspectors.get(0));
DataVL_INSA = new ShortestPathData(graphs.get(0), paths.get(0).getOrigin(), paths.get(0).getDestination(), arcInspectors.get(1)); DataVL_INSA = new ShortestPathData(graphs.get(0), paths.get(0).getOrigin(), paths.get(0).getDestination(), arcInspectors.get(1));
DataVL_HauteGaronne = new ShortestPathData(graphs.get(2), paths.get(2).getOrigin(), paths.get(2).getDestination(), arcInspectors.get(1)); DataVL_HauteGaronne = new ShortestPathData(graphs.get(1), paths.get(1).getOrigin(), paths.get(1).getDestination(), arcInspectors.get(1));
DataVL_INSA = new ShortestPathData(graphs.get(0), paths.get(0).getOrigin(), paths.get(0).getDestination(), arcInspectors.get(2)); DataVL_INSA = new ShortestPathData(graphs.get(0), paths.get(0).getOrigin(), paths.get(0).getDestination(), arcInspectors.get(2));
DataVL_HauteGaronne = new ShortestPathData(graphs.get(2), paths.get(2).getOrigin(), paths.get(2).getDestination(), arcInspectors.get(2)); DataVL_HauteGaronne = new ShortestPathData(graphs.get(1), paths.get(1).getOrigin(), paths.get(1).getDestination(), arcInspectors.get(2));
} }
@ -130,12 +121,12 @@ public class PCCTest{
/* TEST A* SANS FILTRE */ /* TEST A* SANS FILTRE */
@Test @Test
public void TestAStarSF() { public void TestAStarSF() {
dji = new DijkstraAlgorithm(DataVT_INSA); as = new AStarAlgorithm(DataSF_INSA);
bf = new BellmanFordAlgorithm(DataVT_INSA); bf = new BellmanFordAlgorithm(DataSF_INSA);
assertEquals(bf.run().getPath().getLength(), dji.run().getPath().getLength(), 0.05f); assertEquals(bf.run().getPath().getLength(), as.run().getPath().getLength(), 0.05f);
as = new AStarAlgorithm(DataSF_HauteGaronne); as = new AStarAlgorithm(DataSF_HauteGaronne);
bf = new BellmanFordAlgorithm(DataSF_HauteGaronne); bf = new BellmanFordAlgorithm(DataSF_HauteGaronne);
assertEquals(bf.run().getPath().getLength(), dji.run().getPath().getLength(), 0.05f); assertEquals(bf.run().getPath().getLength(), as.run().getPath().getLength(), 0.05f);
} }
@ -143,12 +134,12 @@ public class PCCTest{
@Test @Test
public void TestAStarVL() { public void TestAStarVL() {
dji = new DijkstraAlgorithm(DataVL_INSA); as = new AStarAlgorithm(DataVL_INSA);
assertTrue(dji.run().isFeasible()); assertTrue(as.run().isFeasible());
as = new AStarAlgorithm(DataVL_HauteGaronne); as = new AStarAlgorithm(DataVL_HauteGaronne);
bf = new BellmanFordAlgorithm(DataVL_HauteGaronne); bf = new BellmanFordAlgorithm(DataVL_HauteGaronne);
assertEquals(bf.run().getPath().getLength(), dji.run().getPath().getLength(), 0.05f); assertEquals(bf.run().getPath().getLength(), as.run().getPath().getLength(), 0.05f);
} }
@ -158,11 +149,11 @@ public class PCCTest{
as = new AStarAlgorithm(DataVT_INSA); as = new AStarAlgorithm(DataVT_INSA);
bf = new BellmanFordAlgorithm(DataVT_INSA); bf = new BellmanFordAlgorithm(DataVT_INSA);
assertEquals(bf.run().getPath().getLength(), dji.run().getPath().getLength(), 0.05f); assertEquals(bf.run().getPath().getLength(), as.run().getPath().getLength(), 0.05f);
as = new AStarAlgorithm(DataVT_HauteGaronne); as = new AStarAlgorithm(DataVT_HauteGaronne);
bf = new BellmanFordAlgorithm(DataVT_HauteGaronne); bf = new BellmanFordAlgorithm(DataVT_HauteGaronne);
assertEquals(bf.run().getPath().getLength(), dji.run().getPath().getLength(), 0.05f); assertEquals(bf.run().getPath().getLength(), as.run().getPath().getLength(), 0.05f);
} }