Changeset 8516
- Timestamp:
- 08/22/12 11:46:08 (12 years ago)
- Location:
- branches/RoutePlanning
- Files:
-
- 32 added
- 12 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RoutePlanning/HeuristicLab.Algorithms.GraphRouting/3.3/AStarAlgorithmV3.cs
r8481 r8516 2 2 using System; 3 3 using System.Collections.Generic; 4 using HeuristicLab.Problems.RoutePlanning.Graph; 4 using HeuristicLab.Algorithms.GraphRouting.Interfaces; 5 using HeuristicLab.Problems.RoutePlanning.Interfaces; 5 6 namespace HeuristicLab.Algorithms.GraphRouting { 6 7 public class AStarAlgorithmV3 : IRouter { -
branches/RoutePlanning/HeuristicLab.Algorithms.GraphRouting/3.3/BidirectionalDijkstraAlgorithmV2.cs
r8481 r8516 2 2 using System; 3 3 using System.Collections.Generic; 4 using HeuristicLab.Problems.RoutePlanning.Graph; 4 using HeuristicLab.Algorithms.GraphRouting.Interfaces; 5 using HeuristicLab.Problems.RoutePlanning.Interfaces; 5 6 namespace HeuristicLab.Algorithms.GraphRouting { 6 7 public class BidrectionalDijkstraAlgorithmV2 : IRouter { -
branches/RoutePlanning/HeuristicLab.Algorithms.GraphRouting/3.3/DijkstraAlgorithmV2.cs
r8509 r8516 2 2 using System; 3 3 using System.Collections.Generic; 4 using HeuristicLab.Problems.RoutePlanning.Graph; 4 using HeuristicLab.Algorithms.GraphRouting.Interfaces; 5 using HeuristicLab.Problems.RoutePlanning.Interfaces; 5 6 namespace HeuristicLab.Algorithms.GraphRouting { 6 7 public class DijkstraAlgorithmV2 : IRouter { -
branches/RoutePlanning/HeuristicLab.Algorithms.GraphRouting/3.3/HeuristicLab.Algorithms.GraphRouting.csproj
r8481 r8516 57 57 </ItemGroup> 58 58 <ItemGroup> 59 <Compile Include="AStarAlgorithm.cs" />60 <Compile Include="AStarAlgorithmV2.cs" />61 <Compile Include="BidirectionalDijkstraAlgorithm.cs" />62 59 <Compile Include="AStarAlgorithmV3.cs" /> 63 60 <Compile Include="BidirectionalDijkstraAlgorithmV2.cs" /> 64 61 <Compile Include="DijkstraAlgorithmV2.cs" /> 65 <Compile Include="DijkstraAlgorithm.cs" />66 62 <Compile Include="GraphRoutingAlgorithm.cs" /> 67 <Compile Include="I Router.cs" />68 <Compile Include=" Pair.cs" />63 <Compile Include="Interfaces\IRouter.cs" /> 64 <Compile Include="Utilities\Pair.cs" /> 69 65 <Compile Include="Plugin.cs" /> 70 <Compile Include=" PriorityQueue.cs" />71 <Compile Include=" PriorityQueueOld.cs" />66 <Compile Include="Utilities\PriorityQueue.cs" /> 67 <Compile Include="Utilities\PriorityQueueOld.cs" /> 72 68 <Compile Include="Properties\AssemblyInfo.cs" /> 73 69 </ItemGroup> -
branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning.Test/Program.cs
r8514 r8516 7 7 using System.Xml; 8 8 using HeuristicLab.Algorithms.GraphRouting; 9 using HeuristicLab.Problems.RoutePlanning.Graph; 10 using HeuristicLab.Problems.RoutePlanning.Osm; 11 using HeuristicLab.Problems.RoutePlanning.Osm.Data; 9 using HeuristicLab.Algorithms.GraphRouting.Interfaces; 10 using HeuristicLab.Problems.RoutePlanning.Data.DIMACS; 11 using HeuristicLab.Problems.RoutePlanning.Data.Osm; 12 using HeuristicLab.Problems.RoutePlanning.Interfaces; 13 using HeuristicLab.Problems.RoutePlanning.RoutingGraph; 14 15 // For testing openstreetmap data is used 16 // http://www.openstreetmap.org 17 // Map data © OpenStreetMap contributors, CC BY-SA 18 12 19 namespace HeuristicLab.Problems.RoutePlanning.Test { 13 20 class Program { 14 21 static void Main(string[] args) { 15 // For testing openstreetmap data is used16 // http://www.openstreetmap.org17 // Map data © OpenStreetMap contributors, CC BY-SA18 19 22 string file1 = @"..\..\OsmTestFiles\test.osm"; 20 23 string file2 = @"..\..\OsmTestFiles\testNode1.osm"; 21 24 string file3 = @"..\..\OsmTestFiles\testWay1.osm"; 22 25 string file4 = @"..\..\OsmTestFiles\testRelation1.osm"; 23 string file5 = @" ..\..\OsmTestFiles\test_mid.osm";26 string file5 = @"C:\dev\osmfiles\test_mid.osm"; 24 27 string file6 = @"C:\dev\osmfiles\oberosterreich.highway.osm"; 25 28 string file7 = @"C:\dev\osmfiles\austria.highway.osm"; … … 29 32 string fileNYCoords = @"C:\dev\DIMACSfiles\USA-road-d.NY.co.gz"; 30 33 31 //IDataSource ds = TestLoad(typeof(XmlDataSource), file7); 32 //IDataSource ds = TestLoad(typeof(OsmDataSource), file6); 33 //OsmGraph graph = new OsmGraph(ds); 34 35 //IGraph graphNew = TestGetRoutingGraph(ds); 36 //ExecuteBenchmark(graphNew, typeof(AStarAlgorithmV3), 262144, 20); 37 38 //IRouter router = new AStarAlgorithmV3(graphNew); 34 IDataSource ds1 = TestLoad(typeof(OsmDataSource), file6); 35 IDataSource ds2 = TestLoad(typeof(DIMACSDataSource), fileNYCoords, fileNYArcs); 36 37 //IGraph graph = TestGetRoutingGraph(ds1); 38 //ExecuteBenchmark(graph, typeof(AStarAlgorithmV3), 262144, 20); 39 40 //IRouter router = new AStarAlgorithmV3(graph); 39 41 //long[] r = router.Calculate(266733493, 986825165); 40 ////long[] r = router.Calculate(998717680, 986825165); 41 42 //IDataSource ds = new DIMACSDataSource(fileNYCoords, fileNYArcs); 43 //IDataSource ds = new OsmDataSource(file5); 44 45 //TestRouter(new DijkstraAlgorithm(graph), 529102170, 1001363194, true); 46 //TestRouter(new DijkstraAlgorithmV2(graphNew), 529102170, 1001363194, true); 47 //TestRouter(new DijkstraAlgorithm(graph), 529102170, 31372732, false); // inz - hgb 48 //TestRouter(new DijkstraAlgorithmV2(graphNew), 529102170, 31372732, false); // inz - hgb 49 //TestRouter(new BidrectionalDijkstraAlgorithm(graph), 529102170, 31372732, false); // inz - hgb 50 //TestRouter(new BidrectionalDijkstraAlgorithmV2(graphNew), 529102170, 31372732, false); // inz - hgb 51 //TestRouter(new AStarAlgorithm(graph), 529102170, 31372732, false); // inz - hgb 52 //TestRouter(new AStarAlgorithmV2(graph), 529102170, 31372732, false); // inz - hgb 53 //TestRouter(new AStarAlgorithmV3(graphNew), 529102170, 31372732, false); // inz - hgb 54 55 //TestRouter(new AStarAlgorithmV2(graph), 763113382, 1078628481, false); // bregenz (bahnhofstr) - podersdorf (??) 56 //TestRouter(new AStarAlgorithmV3(graphNew), 346151602, 33196510, false); // bregenz (bahnhofstr) - wien (stepansplatz) 57 //TestRouter(new AStarAlgorithmV2(graph), 346151602, 33196510, false); // bregenz (bahnhofstr) - wien (stepansplatz) 58 59 //TestRouter(new AStarAlgorithmV2(graph), 32044987, 261576106, false); //vorarblberg 60 //TestRouter(new AStarAlgorithmV3(graphNew), 32044987, 261576106, false); //vorarblberg 61 62 //TestLoadAndRouter(file6, typeof(DijkstraAlgorithm), 529102170, 31372732, false, false); // inz - hgb 63 //TestLoadAndRouter(file6, typeof(AStarAlgorithm), 529102170, 31372732, false, false); // inz - hgb 64 //TestLoadAndRouter(file6, typeof(AStarAlgorithmV2), 529102170, 31372732, false, true); // inz - hgb 65 66 //TestLoadAndRouter(file6, typeof(DijkstraAlgorithm), 529102170, 1001363194, true, false); 67 //TestLoadAndRouter(file6, typeof(DijkstraAlgorithm), 529102170, 1001363194, true, false); 68 //TestLoadAndRouter(file6, typeof(AStarAlgorithm), 529102170, 1001363194, true, false); 69 //TestLoadAndRouter(file6, typeof(AStarAlgorithmV2), 529102170, 1001363194, true, false); 70 //TestLoadAndRouter(file6, typeof(BidrectionalDijkstraAlgorithm), 529102170, 1001363194, true, false); 71 72 //TestLoadAndRouter(file5, typeof(DijkstraAlgorithm), 529102170, 1001363194, true, false); 73 //TestLoadAndRouter(file5, typeof(BidrectionalDijkstraAlgorithm), 529102170, 1001363194, true, true); 74 //TestLoadAndRouter(file6, typeof(BidrectionalDijkstraAlgorithm), 529102170, 31372732, false, true); // inz - hgb 75 76 TestLoadAndRouterNew(file6, typeof(AStarAlgorithmV3), 529102170, 31372732, false, true); // inz - hgb 77 //TestLoadAndRouterNew(file6, typeof(DijkstraAlgorithmV2), 529102170, 31372732, false, true); 78 //TestLoadAndRouterNew(file6, typeof(BidrectionalDijkstraAlgorithmV2), 529102170, 31372732, false, true); 79 //TestLoadAndRouterNew(file6, typeof(AStarAlgorithmV3), 529102170, 31372732, false, true); 80 81 //TestLoadAndRouter(file7, typeof(AStarAlgorithmV2), 346151602, 33196510, false, true); // bregenz (bahnhofstr) - wien (stepansplatz) 82 //TestLoadAndRouterNew(file7, typeof(AStarAlgorithmV3), 346151602, 33196510, false, true); // bregenz (bahnhofstr) - wien (stepansplatz) 83 84 //TestLoadAndRouter(file8, typeof(AStarAlgorithmV2), 32044987, 261576106, false, true); //vorarblberg 42 //long[] r = router.Calculate(998717680, 986825165); 43 44 //TestRouter(new DijkstraAlgorithmV2(graph), 529102170, 1001363194, true); // inz 45 46 //TestRouter(new DijkstraAlgorithmV2(graph), 529102170, 31372732, false); // inz - hgb 47 //TestRouter(new BidrectionalDijkstraAlgorithmV2(graph), 529102170, 31372732, false); // inz - hgb 48 //TestRouter(new AStarAlgorithmV3(graph), 529102170, 31372732, false); // inz - hgb 49 50 //TestRouter(new AStarAlgorithmV3(graph), 346151602, 33196510, false); // bregenz (bahnhofstr) - wien (stepansplatz) 51 52 //TestRouter(new AStarAlgorithmV3(graph), 32044987, 261576106, false); //vorarblberg 53 54 //TestLoadAndRouter(typeof(OsmDataSource), file6, typeof(AStarAlgorithmV3), 529102170, 31372732, false, true); // inz - hgb 55 //TestLoadAndRouter(typeof(OsmDataSource), file6, typeof(DijkstraAlgorithmV2), 529102170, 31372732, false, true); // inz - hgb 56 //TestLoadAndRouter(typeof(OsmDataSource), file6, typeof(BidrectionalDijkstraAlgorithmV2), 529102170, 31372732, false, true); // inz - hgb 57 //TestLoadAndRouter(typeof(OsmDataSource), file6, typeof(AStarAlgorithmV3), 529102170, 31372732, false, true); // inz - hgb 58 //TestLoadAndRouter(typeof(OsmDataSource), file7, typeof(AStarAlgorithmV3), 346151602, 33196510, false, true); // bregenz (bahnhofstr) - wien (stepansplatz) 85 59 86 60 System.Console.Read(); … … 126 100 } 127 101 128 private static void TestLoadAndRouter( string filepath, Type routerType, long sourceNodeId, long targetNodeId, bool showResult, bool writeResultFile) {102 private static void TestLoadAndRouter(Type dsType, string filepath, Type routerType, long sourceNodeId, long targetNodeId, bool showResult, bool writeResultFile) { 129 103 FileInfo file = new FileInfo(filepath); 130 104 Console.WriteLine("Test Load and Route BEGIN -------------------------"); … … 133 107 Console.Write("Loading data ... "); 134 108 var sw = Stopwatch.StartNew(); 135 XmlDataSource xmlDs = new XmlDataSource(filepath);109 IDataSource ds = (IDataSource)Activator.CreateInstance(dsType, filepath); 136 110 sw.Stop(); 137 111 Console.WriteLine("done."); 138 112 Console.WriteLine("Loading Time: {0}", sw.Elapsed); 139 113 Console.WriteLine(); 140 OsmGraph graph = new OsmGraph(xmlDs);114 IGraph graph = ds.GetRoutingGraph(); 141 115 IRouter router = (IRouter)Activator.CreateInstance(routerType, graph); 142 116 Console.Write("Calculate route ... "); … … 164 138 } 165 139 166 private static void TestLoadAndRouterNew(string filepath, Type routerType, long sourceNodeId, long targetNodeId, bool showResult, bool writeResultFile) { 167 FileInfo file = new FileInfo(filepath); 168 Console.WriteLine("Test Load and Route BEGIN -------------------------"); 169 Console.WriteLine("File name: {0}", file.Name); 170 Console.WriteLine(); 171 Console.Write("Loading data ... "); 172 var sw = Stopwatch.StartNew(); 173 //XmlDataSource xmlDs = new XmlDataSource(filepath); 174 IDataSource xmlDs = new OsmDataSource(filepath); 175 sw.Stop(); 176 Console.WriteLine("done."); 177 Console.WriteLine("Loading Time: {0}", sw.Elapsed); 178 Console.WriteLine(); 179 IGraph graph = xmlDs.GetRoutingGraph(); 180 IRouter router = (IRouter)Activator.CreateInstance(routerType, graph); 181 Console.Write("Calculate route ... "); 182 sw = Stopwatch.StartNew(); 183 long[] result = router.Calculate(sourceNodeId, targetNodeId); 184 sw.Stop(); 185 Console.WriteLine("done."); 186 Console.WriteLine("Execution Time: {0}", sw.Elapsed); 187 Console.WriteLine(); 188 if (showResult) { 189 Console.WriteLine("Result: "); 190 foreach (long i in result) System.Console.Write(i + "; "); 191 Console.WriteLine(); 192 Console.WriteLine(); 193 } 194 if (writeResultFile) { 195 string dt = DateTime.Now.ToString("yyyyMMddhhmmss_"); 196 string fn = Path.GetFileNameWithoutExtension(file.Name); 197 string resultFile = dt + fn + "_" + sourceNodeId + "-" + targetNodeId + ".gpx"; 198 Console.WriteLine("Result file: {0}", resultFile); 199 WriteGPXFileNew(graph, result, resultFile); 200 } 201 Console.WriteLine("==================================================="); 202 Console.WriteLine(); 203 } 204 205 private static void WriteGPXFile(OsmGraph graph, long[] route, string file) { 206 XmlWriterSettings settings = new XmlWriterSettings(); 207 settings.Indent = true; 208 settings.IndentChars = (" "); 209 210 using (XmlWriter writer = XmlWriter.Create(file, settings)) { 211 writer.WriteStartElement("gpx", "http://www.topografix.com/GPX/1/0"); 212 writer.WriteAttributeString("version", "1.1"); 213 writer.WriteAttributeString("creator", "cloudia"); 214 215 foreach (long nodeId in route) { 216 OsmVertex<Node> node = graph.GetVertex(nodeId); 217 writer.WriteStartElement("wpt"); 218 writer.WriteAttributeString("lat", XmlConvert.ToString(node.Node.Latitude)); 219 writer.WriteAttributeString("lon", XmlConvert.ToString(node.Node.Longitude)); 220 writer.WriteEndElement(); // wpt 221 } 222 223 //writer.WriteStartElement("rte"); 224 //foreach (long nodeId in route) { 225 // Vertex<Node> node = graph.GetVertex(nodeId); 226 // writer.WriteStartElement("rtept"); 227 // writer.WriteAttributeString("lat", XmlConvert.ToString(node.Node.Latitude)); 228 // writer.WriteAttributeString("lon", XmlConvert.ToString(node.Node.Longitude)); 229 // writer.WriteEndElement(); // rtept 230 //} 231 //writer.WriteEndElement(); // rte 232 233 //writer.WriteStartElement("trk"); 234 //writer.WriteElementString("name", "RoutePath"); 235 ////writer.WriteEndElement(); // name 236 //writer.WriteStartElement("trkseq"); 237 //foreach (long nodeId in route) { 238 // Vertex<Node> node = graph.GetVertex(nodeId); 239 // writer.WriteStartElement("trkpt"); 240 // writer.WriteAttributeString("lat", XmlConvert.ToString(node.Node.Latitude)); 241 // writer.WriteAttributeString("lon", XmlConvert.ToString(node.Node.Longitude)); 242 // writer.WriteEndElement(); // trkpt 243 //} 244 //writer.WriteEndElement(); // trkseq 245 //writer.WriteEndElement(); // trk 246 247 writer.WriteEndElement(); // gpx 248 } 249 } 250 251 private static void WriteGPXFileNew(IGraph graph, long[] route, string file) { 140 private static void WriteGPXFile(IGraph graph, long[] route, string file) { 252 141 XmlWriterSettings settings = new XmlWriterSettings(); 253 142 settings.Indent = true; … … 267 156 } 268 157 269 //writer.WriteStartElement("rte");270 //foreach (long nodeId in route) {271 // Vertex<Node> node = graph.GetVertex(nodeId);272 // writer.WriteStartElement("rtept");273 // writer.WriteAttributeString("lat", XmlConvert.ToString(node.Node.Latitude));274 // writer.WriteAttributeString("lon", XmlConvert.ToString(node.Node.Longitude));275 // writer.WriteEndElement(); // rtept276 //}277 //writer.WriteEndElement(); // rte278 279 //writer.WriteStartElement("trk");280 //writer.WriteElementString("name", "RoutePath");281 ////writer.WriteEndElement(); // name282 //writer.WriteStartElement("trkseq");283 //foreach (long nodeId in route) {284 // Vertex<Node> node = graph.GetVertex(nodeId);285 // writer.WriteStartElement("trkpt");286 // writer.WriteAttributeString("lat", XmlConvert.ToString(node.Node.Latitude));287 // writer.WriteAttributeString("lon", XmlConvert.ToString(node.Node.Longitude));288 // writer.WriteEndElement(); // trkpt289 //}290 //writer.WriteEndElement(); // trkseq291 //writer.WriteEndElement(); // trk292 293 158 writer.WriteEndElement(); // gpx 294 159 } -
branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/HeuristicLab.Problems.RoutePlanning.csproj
r8488 r8516 57 57 </ItemGroup> 58 58 <ItemGroup> 59 <Compile Include="DIMACS\DIMACSDataSource.cs" /> 60 <Compile Include="Graph\EarthDistanceCostCalculator.cs" /> 61 <Compile Include="Graph\ICostCalculator.cs" /> 62 <Compile Include="Graph\Edge.cs" /> 63 <Compile Include="Graph\Graph.cs" /> 64 <Compile Include="Graph\IGraph.cs" /> 65 <Compile Include="Graph\OsmGraph.cs" /> 66 <Compile Include="Graph\IEdge.cs" /> 67 <Compile Include="Graph\OsmVertex.cs" /> 68 <Compile Include="Graph\Route.cs" /> 69 <Compile Include="Graph\TravelTimeCostCalculator.cs" /> 70 <Compile Include="Graph\Vertex.cs" /> 71 <Compile Include="Osm.Data\OsmDataSource.cs" /> 72 <Compile Include="Osm.Data\XmlDataSource.cs" /> 73 <Compile Include="Osm\IDataSource.cs" /> 74 <Compile Include="Osm\Node.cs" /> 75 <Compile Include="Osm\OsmBase.cs" /> 76 <Compile Include="Osm\PointD.cs" /> 77 <Compile Include="Osm\RectangleD.cs" /> 78 <Compile Include="Osm\Relation.cs" /> 79 <Compile Include="Osm\RelationMember.cs" /> 80 <Compile Include="Osm\TagConstants.cs" /> 81 <Compile Include="Osm\Utils.cs" /> 82 <Compile Include="Osm\Way.cs" /> 59 <Compile Include="Data.DIMACS\DIMACSDataSource.cs" /> 60 <Compile Include="RoutingGraph\EarthDistanceCostCalculator.cs" /> 61 <Compile Include="Interfaces\ICostCalculator.cs" /> 62 <Compile Include="RoutingGraph\Edge.cs" /> 63 <Compile Include="RoutingGraph\Graph.cs" /> 64 <Compile Include="Interfaces\IGraph.cs" /> 65 <Compile Include="Interfaces\IEdge.cs" /> 66 <Compile Include="RoutingGraph\TravelTimeCostCalculator.cs" /> 67 <Compile Include="RoutingGraph\Vertex.cs" /> 68 <Compile Include="Data.Osm\OsmDataSource.cs" /> 69 <Compile Include="Interfaces\IDataSource.cs" /> 70 <Compile Include="Data.Osm.Core\Node.cs" /> 71 <Compile Include="Data.Osm.Core\OsmBase.cs" /> 72 <Compile Include="Utilities\PointD.cs" /> 73 <Compile Include="Utilities\RectangleD.cs" /> 74 <Compile Include="Data.Osm.Core\Relation.cs" /> 75 <Compile Include="Data.Osm.Core\RelationMember.cs" /> 76 <Compile Include="Data.Osm.Core\TagConstants.cs" /> 77 <Compile Include="Utilities\Utils.cs" /> 78 <Compile Include="Data.Osm.Core\Way.cs" /> 83 79 <Compile Include="Plugin.cs" /> 84 80 <Compile Include="Properties\AssemblyInfo.cs" /> … … 90 86 <None Include="Properties\AssemblyInfo.cs.frame" /> 91 87 </ItemGroup> 88 <ItemGroup /> 92 89 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 93 90 <PropertyGroup> -
branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/RoutePlanningProblem.cs
r8429 r8516 27 27 using HeuristicLab.Parameters; 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using HeuristicLab.Problems.RoutePlanning.Graph; 30 using HeuristicLab.Problems.RoutePlanning.Osm; 31 using HeuristicLab.Problems.RoutePlanning.Osm.Data; 29 using HeuristicLab.Problems.RoutePlanning.Data.Osm; 30 using HeuristicLab.Problems.RoutePlanning.Interfaces; 32 31 33 32 namespace HeuristicLab.Problems.RoutePlanning { … … 42 41 43 42 IDataSource dataSource; 44 OsmGraph graph;43 IGraph graph; 45 44 46 45 #region Parameter Properties … … 105 104 public void LoadData(string file) { 106 105 FileInfo f = new FileInfo(file); 107 dataSource = new XmlDataSource(file);108 graph = new OsmGraph(dataSource);106 dataSource = new OsmDataSource(file); 107 graph = dataSource.GetRoutingGraph(); 109 108 110 109 Name = f.Name;
Note: See TracChangeset
for help on using the changeset viewer.