Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/03/12 15:04:27 (12 years ago)
Author:
spimming
Message:

#1894

  • restructured test program
  • new, faster version of AStar algorithm
  • moved method to obtain edge max speed to way
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning.Test/Program.cs

    r8350 r8408  
    1111  class Program {
    1212    static void Main(string[] args) {
     13      // For testing openstreetmap data is used
     14      // http://www.openstreetmap.org
     15      // Map data © OpenStreetMap contributors, CC BY-SA
     16
    1317      string file1 = @"..\..\OsmTestFiles\test.osm";
    1418      string file2 = @"..\..\OsmTestFiles\testNode1.osm";
     
    1822      string file6 = @"C:\dev\osmfiles\oberosterreich.highway.osm";
    1923
    20       Test(file5, 529102170, 1001363194, true, false);
    21       //Test(file6, 529102170, 1001363194, true, false);
    22       //Test(file6, 529102170, 31372732, false, true); // inz - hgb
     24      //TestD(file5, 529102170, 1001363194, true, false); // inz - inz
     25      //Test(file5, 529102170, 1001363194, true, false); // inz - inz
     26      //Test(file6, 529102170, 1001363194, true, false); // inz - inz
     27
     28      IDataSource ds = TestLoad(file6);
     29      Graph.Graph graph = new Graph.Graph(ds);
     30      TestRouter(new AStarAlgorithm(graph), 529102170, 31372732, false); // inz - hgb
     31      TestRouter(new AStarAlgorithmV2(graph), 529102170, 31372732, false); // inz - hgb
     32
     33      //TestLoadAndRouter(file6, typeof(DijkstraAlgorithm), 529102170, 31372732, false, false); // inz - hgb
     34      //TestLoadAndRouter(file6, typeof(AStarAlgorithm), 529102170, 31372732, false, false); // inz - hgb
     35      //TestLoadAndRouter(file6, typeof(AStarAlgorithmV2), 529102170, 31372732, false, false); // inz - hgb
     36
    2337      System.Console.Read();
    2438    }
    2539
    26     private static void Test(string filepath, long sourceNodeId, long targetNodeId, bool showResult, bool writeResultFile) {
     40    private static long[] TestRouter(IRouter router, long sourceNodeId, long targetNodeId, bool showResult) {
     41      Console.WriteLine("Test Router BEGIN ---------------------------------");
     42      Console.WriteLine("Type: " + router.GetType());
     43
     44      Console.Write("Calculate route ... ");
     45      var sw = Stopwatch.StartNew();
     46      long[] result = router.Calculate(sourceNodeId, targetNodeId);
     47      sw.Stop();
     48      Console.WriteLine("done.");
     49      Console.WriteLine("Execution Time: {0}", sw.Elapsed);
     50      Console.WriteLine();
     51      if (showResult) {
     52        Console.WriteLine("Result: ");
     53        foreach (long i in result) System.Console.Write(i + "; ");
     54        Console.WriteLine();
     55        Console.WriteLine();
     56      }
     57      Console.WriteLine("===================================================");
     58      Console.WriteLine();
     59      return result;
     60    }
     61
     62    private static IDataSource TestLoad(string filepath) {
    2763      FileInfo file = new FileInfo(filepath);
    28       Console.WriteLine("Test BEGIN ------------------------------");
     64      Console.WriteLine("Test Load Data BEGIN ------------------------------");
     65      Console.WriteLine("File name: {0}", file.Name);
     66      Console.WriteLine();
     67      Console.Write("Loading data ... ");
     68      var sw = Stopwatch.StartNew();
     69      XmlDataSource xmlDs = new XmlDataSource(filepath);
     70      sw.Stop();
     71      Console.WriteLine("done.");
     72      Console.WriteLine("Time: {0}", sw.Elapsed);
     73      Console.WriteLine();
     74      Console.WriteLine("===================================================");
     75      Console.WriteLine();
     76      return xmlDs;
     77    }
     78
     79    private static void TestLoadAndRouter(string filepath, Type routerType, long sourceNodeId, long targetNodeId, bool showResult, bool writeResultFile) {
     80      FileInfo file = new FileInfo(filepath);
     81      Console.WriteLine("Test Load and Route BEGIN -------------------------");
    2982      Console.WriteLine("File name: {0}", file.Name);
    3083      Console.WriteLine();
     
    3790      Console.WriteLine();
    3891      Graph.Graph graph = new Graph.Graph(xmlDs);
    39       //IRouter router = new DijkstraAlgorithm(graph);
    40       IRouter router = new AStarAlgorithm(graph);
     92      IRouter router = (IRouter)Activator.CreateInstance(routerType, graph);
    4193      Console.Write("Calculate route ... ");
    4294      sw = Stopwatch.StartNew();
     
    59111        WriteGPXFile(graph, result, resultFile);
    60112      }
    61       Console.WriteLine("=========================================");
     113      Console.WriteLine("===================================================");
    62114      Console.WriteLine();
    63115    }
Note: See TracChangeset for help on using the changeset viewer.