Skip to main content

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

Project description

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

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

tsp_tools-0.3.2-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file tsp_tools-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: tsp_tools-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for tsp_tools-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f9bb8d1fbe567c74550f92b8ddd5ee1ff7435f0c373cf5106415a433990cafb0
MD5 03c07b7749ea8d799bb1cc8fd80d275c
BLAKE2b-256 1d37fd9ff22a2d0ee9701707065e35173c443c0885d4d71b95942f81841e8713

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