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

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

Uploaded CPython 3.8 macOS 10.7+ x86-64

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