Skip to main content

tspsolve

CircleCI codecov Code style: black PyPi Version GitHub stars

Algorithms for the traveling salesman problem (TSP) in Python.

Implemented so far:

  • Nearest neighbor algorithm

    import tspsolve
    
    # Create matrix of distances d
    path = tspsolve.nearest_neighbor(d)
    
  • 2-opt improvement

    import tspsolve
    
    # Create matrix of distances d and an initial path
    new_path = tspsolve.two_opt(d, path, verbose=True)
    

For Euclidiean TSP, the distance matrix can be computed efficiently with

dx = numpy.subtract.outer(x, x)
dy = numpy.subtract.outer(y, y)
d = numpy.sqrt(dx ** 2 + dy ** 2)

Installation

tspsolve is available from the Python Package Index, so simply type

pip install -U tspsolve

to install or upgrade.

Testing

To run the tspsolve unit tests, check out this repository and type

pytest

Distribution

To create a new release

  1. bump the __version__ number,

  2. publish to PyPi and GitHub:

    make publish
    

License

tspsolve is published under the MIT license.

Release files for tspsolve 0.1.0

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

Source distribution (sdist)

Source distribution for tspsolve 0.1.0
File Size Uploaded
tspsolve-0.1.0.tar.gz 3.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tspsolve 0.1.0
File Interpreter ABI Platform
tspsolve-0.1.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 7.5 kB

Release files / tspsolve-0.1.0.tar.gz

Download URL tspsolve-0.1.0.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f1788778c683c5d360bd99e0363fd2280e1b9ce8f1f4454526b2d8d3f96215c0
BLAKE2b-256 checksum
How to use checksums
48f1bb6ebe41eca3fe831e0007e3eca6ef3ec28f1b3a45cd55de7948f826299b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / tspsolve-0.1.0-py2.py3-none-any.whl

Download URL tspsolve-0.1.0-py2.py3-none-any.whl
Size 3.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
8c162b71222e086ddca6a43d3874164c98cfdd22913a9c17f6b44972c9dcdbc2
BLAKE2b-256 checksum
How to use checksums
e82cc08c1f37b0587da38f3936509d69ec5dc9ec09f96744743bc8a2705d66e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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