Changement bofs sur PCCTests

This commit is contained in:
Marie Brunetto 2023-04-19 17:43:23 +02:00
parent a7c6478d67
commit 9b191810c4

View file

@ -5,30 +5,14 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.IntStream;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
import org.junit.BeforeClass;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import org.insa.graphs.model.Graph;
import org.insa.graphs.model.Path;
import org.insa.graphs.model.io.BinaryGraphReader;
@ -48,31 +32,29 @@ public class PCCTest{
final static ArrayList<Path> paths = new ArrayList<>();
final static ArrayList<ArcInspector> arcInspectors = new ArrayList<>();
private static ShortestPathData DataSF_INSA, DataSF_France, DataSF_HauteGaronne, DataVL_INSA, DataVL_France, DataVL_HauteGaronne, DataVT_INSA, DataVT_France, DataVT_HauteGaronne;
private static ShortestPathData DataSF_INSA, DataSF_HauteGaronne, DataVL_INSA, DataVL_HauteGaronne, DataVT_INSA, DataVT_HauteGaronne;
@BeforeClass
public static void initAll() throws Exception
{
final String nomUser = "norgeux";
final String nomUser = "brunetto";
// Visit these directory to see the list of available files on Commetud.
//Récupération des cartes
mapNames.add("/home/" + nomUser + "/Bureau/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps/insa.mapgr");
mapNames.add("/home/" + nomUser + "/Bureau/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps/france.mapgr");
mapNames.add("/home/" + nomUser + "/Bureau/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps/haute-garonne.mapgr");
//Recupération des chemins
pathNames.add("/home/" + nomUser + "/Bureau/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Paths/path_fr31insa_rangueil_r2.path");
pathNames.add("/home/" + nomUser + "/Bureau/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Paths/path_fr_insa_tour.path");
pathNames.add("/home/" + nomUser + "/Bureau/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Paths/path_fr31_insa_aeroport_length.path");
// Extraction des données des cartes et chemins
for(int i = 0; i<3; i++)
for(int i = 0; i<2; i++)
{
graphs.set(i,new BinaryGraphReader(new DataInputStream(new BufferedInputStream(new FileInputStream(mapNames.get(i))))).read());
paths.set(i,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(i))))).read());
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());
@ -83,23 +65,19 @@ public class PCCTest{
paths.add(new BinaryPathReader(new DataInputStream(new BufferedInputStream(new FileInputStream(pathNames.get(2))))).readPath(graphs.get(2)));*/
// Creation des filtres
arcInspectors.set(0, ArcInspectorFactory.getAllFilters().get(0)) ; //Sans Filtres
arcInspectors.set(1, ArcInspectorFactory.getAllFilters().get(1)); //Voiture, longueur
arcInspectors.set(2, ArcInspectorFactory.getAllFilters().get(2)); //Voiture, temps
arcInspectors.add(ArcInspectorFactory.getAllFilters().get(0)) ; //Sans Filtres
arcInspectors.add(ArcInspectorFactory.getAllFilters().get(1)); //Voiture, longueur
arcInspectors.add(ArcInspectorFactory.getAllFilters().get(2)); //Voiture, temps
//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_France = new ShortestPathData(graphs.get(1), paths.get(1).getOrigin(), paths.get(1).getDestination(), arcInspectors.get(0));
DataSF_HauteGaronne = new ShortestPathData(graphs.get(2), paths.get(2).getOrigin(), paths.get(2).getDestination(), arcInspectors.get(0));
DataVL_INSA = new ShortestPathData(graphs.get(0), paths.get(0).getOrigin(), paths.get(0).getDestination(), arcInspectors.get(1));
DataVL_France = new ShortestPathData(graphs.get(1), paths.get(1).getOrigin(), paths.get(1).getDestination(), arcInspectors.get(1));
DataVL_HauteGaronne = new ShortestPathData(graphs.get(2), paths.get(2).getOrigin(), paths.get(2).getDestination(), arcInspectors.get(1));
DataVT_INSA = new ShortestPathData(graphs.get(0), paths.get(0).getOrigin(), paths.get(0).getDestination(), arcInspectors.get(2));
DataVT_France = new ShortestPathData(graphs.get(1), paths.get(1).getOrigin(), paths.get(1).getDestination(), arcInspectors.get(2));
DataVT_HauteGaronne = new ShortestPathData(graphs.get(2), paths.get(2).getOrigin(), paths.get(2).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));
System.out.println("");
}
@ -113,15 +91,11 @@ public class PCCTest{
dji = new DijkstraAlgorithm(DataSF_INSA);
bf = new BellmanFordAlgorithm(DataSF_INSA);
assertEquals(bf.run(), dji.run());
dji = new DijkstraAlgorithm(DataSF_France);
bf = new BellmanFordAlgorithm(DataSF_France);
assertEquals(bf.run(), dji.run());
assertEquals(bf.run().getPath().getLength(), dji.run().getPath().getLength(), 0.05f);
dji = new DijkstraAlgorithm(DataSF_HauteGaronne);
bf = new BellmanFordAlgorithm(DataSF_HauteGaronne);
assertEquals(bf.run(), dji.run());
assertEquals(bf.run().getPath().getLength(), dji.run().getPath().getLength(), 0.05f);
}
@ -130,16 +104,11 @@ public class PCCTest{
public void TestDikjstraVL() {
dji = new DijkstraAlgorithm(DataVL_INSA);
bf = new BellmanFordAlgorithm(DataVL_INSA);
assertEquals(bf.run(), dji.run());
dji = new DijkstraAlgorithm(DataVL_France);
bf = new BellmanFordAlgorithm(DataVL_France);
assertEquals(bf.run(), dji.run());
assertTrue(dji.run().isFeasible());
dji = new DijkstraAlgorithm(DataVL_HauteGaronne);
bf = new BellmanFordAlgorithm(DataVL_HauteGaronne);
assertEquals(bf.run(), dji.run());
assertEquals(bf.run().getPath().getLength(), dji.run().getPath().getLength(), 0.05f);
}
@ -149,33 +118,24 @@ public class PCCTest{
dji = new DijkstraAlgorithm(DataVT_INSA);
bf = new BellmanFordAlgorithm(DataVT_INSA);
assertEquals(bf.run(), dji.run());
assertEquals(bf.run().getPath().getLength(), dji.run().getPath().getLength(), 0.05f);
dji = new DijkstraAlgorithm(DataVT_France);
bf = new BellmanFordAlgorithm(DataVT_France);
assertEquals(bf.run(), dji.run());
dji = new DijkstraAlgorithm(DataVT_HauteGaronne);
bf = new BellmanFordAlgorithm(DataVT_HauteGaronne);
assertEquals(bf.run(), dji.run());
assertEquals(bf.run().getPath().getLength(), dji.run().getPath().getLength(), 0.05f);
}
/* TEST A* SANS FILTRE */
@Test
public void TestAStarSF() {
as = new AStarAlgorithm(DataSF_INSA);
bf = new BellmanFordAlgorithm(DataSF_INSA);
assertEquals(bf.run(), as.run());
as = new AStarAlgorithm(DataSF_INSA);
bf = new BellmanFordAlgorithm(DataSF_France);
assertEquals(bf.run(), as.run());
dji = new DijkstraAlgorithm(DataVT_INSA);
bf = new BellmanFordAlgorithm(DataVT_INSA);
assertEquals(bf.run().getPath().getLength(), dji.run().getPath().getLength(), 0.05f);
as = new AStarAlgorithm(DataSF_HauteGaronne);
bf = new BellmanFordAlgorithm(DataSF_HauteGaronne);
assertEquals(bf.run(), as.run());
assertEquals(bf.run().getPath().getLength(), dji.run().getPath().getLength(), 0.05f);
}
@ -183,17 +143,12 @@ public class PCCTest{
@Test
public void TestAStarVL() {
as = new AStarAlgorithm(DataVL_INSA);
bf = new BellmanFordAlgorithm(DataVL_INSA);
assertEquals(bf.run(), as.run());
as = new AStarAlgorithm(DataVL_INSA);
bf = new BellmanFordAlgorithm(DataVL_France);
assertEquals(bf.run(), as.run());
dji = new DijkstraAlgorithm(DataVL_INSA);
assertTrue(dji.run().isFeasible());
as = new AStarAlgorithm(DataVL_HauteGaronne);
bf = new BellmanFordAlgorithm(DataVL_HauteGaronne);
assertEquals(bf.run(), as.run());
assertEquals(bf.run().getPath().getLength(), dji.run().getPath().getLength(), 0.05f);
}
@ -203,15 +158,11 @@ public class PCCTest{
as = new AStarAlgorithm(DataVT_INSA);
bf = new BellmanFordAlgorithm(DataVT_INSA);
assertEquals(bf.run(), as.run());
as = new AStarAlgorithm(DataVT_INSA);
bf = new BellmanFordAlgorithm(DataVT_France);
assertEquals(bf.run(), as.run());
assertEquals(bf.run().getPath().getLength(), dji.run().getPath().getLength(), 0.05f);
as = new AStarAlgorithm(DataVT_HauteGaronne);
bf = new BellmanFordAlgorithm(DataVT_HauteGaronne);
assertEquals(bf.run(), as.run());
assertEquals(bf.run().getPath().getLength(), dji.run().getPath().getLength(), 0.05f);
}