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 framework that simplifies the process of solving TSP (Traveling Salesman Problem) problems.
Installation
pip install TSPLifesaver
Quick Start
How to import:
from TSPLifesaver.structure import BasicRoute, PointWithEuclideanDistance
from TSPLifesaver.optimizer import SimulatedAnnealing
from TSPLifesaver.tools import route_from_sequence, simulated_annealing
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")
#or you can
route = route_from_sequence([[1,1,1],[2,2,2],[3,3,3]])
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()
# or you can
optimized_route = simulated_annealing(route,epoch=50)
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
TSPLifesaver-0.0.3.tar.gz
(6.3 kB
view details)
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.3.tar.gz.
File metadata
- Download URL: TSPLifesaver-0.0.3.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ecd10f271add264a798bf7fd7f8dcdb29e9f43385e1483c8a87bb949bdbadd10
|
|
| MD5 |
b17bf84651fe0e819b43ed9ceb77807f
|
|
| BLAKE2b-256 |
3f309b4a7a1fbfe5bf0659f79cf9cd290f2c13566034c269c3384e494e3dbe50
|
File details
Details for the file TSPLifesaver-0.0.3-py3-none-any.whl.
File metadata
- Download URL: TSPLifesaver-0.0.3-py3-none-any.whl
- Upload date:
- Size: 7.1 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 |
ffc48fdea223078d1e0a3314dfca15cdf77f797b1e4416fdeffd2a53e3de2ea0
|
|
| MD5 |
6cadad608c8d6d287e95bd6bfd048eab
|
|
| BLAKE2b-256 |
5db8b97cc8592be7659c2e575c09e6e0fb708120617654d2703dd47f72097273
|