Skip to main content

No project description provided

Project description

Traveling Salesman Problem (TSP) Solver

This python library gives a solver to efficiently find good sub-optimal solutions to the TSP. It uses the 2-opt heuristic and the search part is implemented in rust.

Install

To install the library, run:

pip install tsp_2opt

For now, the library is working only on MacOS X platforms.

Use

The current version relies on the availability of a distance matrix, i.e. matrix giving pair-wise distance between cities in the TSP instance.

Here is a small example :

from tsp_2opt.solver import tsp_solver
distances = [[0, 2, 3], [2, 0, 4], [3, 4, 0]]
route, length = tsp_solver(distances)

The solution obtained to a TSP instance after performing the 2-opt heuristic depends on the initial solution (starting point of the search), therefore this library runs the heuristic n times with n different starting point in parralel (true parallelism is possible thanks to rust) and the best obtained is returned. You can pass n as a parameter to tsp_solver() and control the maximum number of workers :

tsp_solver(distances, workers, n) 

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

tsp_2opt-0.0.1-cp38-cp38-macosx_10_7_x86_64.whl (161.5 kB view details)

Uploaded CPython 3.8macOS 10.7+ x86-64

File details

Details for the file tsp_2opt-0.0.1-cp38-cp38-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for tsp_2opt-0.0.1-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 06c65dd1081ad6d7bb01cee4ccfc1be16041ca1dbcc60c894be104e476c0d607
MD5 eb6850be882d38259fe59385ebdd962e
BLAKE2b-256 3f9d7985b5c0c188bd9fb9eec22c0c3793dc49d2c4a5a3e999f1705041161ba8

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