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)
Metadata
Release files for tsp_2opt 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tsp_2opt-0.0.1-cp38-cp38-macosx_10_7_x86_64.whl | CPython 3.8 | CPython 3.8 | macOS 10.7+ x86-64 | Details for tsp_2opt-0.0.1-cp38-cp38-macosx_10_7_x86_64.whl |
Release files / tsp_2opt-0.0.1-cp38-cp38-macosx_10_7_x86_64.whl
| Download URL | tsp_2opt-0.0.1-cp38-cp38-macosx_10_7_x86_64.whl |
|---|---|
| Size | 161.5 kB |
| Tags | CPython 3.8 macOS 10.7+ x86-64 |
|
SHA-256 checksum How to use checksums |
06c65dd1081ad6d7bb01cee4ccfc1be16041ca1dbcc60c894be104e476c0d607
|
|
BLAKE2b-256 checksum How to use checksums |
3f9d7985b5c0c188bd9fb9eec22c0c3793dc49d2c4a5a3e999f1705041161ba8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/0.9.4
|
Security for tsp_2opt 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.