Skip to main content

elkai is a Python library for solving travelling salesman problems (TSP) based on LKH 3

Project description

elkai - a Python library for solving TSP problems

Python build elkai on PyPi


Installation

💾 To install it run pip install elkai

Example usage

import elkai

cities = elkai.Coordinates2D({
    'city1': (0, 0),
    'city2': (0, 4),
    'city3': (5, 0)
})

print(cities.solve_tsp())
import elkai

cities = elkai.DistanceMatrix([
    [0, 4, 0],
    [0, 0, 5],
    [0, 0, 0]
])

print(cities.solve_tsp())

Note

solve_int_matrix and solve_float_matrix are deprecated in v1. Also, they don't contain the departure to origin in the result by default.

License

The LKH native code by Helsgaun is released for non-commercial use only. Therefore the same restriction applies to elkai, which is explained in the LICENSE file.

How it works internally

  • We refactored LKH such that it doesn't have global state and you don't need to restart the program in order to run another input problem
  • We added a hook in ReadProblem that allows reading problems from memory instead of files
  • We read the solution from the Tour variable and put it in a PyObject (Python list).
  • ✓ Valgrind passed on d3d8c12.

⚠️ elkai takes the global interpreter lock (GIL) during the solving phase which means two threads cannot solve problems at the same time. If you want to run other workloads at the same time, you have to run another process - for example by using the multiprocessing module.

If there isn't a prebuilt wheel for your platform, you'll have to follow the scikit-build process.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

elkai-2.0.1.tar.gz (227.7 kB view details)

Uploaded Source

Built Distributions

elkai-2.0.1-cp311-cp311-win_amd64.whl (158.9 kB view details)

Uploaded CPython 3.11 Windows x86-64

