Python project scaffold
Project description
tspsolve
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
-
bump the
__version__
number, -
publish to PyPi and GitHub:
make publish
License
tspsolve is published under the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tspsolve-0.1.0.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for tspsolve-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c162b71222e086ddca6a43d3874164c98cfdd22913a9c17f6b44972c9dcdbc2 |
|
MD5 | b73310470682d9834330a007349bba70 |
|
BLAKE2b-256 | e82cc08c1f37b0587da38f3936509d69ec5dc9ec09f96744743bc8a2705d66e4 |