{"id":13419356,"url":"https://github.com/fikisipi/elkai","last_synced_at":"2025-03-15T05:30:57.069Z","repository":{"id":55123013,"uuid":"184775767","full_name":"fikisipi/elkai","owner":"fikisipi","description":"elkai is a Python library for solving travelling salesman problems (TSP) based on LKH 3","archived":false,"fork":false,"pushed_at":"2023-05-09T17:34:19.000Z","size":3041,"stargazers_count":172,"open_issues_count":11,"forks_count":17,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-09-28T13:34:59.279Z","etag":null,"topics":["elkai","optimization","python","python-tsp","travelling-salesman-problem","tsp"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fikisipi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-03T15:06:11.000Z","updated_at":"2024-08-28T10:55:56.000Z","dependencies_parsed_at":"2022-08-14T12:40:39.132Z","dependency_job_id":null,"html_url":"https://github.com/fikisipi/elkai","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fikisipi%2Felkai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fikisipi%2Felkai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fikisipi%2Felkai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fikisipi%2Felkai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fikisipi","download_url":"https://codeload.github.com/fikisipi/elkai/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221541863,"owners_count":16840112,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elkai","optimization","python","python-tsp","travelling-salesman-problem","tsp"],"created_at":"2024-07-30T22:01:14.816Z","updated_at":"2024-10-26T14:31:28.974Z","avatar_url":"https://github.com/fikisipi.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n \u003cimg src=\"https://raw.githubusercontent.com/fikisipi/elkai/assets/elkaiv2.png\" alt=\"\" /\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003cem\u003eelkai - a Python library for solving TSP problems\u003c/em\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/fikisipi/elkai/actions/workflows/python-app.yml\"\u003e\u003cimg src=\"https://github.com/fikisipi/elkai/actions/workflows/python-app.yml/badge.svg\" alt=\"Python build\"\u003e\u003c/a\u003e\n\u003ca href=\"https://pypi.org/project/elkai/\"\u003e\u003cimg src=\"https://img.shields.io/pypi/v/elkai.svg\" alt=\"elkai on PyPi\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n----\n\n* **based on [LKH](http://akira.ruc.dk/~keld/research/LKH/) by Keld Helsgaun**: with proven optimal solutions up to N=315 and more accurate results than [Google's OR tools](https://developers.google.com/optimization/routing/tsp)\n* **asymmetric and symmetric** [travelling salesman problems](https://en.wikipedia.org/wiki/Travelling_salesman_problem) support\n* **clean and simple API**: get results with one line calls\n\n## Installation\n\n💾 **To install it** run `pip install elkai`\n\n## Example usage\n\n```python\nimport elkai\n\ncities = elkai.Coordinates2D({\n    'city1': (0, 0),\n    'city2': (0, 4),\n    'city3': (5, 0)\n})\n\nprint(cities.solve_tsp()) # Output: ['city1', 'city2', 'city3', 'city1']\n```\n\n```python\nimport elkai\n\ncities = elkai.DistanceMatrix([\n    [0, 4, 0],\n    [0, 0, 5],\n    [0, 0, 0]\n])\n\nprint(cities.solve_tsp()) # Output: [0, 2, 1, 0]\n```\n\n\u003e **Note**\n\u003e\n\u003e [solve_int_matrix](https://github.com/fikisipi/elkai/blob/55187e83e7d91ee597b408c8644632fb0ef2687f/elkai/__init__.py#L33) and [solve_float_matrix](https://github.com/fikisipi/elkai/blob/55187e83e7d91ee597b408c8644632fb0ef2687f/elkai/__init__.py#L38) are deprecated in v1. Also, they don't contain the departure to origin in the result by default.\n\n## License\n\nThe 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. \n\n## How it works internally\n\n* 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\n* We added a hook in ReadProblem that allows reading problems from memory instead of files\n* We read the solution from the `Tour` variable and put it in a PyObject (Python list).\n* ✓ Valgrind passed on `d3d8c12`.\n\n⚠️ 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.\n\nIf there isn't a prebuilt wheel for your platform, you'll have to follow the `scikit-build` process.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffikisipi%2Felkai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffikisipi%2Felkai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffikisipi%2Felkai/lists"}