elkai-2.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (229.3 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

elkai-2.0.1-cp311-cp311-macosx_13_0_arm64.whl (189.9 kB view details)

Uploaded CPython 3.11 macOS 13.0+ ARM64

elkai-2.0.1-cp311-cp311-macosx_12_0_x86_64.whl (204.9 kB view details)

Uploaded CPython 3.11 macOS 12.0+ x86-64

elkai-2.0.1-cp310-cp310-win_amd64.whl (158.9 kB view details)

Uploaded CPython 3.10 Windows x86-64

elkai-2.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (229.3 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

elkai-2.0.1-cp310-cp310-macosx_13_0_arm64.whl (189.9 kB view details)

Uploaded CPython 3.10 macOS 13.0+ ARM64

elkai-2.0.1-cp310-cp310-macosx_12_0_x86_64.whl (204.9 kB view details)

Uploaded CPython 3.10 macOS 12.0+ x86-64

elkai-2.0.1-cp39-cp39-win_amd64.whl (158.9 kB view details)

Uploaded CPython 3.9 Windows x86-64

elkai-2.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (229.3 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

elkai-2.0.1-cp39-cp39-macosx_13_0_arm64.whl (189.9 kB view details)

Uploaded CPython 3.9 macOS 13.0+ ARM64

elkai-2.0.1-cp39-cp39-macosx_12_0_x86_64.whl (204.9 kB view details)

Uploaded CPython 3.9 macOS 12.0+ x86-64

elkai-2.0.1-cp38-cp38-win_amd64.whl (158.9 kB view details)

Uploaded CPython 3.8 Windows x86-64

elkai-2.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (229.3 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

elkai-2.0.1-cp38-cp38-macosx_13_0_arm64.whl (189.9 kB view details)

Uploaded CPython 3.8 macOS 13.0+ ARM64

elkai-2.0.1-cp38-cp38-macosx_10_16_x86_64.whl (204.9 kB view details)

Uploaded CPython 3.8 macOS 10.16+ x86-64

elkai-2.0.1-cp37-cp37m-win_amd64.whl (158.9 kB view details)

Uploaded CPython 3.7m Windows x86-64

elkai-2.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (229.3 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

elkai-2.0.1-cp37-cp37m-macosx_10_16_x86_64.whl (204.9 kB view details)

Uploaded CPython 3.7m macOS 10.16+ x86-64

File details

Details for the file elkai-2.0.1.tar.gz.

File metadata

  • Download URL: elkai-2.0.1.tar.gz
  • Upload date:
  • Size: 227.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.12.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for elkai-2.0.1.tar.gz
Algorithm Hash digest
SHA256 1d8204b85fc960d2619c280e6143b14c1b62e09c532b388fff51e40e18404ba4
MD5 5e14096a83f1863baef7923fe10509f4
BLAKE2b-256 900e2de87c0770f9939fd4fe6ac5419976e29652e1b409803fae600ea2d328b4

See more details on using hashes here.

Provenance

File details

Details for the file elkai-2.0.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: elkai-2.0.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 158.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0rc2

File hashes

Hashes for elkai-2.0.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0b0b0c8e3e99577322f5f36b9e6bcb57444bffc2a1555a041fb9b0e3c8813d0c
MD5 7e024e2b46c6590d721b1bb5490d69b9
BLAKE2b-256 c73e853ef88f4ed6e362098a073bd054d332ad4d43f9ac9c228b313eb08f791b

See more details on using hashes here.

Provenance

File details

Details for the file elkai-2.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for elkai-2.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5110f1845f2e83424e5e1e1e154a87f23c5f6a62d25366aa5fb8f4020c52a1b9
MD5 3351f8ab17e78ed3fdc6dd7578bf37ec
BLAKE2b-256 ddbcfbc745554da2f4b6387d9e554d97b86bf0b8a9ebbc6f57917723770d18d4

See more details on using hashes here.

Provenance

File details

Details for the file elkai-2.0.1-cp311-cp311-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for elkai-2.0.1-cp311-cp311-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 795df6b51c89a628bc8425443eaf8fd0df37ace76fa3f2effb9567a5fd16f53e
MD5 4e4d9dca7e39ac75e6c1ad5ad75bcb11
BLAKE2b-256 2e35672bb00e2946f7b27f92f6f5b24bf7ca67b8f331a6b4415f6dce1a2093e2

See more details on using hashes here.

Provenance

File details

Details for the file elkai-2.0.1-cp311-cp311-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for elkai-2.0.1-cp311-cp311-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 0020189976045beca79495b6ddb9f3e3f2970290efc8cc8a3954eb7579304325
MD5 17ed68288695505cabbc693bac41b710
BLAKE2b-256 b9ad32bec43e3133751b8675a4ec78ccb709c437acee181d728667f5bd45c921

See more details on using hashes here.

Provenance

File details

Details for the file elkai-2.0.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: elkai-2.0.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 158.9 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0rc2

File hashes

Hashes for elkai-2.0.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 62590df53d3207e7d2b05faf5d45eddcbbb1d2c255614907d450aab903b20611
MD5 55e9635fd373c125184b6996d7294089
BLAKE2b-256 cd5c1e7bde6ca78f6d8f12dab8684a301ab40fcca670313bf085c23d07a47b7d

See more details on using hashes here.

Provenance

File details

Details for the file elkai-2.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for elkai-2.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b71b5b03286288c2cdb27bb3d18fcf1710e8371125affcfdd91495c2bc4d501b
MD5 635c99860bab23fb77c260ed0ed4425d
BLAKE2b-256 2ccb97afba712f0bda55bd0d95fd33d31ee6429e133a77375e2b4e4cd26d6e96

See more details on using hashes here.

Provenance

File details

Details for the file elkai-2.0.1-cp310-cp310-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for elkai-2.0.1-cp310-cp310-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 61afde5a687f6cb4a41af710b308eaafe3ef7ef8c4c3e0ce3a1e1ae5d395f48e
MD5 4fa22e9708d6c35e3cc959ad98eca0b1
BLAKE2b-256 09813fb5637f892022f69d7d6a83ff1f95354a5376c4da15b86f2ca97ffdbab0

See more details on using hashes here.

Provenance

File details

Details for the file elkai-2.0.1-cp310-cp310-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for elkai-2.0.1-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 66c85d0ed8b31bcb114a320372b6e7a5651815d94d00bbc157cd893c4e9ac6ef
MD5 c07d57b36734e20cd20a934ea40246b3
BLAKE2b-256 ebf95038eee9504fccd5d77c181b80cdf1da360200b82907dcaf079bea3bdbac

See more details on using hashes here.

Provenance

File details

Details for the file elkai-2.0.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: elkai-2.0.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 158.9 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.12.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for elkai-2.0.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 2b4b68ee236d2c516d8637c190da937719d5730d29d86e2a0b43e0d4a35f6fd1
MD5 a6fd163d694ffe1219d8ee51271ae004
BLAKE2b-256 cd31824ec5c3af4b1111ed58829f094db1cb6e83229157dc2db471f22ce54e43

See more details on using hashes here.

Provenance

File details

Details for the file elkai-2.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for elkai-2.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9af53cb126080a9e8c6e802121cad43a7d4b75431aae73d75e3e3588ca5fa893
MD5 86e8125c513100482ba6292860e5f32a
BLAKE2b-256 d6fd82eda1864539b7e62225d4ca2f9220bfda280c620131252278a48f715602

See more details on using hashes here.

Provenance

File details

Details for the file elkai-2.0.1-cp39-cp39-macosx_13_0_arm64.whl.

File metadata

  • Download URL: elkai-2.0.1-cp39-cp39-macosx_13_0_arm64.whl
  • Upload date:
  • Size: 189.9 kB
  • Tags: CPython 3.9, macOS 13.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.12.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for elkai-2.0.1-cp39-cp39-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 90cbe996ce6a6a07e1875fb3912674d715bd67c24d60973288a89d3f339aea3a
MD5 8739c9b41d1ca29b4395738ace2fd42d
BLAKE2b-256 5e1b705909e941ee8b6c0ac59cd58c9debf2670797dfdad37f42471d315e969d

See more details on using hashes here.

Provenance

File details

Details for the file elkai-2.0.1-cp39-cp39-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for elkai-2.0.1-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 4ae47bb761928a80e4ec50387ce21f757ef665575b3b4cde85774e7dad513025
MD5 6b7af7b46d7100b10c32ae1f61c4701b
BLAKE2b-256 76efaccc9d062078005232ff428bff8ac4e4d128a13eac06126ebc83a73d0d20

See more details on using hashes here.

Provenance

File details

Details for the file elkai-2.0.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: elkai-2.0.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 158.9 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0rc2

File hashes

Hashes for elkai-2.0.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 221c0f884386770cc0958f6d8b8573b9cb66b8b3d993dcb8329b26710a09e401
MD5 f87133381391d9d8dd70eae56243eabb
BLAKE2b-256 756e8e1ea710257184127201c64fca1b4f206299285cac1ade0e1424097948af

See more details on using hashes here.

Provenance

File details

Details for the file elkai-2.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for elkai-2.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ee99338cb3a370ba8be2e3fb750e231f21c28bbf05bb8908bad9e256fdaaa437
MD5 06790ceb96cbd20c58fc70dc2d1e4d98
BLAKE2b-256 dc15b06fc4765a92e0727f2cd4ba54526d09a46148768441d4a320f83fff7840

See more details on using hashes here.

Provenance

File details

Details for the file elkai-2.0.1-cp38-cp38-macosx_13_0_arm64.whl.

File metadata

  • Download URL: elkai-2.0.1-cp38-cp38-macosx_13_0_arm64.whl
  • Upload date:
  • Size: 189.9 kB
  • Tags: CPython 3.8, macOS 13.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.12.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for elkai-2.0.1-cp38-cp38-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 b3d046c382838b6e195620a9cc1dbbebff0d21a8564cf13e13464300b389fb8b
MD5 a4a653694b07fa87e04ce802ec567e51
BLAKE2b-256 83265b7aa5388bd48b98d6dab4d25782dd26e2189b117e4908df7d12f4dc9fe8

See more details on using hashes here.

Provenance

File details

Details for the file elkai-2.0.1-cp38-cp38-macosx_10_16_x86_64.whl.

File metadata

File hashes

Hashes for elkai-2.0.1-cp38-cp38-macosx_10_16_x86_64.whl
Algorithm Hash digest
SHA256 7825e298ba04d715602f61b837c91e9ce6f5d3c05cb4c9d745cad602f51a46f2
MD5 8423a321a96af29cf7694adc9cb474e9
BLAKE2b-256 44632e2b7a7f1b78af9f66f1e9e5e07384b709aa511dcb054104efe16d077fce

See more details on using hashes here.

Provenance

File details

Details for the file elkai-2.0.1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: elkai-2.0.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 158.9 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0rc2

File hashes

Hashes for elkai-2.0.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 16e56434a81ebcde60ac8c2e9742a63971b913e37e1ccbfd4b933ba0fe49f9a4
MD5 42b89eb748093d3605aa3ef9b21ca694
BLAKE2b-256 26cfe7b8de6614df03215015e32def8cef9f088b4064aa0539d7534d48236e33

See more details on using hashes here.

Provenance

File details

Details for the file elkai-2.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for elkai-2.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f37405dc29c877e73c061251f26421b2bf982b765785f6fd9689a723755d0018
MD5 b7826332b41ae6d41211b9659fc0d0e3
BLAKE2b-256 ea63c395fa4db36c982ad34c78439780fb11101c60363f0f75b1429876df13fb

See more details on using hashes here.

Provenance

File details

Details for the file elkai-2.0.1-cp37-cp37m-macosx_10_16_x86_64.whl.

File metadata

File hashes

Hashes for elkai-2.0.1-cp37-cp37m-macosx_10_16_x86_64.whl
Algorithm Hash digest
SHA256 093b97ffabbeecc802adc93594843cc6115ed149b6dc09d1c9ddf15e86f934b1
MD5 774141347a6c9666c90d90c17e2642e2
BLAKE2b-256 c6f74a971ec200ee8ec328c99ed7d17418f69046ead106c697c41927d4b8cc8b

See more details on using hashes here.

Provenance

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