Skip to main content

tsp-tools is a package for Traveling Salesman Problem for Python.

Usage

import tsp_tools
t = tsp_tools.tsp([(0,0), (0,1), (1,0), (1,1)])
print(t)  # distance, node index list
>>>
(4.0, [0, 2, 3, 1])
mat = [
    [  0,   1, 1, 1.5],
    [  1,   0, 1.5, 1],
    [  1, 1.5,   0, 1],
    [1.5,   1,   1, 0],
]  # Distance Matrix
r = range(len(mat))
# Dictionary of distance
dist = {(i, j): mat[i][j] for i in r for j in r}
print(tsp_tools.tsp(r, dist))
>>>
(4.0, [0, 2, 3, 1])

Note: When large size, ortoolpy.ortools_vrp may be efficient.

See also https://pypi.org/project/ortoolpy/

Requirements

  • Python 3
  • more-itertools

Setup

$ pip install tsp-tools

History

  • 0.0.1 (2015-10-2): first release

Metadata

Release files for tsp-tools 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for tsp-tools 0.3.2
File Interpreter ABI Platform Actions
tsp_tools-0.3.2-py3-none-any.whl Python 3 none any Details for tsp_tools-0.3.2-py3-none-any.whl

Release files / tsp_tools-0.3.2-py3-none-any.whl

Download URL tsp_tools-0.3.2-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9bb8d1fbe567c74550f92b8ddd5ee1ff7435f0c373cf5106415a433990cafb0
BLAKE2b-256 checksum
How to use checksums
1d37fd9ff22a2d0ee9701707065e35173c443c0885d4d71b95942f81841e8713
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Security for tsp-tools 0.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page