Smart TSP Benchmark v1.0.1

Professional algorithm testing infrastructure

Customizable scenarios and detailed metrics for Traveling Salesman Problem algorithms.

Python TSP Benchmark PyPI Testing Optimization

Smart TSP Benchmark is a professional algorithm testing infrastructure with customizable scenarios and detailed metrics.

pip install smart-tsp-benchmark

With Smart TSP Solver:

pip install smart-tsp-solver

from smart_tsp_benchmark.tsp_benchmark import TSPBenchmark, AlgorithmConfig

from smart_tsp_solver.algorithms.angular_radial.v2 import angular_radial_tsp_v2
from smart_tsp_solver.algorithms.dynamic_gravity.v2 import dynamic_gravity_tsp_v2
from smart_tsp_solver.algorithms.other.greedy.v2 import greedy_tsp_v2

config = {
    'n_points': 100,
    'seed': 123,
    'point_generation': 'random',
    'plot_results': True,
    'verbose': True
}

benchmark = TSPBenchmark(config=config)
benchmark.add_algorithm(
    name='Angular-radial v2',
    config=AlgorithmConfig(
        function=angular_radial_tsp_v2,
        params={"look_ahead": 100, "max_2opt_iter": 100},
        post_optimize=True
    )
)
benchmark.add_algorithm(
    name='Dynamic-gravity v2',
    config=AlgorithmConfig(
        function=dynamic_gravity_tsp_v2,
        params={"delta": 0.5, "fast_2opt_iter": 100},
        post_optimize=True
    )
)
benchmark.add_algorithm(
    name='Greedy v2',
    config=AlgorithmConfig(
        function=greedy_tsp_v2,
        params={},
        post_optimize=False
    )
)
benchmark.run_benchmark()

Visual analysis showing Angular-radial's optimal sector-based routing, Dynamic-gravity's smooth trajectories, Greedy's suboptimal clustering

==================================================
          SMART TSP ALGORITHMS BENCHMARK
==================================================
Cities:         100
Seed:           123
Generation:     cluster
Post-opt:       OFF

==================================================
Running Angular-radial v2 algorithm...
Completed in 0.0088 seconds
Route length: 553.66
==================================================

Running Dynamic-gravity v2 algorithm...
Completed in 0.0073 seconds
Route length: 534.90
==================================================

Running Greedy v2 algorithm...
Completed in 0.0016 seconds
Route length: 609.21
==================================================

================================================================
                    DETAILED COMPARISON
================================================================
Algorithm            | Time (s) | Length | vs Best | Params
----------------------------------------------------------------
Greedy v2            | 0.0016 | 609.21 | +13.89% |
Dynamic-gravity v2   | 0.0073 | 534.90 | BEST | delta=0.5
Angular-radial v2    | 0.0088 | 553.66 | +3.51%  | look_ahead=100
================================================================

PERFORMANCE ANALYSIS:
- Fastest: Greedy v2 (0.0016 sec)
- Shortest: Dynamic-gravity v2 (534.90 units)