A toolset that simplifies the process of solving TSP (Traveling Salesman Problem) problems.
Project description
TSP Lifesaver
!!! This package is currently under development and may contain bugs. !!!
Introduction
This is a toolset that simplifies the process of solving TSP (Traveling Salesman Problem) problems.
Usage
How to import:
from TSPLifesaver.structure import BasicRoute, PointWithEuclideanDistance
from TSPLifesaver.optimizer import SimulatedAnnealing
from TSPLifesaver.tools import #still_developing
Define a point:
point = PointWithEuclideanDistance([1,1,1], name="test_point")
print(point)
# test_point([1,1,1])
print(point.distance_to(point))
# 0
print(point.distance_to([1,1,2]))
# 1
Define a route:
points = [PointWithEuclideanDistance(i) for i in [[1,1,1],[2,2,2],[3,3,3]]]
route = BasicRoute(points, name="TestRoute")
print(route)
# TestRoute(
# None: [1, 1, 1]
# None: [2, 2, 2]
# None: [3, 3, 3]
# )
Calculate total distance:
print(route.distance())
# 6.928203230275509
Optimize the route:
optimizer = SimulatedAnnealing(route, temperature=10000, cooling_rate=0.003, min_temperature=1)
route = optimizer.optimize()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file TSPLifesaver-0.0.1.tar.gz.
File metadata
- Download URL: TSPLifesaver-0.0.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aba8b8cd0ce096c17d5b24202dacc21bee84dcbc735b2aff37fca8ae7693bc1f
|
|
| MD5 |
1342ee8b390671a010761c2ba45be9f3
|
|
| BLAKE2b-256 |
1c960323d0f8d2db7026e432d56efcd83f5e2cfcc40c2dba965b67d4b3efa271
|
File details
Details for the file TSPLifesaver-0.0.1-py3-none-any.whl.
File metadata
- Download URL: TSPLifesaver-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28a5ed68a4a9138149f565d328a1c8aa0c10abfaabac21acfb64b1dd79717a5a
|
|
| MD5 |
283c2298f40bb915f69f2875998c5ac6
|
|
| BLAKE2b-256 |
583dfc815540c5d4a79804dadd3e2a904754c0fe74db9c584c0fcfad924dbeb9
|