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

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page