PyLKH
This is a super simple Python wrapper for the constrained traveling salesman and vehicle routing problem solver called LKH-3.
If you want to use this wrapper, you should install LKH-3 first.
LKH-3 expects problems in the TSPLIB95 format. Using PyLKH you can solve problems represented as Python objects (via tsplib95) or files.
Example
import requests
import tsplib95
import lkh
problem_str = requests.get('http://vrp.galgos.inf.puc-rio.br/media/com_vrp/instances/A/A-n32-k5.vrp').text
problem = tsplib95.parse(problem_str)
solver_path = '../LKH-3.0.6/LKH'
lkh.solve(solver_path, problem=problem, runs=10)
Output:
[[26, 7, 13, 17, 19, 31, 21],
[24, 27],
[14, 28, 11, 4, 23, 3, 2, 6],
[29, 18, 8, 9, 22, 15, 10, 25, 5, 20],
[12, 1, 16, 30]]
API
lkh.solve(solver='LKH', problem=None, **kwargs)
Solve a problem.
Parameters
solver (str, optional): Path to LKH-3 executable.
problem (tsplib95.model.StandardProblem, optional): Problem object. problem or problem_file is required.
kwargs (optional): Any LKH-3 parameter described here. Lowercase works. For example: runs=10.
Returns
routes (list): List of lists of nodes.
Metadata
Release files for lkh 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lkh-1.0.1.tar.gz | 2.1 kB | Without provenance | Details for lkh-1.0.1.tar.gz |
Release files / lkh-1.0.1.tar.gz
| Download URL | lkh-1.0.1.tar.gz |
|---|---|
| Size | 2.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ba542f6208ad2a5cac210257d1893819a9d68dde04fa1ec9ec48d8ba26781b77
|
|
BLAKE2b-256 checksum How to use checksums |
24ec403a321268a6e0f250f239c60b070be0e0468d86dd4d64bb1e17c9882392
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5
|
Security for lkh 1.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.