From af1d9baf4f2dd2e78758582ac6e3ccb2298cca92 Mon Sep 17 00:00:00 2001 From: glax Date: Sun, 23 Apr 2023 14:51:13 +0200 Subject: [PATCH] Testsetup for cariable testing --- Server/Server.cs | 51 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/Server/Server.cs b/Server/Server.cs index e3383ef..abc0616 100644 --- a/Server/Server.cs +++ b/Server/Server.cs @@ -26,9 +26,22 @@ public class Server Coordinates start = new (48.7933798f, 9.8275859f); Coordinates finish = new (48.795918f, 9.021618f); - TestVariables(workingDir, start, finish, 32); + //TestVariables(workingDir, start, finish, 16); + //GetShortestRoute("D:"); + + /* + ValueTuple area = RenderAreaBaseImage(workingDir, start, finish); + area.Item1.Save(@"D:\Base.png", ImageFormat.Png); -/* + ValueTuple areaDistance = Renderer.DrawPath( + PathResult.PathresultFromFile(@"D:\angle0,140_level0,020_same0,160.result"), Image.FromFile(@"D:\Base.png"), area.Item2); + areaDistance.Item1.Save(@"D:\Distance.png", ImageFormat.Png); + + ValueTuple areaWeight = Renderer.DrawPath( + PathResult.PathresultFromFile(@"D:\angle0,160_level0,020_same0,020.result"), Image.FromFile(@"D:\Base.png"), area.Item2); + areaWeight.Item1.Save(@"D:\Weight.png", ImageFormat.Png); +*/ + string parentFolder = new DirectoryInfo(workingDir).Parent!.FullName; Pathfinder result = new Pathfinder(workingDir, 0.002, 0, @@ -47,6 +60,34 @@ public class Server #pragma warning disable CA1416 render.Save(Path.Join(parentFolder, renderFileName), ImageFormat.Png); #pragma warning restore CA1416*/ + Console.Beep(400, 100); + } + + private static void GetShortestRoute(string directory) + { + DateTime start = DateTime.Now; + HashSet allFiles = Directory.GetFiles(directory).Where(file => file.EndsWith(".result")).ToHashSet(); + PathResult first = PathResult.PathresultFromFile(allFiles.First()); + KeyValuePair shortest = new(first, allFiles.First()); + KeyValuePair fastest = new(first, allFiles.First()); + KeyValuePair calcTime = new(first, allFiles.First()); + int loaded = 0; + foreach (string filePath in allFiles) + { + PathResult result = PathResult.PathresultFromFile(filePath); + Console.WriteLine($"{loaded++}/{allFiles.Count()} {filePath} " + + $"Time elapsed: {DateTime.Now - start} " + + $"Remaining {((DateTime.Now - start)/loaded)*(allFiles.Count-loaded)}"); + if (shortest.Key.distance > result.distance) + shortest = new KeyValuePair(result, filePath); + + if (fastest.Key.weight > result.weight) + fastest = new KeyValuePair(result, filePath); + + if (calcTime.Key.calcTime > result.calcTime) + calcTime = new KeyValuePair(result, filePath); + } + Console.WriteLine($"Shortest: {shortest.Key.distance} {shortest.Value}\nFastest: {shortest.Key.weight} {fastest.Value}\nCalcTime: {calcTime.Key.calcTime} {calcTime.Value}"); } private static ValueTuple RenderAreaBaseImage(string workingDir, Coordinates c1, Coordinates c2) @@ -77,11 +118,11 @@ public class Server Queue calcThreads = new(); - for (double sameRoadPriority = 0.02; sameRoadPriority < 0.4; sameRoadPriority += 0.02) + for (double sameRoadPriority = 0.02; sameRoadPriority < 0.1; sameRoadPriority += 0.02) { - for (double roadLevelPriority = 0.4; roadLevelPriority > 0; roadLevelPriority -= 0.02) + for (double roadLevelPriority = 0.05; roadLevelPriority > 0; roadLevelPriority -= 0.002) { - for (double angleWeightFactor = 0.01; angleWeightFactor < 0.25; angleWeightFactor += 0.01) + for (double angleWeightFactor = 0.12; angleWeightFactor < 0.17; angleWeightFactor += 0.002) { double priority = roadLevelPriority; double roadPriority = sameRoadPriority;