Skip to main content

A fast C++ implementation of the Held-Karp algorithm for solving TSP

Project description

toposolve

A fast C++ implementation of the Held-Karp algorithm for solving the Traveling Salesman Problem (TSP) for ring-reduce tours, with Python bindings. We solve a specific variant of TSP where the dist(i, j) is calculated as min(max(dist(i, k), dist(k, j)) for k in range(n)).

Installation

pip install toposolve

Usage

from toposolve import TSPSolver

# Create distance matrix
distances = [
    [0, 10, 15, 20],
    [10, 0, 35, 25],
    [15, 35, 0, 30],
    [20, 25, 30, 0]
]

# Create solver instance
solver = TSPSolver()

# Solve TSP
min_distance, path = solver.solve_tsp(distances)

print(f"Minimum distance: {min_distance}")
print(f"Optimal path: {path}")

Requirements

  • Python 3.6+
  • C++ compiler supporting C++17
  • CMake 3.18+

Building from source

git clone https://github.com/Jackmin801/toposolve
cd toposolve
pip install .

Running tests

pip install pytest
pytest tests/

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toposolve-0.1.15.tar.gz (5.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

toposolve-0.1.15-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (95.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

toposolve-0.1.15-cp310-cp310-macosx_11_0_arm64.whl (125.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

toposolve-0.1.15-cp310-cp310-macosx_10_9_x86_64.whl (125.5 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

File details

Details for the file toposolve-0.1.15.tar.gz.

File metadata

  • Download URL: toposolve-0.1.15.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for toposolve-0.1.15.tar.gz
Algorithm Hash digest
SHA256 7cc5c551cc18a0515d727eead6c08d5135936be94193c32161126b51f3f04c3b
MD5 f0b5935f031188faa41e82de62de3233
BLAKE2b-256 a814ce4e9b36496001d774ee36cec34a701571e956c386b6c7cbc97a215dcdf6

See more details on using hashes here.

File details

Details for the file toposolve-0.1.15-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for toposolve-0.1.15-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fc74a56542896289fee2d82f82f54adf914ca15c7a3ed365d8981d52f633cf4d
MD5 1eefc66ccbaf97de2fc21c75c974f9e4
BLAKE2b-256 a020d3491f9d4aa77e533ae54f567de783b19d52cf7827979fc6c61f2ba0e9ce

See more details on using hashes here.

File details

Details for the file toposolve-0.1.15-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for toposolve-0.1.15-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 abd6ee87a5b4027ef020f7e7585b6b6a9fbd4a1539865c08cd92f131b2b7fe7b
MD5 63645fb1b4c9cc87e308f3fb5e16f8db
BLAKE2b-256 8d894dff064cbe4efbe6dafc7703dde4dedfd71666c809644a0788769169ac4f

See more details on using hashes here.

File details

Details for the file toposolve-0.1.15-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for toposolve-0.1.15-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c50a6d51bcb859bf297f81b32449c7dca4b6d83d021f2d638d2e894bf1a970d3
MD5 f0c0b98372b08c5e059fe7beba30d81e
BLAKE2b-256 af496764c306f2c7ab7097105bc31e492ae3d2563ac998af67741694c9a82656

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page