Changed values for heuristic and weight functions, as well as increased priority for type1-roads (motorways).

This commit is contained in:
glax 2023-04-19 22:51:47 +02:00
parent 5212e43897
commit 208c000577

View File

@ -64,7 +64,6 @@ public static class Pathfinder
heuristicRoadLevelPriority, heuristicFewJunctionsPriority, heuristicSameRoadPriority);
//Console.WriteLine($"Queue: {openSetfScore.Count:00000} Current Distance: {Utils.DistanceBetween(currentNode, goalNode):000000.00} Visited: {cameFromDict.Count:00000} Current heuristic: {h:00000.00}");
openSetfScore.Enqueue(neighbor, tentativeGScore + h);
}
}
}
@ -106,7 +105,7 @@ public static class Pathfinder
double distance = Utils.DistanceBetween(fromNode, neighborNode);
double speed = regionManager.GetSpeedForEdge(fromNode, edge.wayId, vehicle);
double prio = GetPriorityVehicleRoad(edge, vehicle, regionManager.GetRegion(fromNode.coordinates)!);
return distance / (speed + prio * 50);
return distance / speed;
}
private static double Heuristic(OsmNode fromNode, OsmNode neighborNode, OsmNode goalNode, OsmEdge edge, SpeedType vehicle, RegionManager regionManager, double roadPriorityFactor, double junctionFactor, double sameRoadFactor)
@ -132,9 +131,7 @@ public static class Pathfinder
double junctionCount = (neighborNode.edges.Count > 2 ? 0 : 1) * junctionFactor;
//Console.WriteLine($"{roadPriority:000.00} {sameRoadName:000.00} {junctionCount:000.00} {distanceImprovement:+000.00;-000.00;0000.00}");
return Utils.DistanceBetween(neighborNode, goalNode) - (roadPriority + sameRoadName + junctionCount) * 20;
return Utils.DistanceBetween(neighborNode, goalNode) / (1 + roadPriority + sameRoadName + junctionCount);
}
private static double GetPriorityVehicleRoad(OsmEdge edge, SpeedType vehicle, Region region)
@ -155,10 +152,10 @@ public static class Pathfinder
case WayType.trunk_link:
case WayType.primary:
case WayType.primary_link:
return 8;
return 10;
case WayType.secondary:
case WayType.secondary_link:
return 6;
return 7;
case WayType.tertiary:
case WayType.tertiary_link:
return 5;
@ -169,7 +166,7 @@ public static class Pathfinder
return 2;
case WayType.service:
case WayType.track:
return 0.01;
return 0.0001;
}
}
if (vehicle == SpeedType.pedestrian)