|
|
|
@ -30,7 +30,7 @@ public class Server
|
|
|
|
|
GetShortestRoute("D:");
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ValueTuple<Image, Renderer.Bounds> area = RenderAreaBaseImage(workingDir, start, finish);
|
|
|
|
|
ValueTuple<Image, Renderer.Bounds> area = Renderer.DrawArea(LoadRegions(workingDir, start, finish));
|
|
|
|
|
area.Item1.Save(@"D:\Base.png", ImageFormat.Png);
|
|
|
|
|
|
|
|
|
|
ValueTuple<Image, Renderer.Bounds> areaDistance = Renderer.DrawPath(
|
|
|
|
@ -87,10 +87,12 @@ public class Server
|
|
|
|
|
if (calcTime.Key.calcTime > result.calcTime)
|
|
|
|
|
calcTime = new KeyValuePair<PathResult, string>(result, filePath);
|
|
|
|
|
}
|
|
|
|
|
Console.WriteLine($"Shortest: {shortest.Key.distance} {shortest.Value}\nFastest: {shortest.Key.weight} {fastest.Value}\nCalcTime: {calcTime.Key.calcTime} {calcTime.Value}");
|
|
|
|
|
Console.WriteLine($"\nShortest:\t{shortest.Key.distance:0.0} {shortest.Key.weight:0.00} {shortest.Key.calcTime} {shortest.Value}\n" +
|
|
|
|
|
$"Fastest:\t{fastest.Key.distance:0.0} {fastest.Key.weight:0.00} {fastest.Key.calcTime} {fastest.Value}\n" +
|
|
|
|
|
$"CalcTime:\t{calcTime.Key.distance:0.0} {calcTime.Key.weight:0.00} {calcTime.Key.calcTime} {calcTime.Value}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static ValueTuple<Image, Renderer.Bounds> RenderAreaBaseImage(string workingDir, Coordinates c1, Coordinates c2)
|
|
|
|
|
private static RegionManager LoadRegions(string workingDir, Coordinates c1, Coordinates c2)
|
|
|
|
|
{
|
|
|
|
|
float minLat = c1.latitude < c2.latitude ? c1.latitude : c2.latitude;
|
|
|
|
|
float minLon = c1.longitude < c2.longitude ? c1.longitude : c2.longitude;
|
|
|
|
@ -105,22 +107,21 @@ public class Server
|
|
|
|
|
allRegions.GetRegion(new Coordinates(lat, lon));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Console.WriteLine("Regions Loaded. Rendering.");
|
|
|
|
|
ValueTuple<Image, Renderer.Bounds> baseRender = Renderer.DrawArea(allRegions);
|
|
|
|
|
return baseRender;
|
|
|
|
|
Console.WriteLine("Loaded needed Regions");
|
|
|
|
|
return allRegions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void TestVariables(string workingDir, Coordinates start, Coordinates finish, int threads)
|
|
|
|
|
{
|
|
|
|
|
string parentFolder = new DirectoryInfo(workingDir).Parent!.FullName;
|
|
|
|
|
|
|
|
|
|
RegionManager rm = new (workingDir);
|
|
|
|
|
RegionManager rm = LoadRegions(workingDir, start, finish);
|
|
|
|
|
|
|
|
|
|
Queue<Thread> calcThreads = new();
|
|
|
|
|
|
|
|
|
|
for (double roadLevelPriority = 0.02; roadLevelPriority > 0; roadLevelPriority -= 0.001)
|
|
|
|
|
for (double roadLevelPriority = 0.016; roadLevelPriority < 0.02; roadLevelPriority += 0.0002)
|
|
|
|
|
{
|
|
|
|
|
for (double maxAngle = 5; maxAngle < 45; maxAngle += 5)
|
|
|
|
|
for (double maxAngle = 25; maxAngle < 35; maxAngle += 1)
|
|
|
|
|
{
|
|
|
|
|
double priority = roadLevelPriority;
|
|
|
|
|
double angle = maxAngle;
|
|
|
|
@ -128,7 +129,7 @@ public class Server
|
|
|
|
|
{
|
|
|
|
|
Pathfinder testresult = new Pathfinder(rm, priority, angle).AStar(start,
|
|
|
|
|
finish, Tag.SpeedType.car);
|
|
|
|
|
string fileName = $"angle{angle:0.000}_level{priority:0.000}.result";
|
|
|
|
|
string fileName = $"angle{angle:00}_level{priority:0.0000}.result";
|
|
|
|
|
testresult.SaveResult(Path.Join(parentFolder, fileName));
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
@ -139,7 +140,7 @@ public class Server
|
|
|
|
|
DateTime startTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
HashSet<Thread> runningThreads = new();
|
|
|
|
|
while (calcThreads.Count > 0)
|
|
|
|
|
while (calcThreads.Count > 0 || runningThreads.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
while (runningThreads.Count < threads && calcThreads.Count > 0)
|
|
|
|
|
{
|
|
|
|
@ -153,7 +154,7 @@ public class Server
|
|
|
|
|
if (newCompletedTasks > 0)
|
|
|
|
|
{
|
|
|
|
|
TimeSpan elapsedTime = DateTime.Now - startTime;
|
|
|
|
|
Console.WriteLine($"To calculate: {calcThreads.Count}/{totalTasks} Time Average: {(elapsedTime)/(completedTasks)} Elapsed: {elapsedTime} Remaining: {(elapsedTime)/(completedTasks)*calcThreads.Count}");
|
|
|
|
|
Console.WriteLine($"To calculate: {calcThreads.Count}(+{runningThreads.Count})/{totalTasks} Time Average: {(elapsedTime)/(completedTasks)} Elapsed: {elapsedTime} Remaining: {(elapsedTime)/(completedTasks)*calcThreads.Count}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|