Merge branch 'master' of https://git.etud.insa-toulouse.fr/brunetto/BEGraphes
This commit is contained in:
當前提交
3709024dbd
共有 1 個文件被更改,包括 25 次插入 和 59 次删除
|
@ -2,33 +2,16 @@ 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;
|
||||||
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.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 org.junit.BeforeClass;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
|
|
||||||
import org.insa.graphs.model.Graph;
|
import org.insa.graphs.model.Graph;
|
||||||
import org.insa.graphs.model.Path;
|
import org.insa.graphs.model.Path;
|
||||||
import org.insa.graphs.model.io.BinaryGraphReader;
|
import org.insa.graphs.model.io.BinaryGraphReader;
|
||||||
|
@ -48,58 +31,44 @@ public class PCCTest{
|
||||||
final static ArrayList<Path> paths = new ArrayList<>();
|
final static ArrayList<Path> paths = new ArrayList<>();
|
||||||
final static ArrayList<ArcInspector> arcInspectors = 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
|
@BeforeClass
|
||||||
public static void initAll() throws Exception
|
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.
|
// Visit these directory to see the list of available files on Commetud.
|
||||||
|
|
||||||
//Récupération des cartes
|
//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/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");
|
mapNames.add("/home/" + nomUser + "/Bureau/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps/haute-garonne.mapgr");
|
||||||
//Recupération des chemins
|
//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_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");
|
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
|
// Extraction des données des cartes et chemins
|
||||||
|
|
||||||
for(int i = 0; i<3; i++)
|
for(int i = 0; i<2; i++)
|
||||||
{
|
{
|
||||||
graphs.add(i,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(i,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)));
|
arcInspectors.add(ArcInspectorFactory.getAllFilters().get(0)) ; //Sans Filtres
|
||||||
paths.add(new BinaryPathReader(new DataInputStream(new BufferedInputStream(new FileInputStream(pathNames.get(1))))).readPath(graphs.get(1)));
|
arcInspectors.add(ArcInspectorFactory.getAllFilters().get(1)); //Voiture, longueur
|
||||||
paths.add(new BinaryPathReader(new DataInputStream(new BufferedInputStream(new FileInputStream(pathNames.get(2))))).readPath(graphs.get(2)));*/
|
arcInspectors.add(ArcInspectorFactory.getAllFilters().get(2)); //Voiture, temps
|
||||||
// Creation des filtres
|
|
||||||
|
|
||||||
arcInspectors.add(0, ArcInspectorFactory.getAllFilters().get(0)) ; //Sans Filtres
|
|
||||||
arcInspectors.add(1, ArcInspectorFactory.getAllFilters().get(1)); //Voiture, longueur
|
|
||||||
arcInspectors.add(2, ArcInspectorFactory.getAllFilters().get(2)); //Voiture, temps
|
|
||||||
|
|
||||||
//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_France = new ShortestPathData(graphs.get(1), paths.get(1).getOrigin(), paths.get(1).getDestination(), arcInspectors.get(0));
|
DataSF_HauteGaronne = 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_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(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));
|
DataVL_INSA = new ShortestPathData(graphs.get(0), paths.get(0).getOrigin(), paths.get(0).getDestination(), arcInspectors.get(2));
|
||||||
DataVT_INSA = new ShortestPathData(graphs.get(0), paths.get(0).getOrigin(), paths.get(0).getDestination(), arcInspectors.get(2));
|
DataVL_HauteGaronne = new ShortestPathData(graphs.get(1), paths.get(1).getOrigin(), paths.get(1).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));
|
|
||||||
|
|
||||||
System.out.println("");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,11 +82,11 @@ public class PCCTest{
|
||||||
|
|
||||||
dji = new DijkstraAlgorithm(DataSF_INSA);
|
dji = new DijkstraAlgorithm(DataSF_INSA);
|
||||||
bf = new BellmanFordAlgorithm(DataSF_INSA);
|
bf = new BellmanFordAlgorithm(DataSF_INSA);
|
||||||
assertEquals(bf.run(), dji.run());
|
assertEquals(bf.run().getPath().getLength(), dji.run().getPath().getLength(), 0.05f);
|
||||||
|
|
||||||
dji = new DijkstraAlgorithm(DataSF_HauteGaronne);
|
dji = new DijkstraAlgorithm(DataSF_HauteGaronne);
|
||||||
bf = new BellmanFordAlgorithm(DataSF_HauteGaronne);
|
bf = new BellmanFordAlgorithm(DataSF_HauteGaronne);
|
||||||
assertEquals(bf.run(), dji.run());
|
assertEquals(bf.run().getPath().getLength(), dji.run().getPath().getLength(), 0.05f);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,12 +95,11 @@ public class PCCTest{
|
||||||
public void TestDikjstraVL() {
|
public void TestDikjstraVL() {
|
||||||
|
|
||||||
dji = new DijkstraAlgorithm(DataVL_INSA);
|
dji = new DijkstraAlgorithm(DataVL_INSA);
|
||||||
bf = new BellmanFordAlgorithm(DataVL_INSA);
|
assertTrue(dji.run().isFeasible());
|
||||||
assertEquals(bf.run(), dji.run());
|
|
||||||
|
|
||||||
dji = new DijkstraAlgorithm(DataVL_HauteGaronne);
|
dji = new DijkstraAlgorithm(DataVL_HauteGaronne);
|
||||||
bf = new BellmanFordAlgorithm(DataVL_HauteGaronne);
|
bf = new BellmanFordAlgorithm(DataVL_HauteGaronne);
|
||||||
assertEquals(bf.run(), dji.run());
|
assertEquals(bf.run().getPath().getLength(), dji.run().getPath().getLength(), 0.05f);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,25 +109,24 @@ public class PCCTest{
|
||||||
|
|
||||||
dji = new DijkstraAlgorithm(DataVT_INSA);
|
dji = new DijkstraAlgorithm(DataVT_INSA);
|
||||||
bf = new BellmanFordAlgorithm(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_HauteGaronne);
|
dji = new DijkstraAlgorithm(DataVT_HauteGaronne);
|
||||||
bf = new BellmanFordAlgorithm(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 A* SANS FILTRE */
|
||||||
@Test
|
@Test
|
||||||
public void TestAStarSF() {
|
public void TestAStarSF() {
|
||||||
|
|
||||||
as = new AStarAlgorithm(DataSF_INSA);
|
as = new AStarAlgorithm(DataSF_INSA);
|
||||||
bf = new BellmanFordAlgorithm(DataSF_INSA);
|
bf = new BellmanFordAlgorithm(DataSF_INSA);
|
||||||
assertEquals(bf.run(), as.run());
|
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(), as.run());
|
assertEquals(bf.run().getPath().getLength(), as.run().getPath().getLength(), 0.05f);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,12 +135,11 @@ public class PCCTest{
|
||||||
public void TestAStarVL() {
|
public void TestAStarVL() {
|
||||||
|
|
||||||
as = new AStarAlgorithm(DataVL_INSA);
|
as = new AStarAlgorithm(DataVL_INSA);
|
||||||
bf = new BellmanFordAlgorithm(DataVL_INSA);
|
assertTrue(as.run().isFeasible());
|
||||||
assertEquals(bf.run(), as.run());
|
|
||||||
|
|
||||||
as = new AStarAlgorithm(DataVL_HauteGaronne);
|
as = new AStarAlgorithm(DataVL_HauteGaronne);
|
||||||
bf = new BellmanFordAlgorithm(DataVL_HauteGaronne);
|
bf = new BellmanFordAlgorithm(DataVL_HauteGaronne);
|
||||||
assertEquals(bf.run(), as.run());
|
assertEquals(bf.run().getPath().getLength(), as.run().getPath().getLength(), 0.05f);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,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(), as.run());
|
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(), as.run());
|
assertEquals(bf.run().getPath().getLength(), as.run().getPath().getLength(), 0.05f);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
載入中…
Reference in a new issue