Skip to main content

Python project scaffold

Project description

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.

Project details


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

Uploaded Source

Built Distribution

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

tspsolve-0.1.0-py2.py3-none-any.whl (3.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file tspsolve-0.1.0.tar.gz.

File metadata

  • Download URL: tspsolve-0.1.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for tspsolve-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f1788778c683c5d360bd99e0363fd2280e1b9ce8f1f4454526b2d8d3f96215c0
MD5 c0694e6863357e7e93d409501c10f888
BLAKE2b-256 48f1bb6ebe41eca3fe831e0007e3eca6ef3ec28f1b3a45cd55de7948f826299b

See more details on using hashes here.

File details

Details for the file tspsolve-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for tspsolve-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8c162b71222e086ddca6a43d3874164c98cfdd22913a9c17f6b44972c9dcdbc2
MD5 b73310470682d9834330a007349bba70
BLAKE2b-256 e82cc08c1f37b0587da38f3936509d69ec5dc9ec09f96744743bc8a2705d66e4

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