Skip to main content

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

Project description

tsp is a package for Traveling Salesman Problem for Python.

import tsp
t = tsp.tsp([(0,0), (0,1), (1,0), (1,1)])
print(t)  # distance, node index list
>>>
(4, [0, 1, 3, 2])

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.tsp(r, dist))
>>>
(4, [0, 1, 3, 2])

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

Requirements

  • Python 3
  • PuLP
  • more-itertools

Features

  • nothing

Setup

$ pip install tsp

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.

Files for tsp, version 0.0.7
Filename, size File type Python version Upload date Hashes
Filename, size tsp-0.0.7-py3-none-any.whl (3.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size tsp-0.0.7.tar.gz (3.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page