Rewrite TSP solver for improved path optimization and clarity

- Completely re-implemented the TSP algorithm in C++ for better path quality
- Added detailed comments and documentation to clarify each step
- Improved nearest neighbor, 2-opt, and relocation logic
- Enhanced handling of start/end point constraints
- Updated PathUtils.py docstring to accurately describe start point behavior
This commit is contained in:
Billy Huddleston
2025-10-19 17:12:08 -04:00
parent 428948699a
commit 005cbb937d
2 changed files with 255 additions and 200 deletions

View File

@@ -626,7 +626,8 @@ def sort_locations_tsp(locations, keys, attractors=None, startPoint=None, endPoi
- endPoint: Optional ending point [x, y]
Returns the sorted list of locations in TSP order.
If startPoint is None, path starts from the first point in the original order.
If startPoint is None, the path is optimized to start near the first point in the original list,
but may not start exactly at that point.
"""
# Extract points from locations
points = [(loc[keys[0]], loc[keys[1]]) for loc in locations]