Metadata-Version: 2.3
Name: tsp-tools
Version: 0.3.2
Summary: `tsp-tools` is a package for Traveling Salesman Problem for Python.
Project-URL: homepage, https://github.com/SaitoTsutomu/tsp-tools
Author-email: Saito Tsutomu <tsutomu7@hotmail.co.jp>
License: Apache-2.0
License-File: LICENSE
Classifier: Development Status :: 1 - Planning
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Software Development
Requires-Python: >=3.12
Requires-Dist: more-itertools>=10.5.0
Requires-Dist: pandas>=2.2.3
Requires-Dist: pulp>=2.9.0
Description-Content-Type: text/markdown

`tsp-tools` is a package for Traveling Salesman Problem for Python.

## Usage

```python
import tsp_tools
t = tsp_tools.tsp([(0,0), (0,1), (1,0), (1,1)])
print(t)  # distance, node index list
>>>
(4.0, [0, 2, 3, 1])
```

```python
mat = [
    [  0,   1, 1, 1.5],
    [  1,   0, 1.5, 1],
    [  1, 1.5,   0, 1],
    [1.5,   1,   1, 0],
]  # Distance Matrix
r = range(len(mat))
# Dictionary of distance
dist = {(i, j): mat[i][j] for i in r for j in r}
print(tsp_tools.tsp(r, dist))
>>>
(4.0, [0, 2, 3, 1])
```

Note: When large size, `ortoolpy.ortools_vrp` may be efficient.

See also https://pypi.org/project/ortoolpy/

## Requirements

* Python 3
* more-itertools

## Setup

```sh
$ pip install tsp-tools
```

## History

* 0.0.1 (2015-10-2): first release
