Skip to main content

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

Project description

tsp is a package for Traveling Salesman Problem.

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])

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.

Filename, size & hash SHA256 hash help File type Python version Upload date
tsp-0.0.6.tar.gz (3.0 kB) Copy SHA256 hash SHA256 Source None May 14, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page