Testsetup for cariable testing

This commit is contained in:
glax 2023-04-23 14:51:13 +02:00
parent e2332847cd
commit af1d9baf4f

View File

@ -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<Image, Renderer.Bounds> area = RenderAreaBaseImage(workingDir, start, finish);
area.Item1.Save(@"D:\Base.png", ImageFormat.Png);
/*
ValueTuple<Image, Renderer.Bounds> 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<Image, Renderer.Bounds> 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<string> allFiles = Directory.GetFiles(directory).Where(file => file.EndsWith(".result")).ToHashSet();
PathResult first = PathResult.PathresultFromFile(allFiles.First());
KeyValuePair<PathResult, string> shortest = new(first, allFiles.First());
KeyValuePair<PathResult, string> fastest = new(first, allFiles.First());
KeyValuePair<PathResult, string> 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<PathResult, string>(result, filePath);
if (fastest.Key.weight > result.weight)
fastest = new KeyValuePair<PathResult, string>(result, filePath);
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}");
}
private static ValueTuple<Image, Renderer.Bounds> RenderAreaBaseImage(string workingDir, Coordinates c1, Coordinates c2)
@ -77,11 +118,11 @@ public class Server
Queue<Thread> 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;