From 886ccaa8dcfefcea4192e3a83edf6094bc16fab5 Mon Sep 17 00:00:00 2001 From: glax Date: Sun, 23 Apr 2023 15:00:22 +0200 Subject: [PATCH] removed nodeAngleFactor --- API/Program.cs | 4 ++-- Pathfinding/Pathfinder.cs | 8 +++----- Server/Server.cs | 18 +++++++++--------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/API/Program.cs b/API/Program.cs index db8ba8f..6d3fec9 100644 --- a/API/Program.cs +++ b/API/Program.cs @@ -16,7 +16,7 @@ var app = builder.Build(); app.MapGet("/getRoute", (float latStart, float lonStart, float latEnd, float lonEnd, Tag.SpeedType vehicle, double stayOnSameRoadPriority, double useHigherLevelRoadsPriority, double useRoadsWithLessJunctionsPriority, double angleFactor) => { Pathfinder result = new Pathfinder("D:/stuttgart-regbez-latest", useHigherLevelRoadsPriority, stayOnSameRoadPriority, - useRoadsWithLessJunctionsPriority, angleFactor, 30).AStar(new Coordinates(latStart, lonStart), + useRoadsWithLessJunctionsPriority, 30).AStar(new Coordinates(latStart, lonStart), new Coordinates(latEnd, lonEnd), vehicle); return result.pathResult; } @@ -25,7 +25,7 @@ app.MapGet("/getRoute", (float latStart, float lonStart, float latEnd, float lon app.MapGet("/getShortestRoute", (float latStart, float lonStart, float latEnd, float lonEnd) => { Pathfinder result = new Pathfinder("D:/stuttgart-regbez-latest", 0, 0, - 0, 0, 30).AStar(new Coordinates(latStart, lonStart), + 0, 30).AStar(new Coordinates(latStart, lonStart), new Coordinates(latEnd, lonEnd), Tag.SpeedType.any); return result.pathResult; } diff --git a/Pathfinding/Pathfinder.cs b/Pathfinding/Pathfinder.cs index 9061a42..32de83f 100644 --- a/Pathfinding/Pathfinder.cs +++ b/Pathfinding/Pathfinder.cs @@ -13,9 +13,9 @@ public class Pathfinder public Dictionary? gScore; private Dictionary? _cameFromDict; private SpeedType _speedType; - private double roadPriorityFactor, junctionFactor, sameRoadFactor, nodeAngleFactor, turnAngle; + private double roadPriorityFactor, junctionFactor, sameRoadFactor, turnAngle; - public Pathfinder(string workingDirectory, double roadPriorityFactor, double junctionFactor, double sameRoadFactor, double nodeAngleFactor, double turnAngle) + public Pathfinder(string workingDirectory, double roadPriorityFactor, double junctionFactor, double sameRoadFactor, double turnAngle) { if (!Path.Exists(workingDirectory)) throw new DirectoryNotFoundException(workingDirectory); @@ -23,17 +23,15 @@ public class Pathfinder this.roadPriorityFactor = roadPriorityFactor; this.junctionFactor = junctionFactor; this.sameRoadFactor = sameRoadFactor; - this.nodeAngleFactor = nodeAngleFactor; this.turnAngle = turnAngle; } - public Pathfinder(RegionManager regionManager, double roadPriorityFactor, double junctionFactor, double sameRoadFactor, double nodeAngleFactor, double turnAngle) + public Pathfinder(RegionManager regionManager, double roadPriorityFactor, double junctionFactor, double sameRoadFactor, double turnAngle) { this.regionManager = regionManager; this.roadPriorityFactor = roadPriorityFactor; this.junctionFactor = junctionFactor; this.sameRoadFactor = sameRoadFactor; - this.nodeAngleFactor = nodeAngleFactor; this.turnAngle = turnAngle; } diff --git a/Server/Server.cs b/Server/Server.cs index abc0616..6d556a7 100644 --- a/Server/Server.cs +++ b/Server/Server.cs @@ -26,8 +26,8 @@ public class Server Coordinates start = new (48.7933798f, 9.8275859f); Coordinates finish = new (48.795918f, 9.021618f); - //TestVariables(workingDir, start, finish, 16); - //GetShortestRoute("D:"); + TestVariables(workingDir, start, finish, 16); + GetShortestRoute("D:"); /* ValueTuple area = RenderAreaBaseImage(workingDir, start, finish); @@ -41,7 +41,7 @@ public class Server 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, @@ -118,22 +118,22 @@ public class Server Queue calcThreads = new(); - for (double sameRoadPriority = 0.02; sameRoadPriority < 0.1; sameRoadPriority += 0.02) + for (double sameRoadPriority = 0; sameRoadPriority < 0.02; sameRoadPriority += 0.001) { - for (double roadLevelPriority = 0.05; roadLevelPriority > 0; roadLevelPriority -= 0.002) + for (double roadLevelPriority = 0.02; roadLevelPriority > 0; roadLevelPriority -= 0.001) { - for (double angleWeightFactor = 0.12; angleWeightFactor < 0.17; angleWeightFactor += 0.002) + for (double maxAngle = 5; maxAngle < 45; maxAngle += 5) { double priority = roadLevelPriority; double roadPriority = sameRoadPriority; - double factor = angleWeightFactor; + double angle = maxAngle; calcThreads.Enqueue(new Thread(() => { Pathfinder testresult = new Pathfinder(rm, priority, roadPriority, - 0, factor, 30).AStar(start, + 0, angle).AStar(start, finish, Tag.SpeedType.car); string fileName = - $"angle{factor:0.000}_level{priority:0.000}_same{roadPriority:0.000}.result"; + $"angle{angle:0.000}_level{priority:0.000}_same{roadPriority:0.000}.result"; testresult.SaveResult(Path.Join(parentFolder, fileName)); })); }