{"id":13677977,"url":"https://github.com/jvkersch/pyconcorde","last_synced_at":"2025-04-05T18:05:00.704Z","repository":{"id":21686540,"uuid":"87963232","full_name":"jvkersch/pyconcorde","owner":"jvkersch","description":"Python wrapper around the Concorde TSP solver","archived":false,"fork":false,"pushed_at":"2024-05-05T08:55:59.000Z","size":3621,"stargazers_count":363,"open_issues_count":20,"forks_count":100,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-29T17:02:13.294Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jvkersch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-11T17:48:56.000Z","updated_at":"2025-03-29T12:02:46.000Z","dependencies_parsed_at":"2023-01-11T21:19:02.622Z","dependency_job_id":"d63aaad1-fc65-4c8f-9fa4-bdc4c2cb9c7a","html_url":"https://github.com/jvkersch/pyconcorde","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jvkersch%2Fpyconcorde","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jvkersch%2Fpyconcorde/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jvkersch%2Fpyconcorde/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jvkersch%2Fpyconcorde/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jvkersch","download_url":"https://codeload.github.com/jvkersch/pyconcorde/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247378135,"owners_count":20929296,"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":[],"created_at":"2024-08-02T13:00:49.049Z","updated_at":"2025-04-05T18:05:00.680Z","avatar_url":"https://github.com/jvkersch.png","language":"Python","funding_links":[],"categories":["Python","**Other Resources**"],"sub_categories":["Code Repositories"],"readme":"PyConcorde\n==========\n\n![Build Status](https://github.com/jvkersch/pyconcorde/actions/workflows/run-unittests.yml/badge.svg)\n\n\nWhat is it?\n-----\n\nPyConcorde is a Python wrapper around the [Concorde TSP\nsolver](http://www.math.uwaterloo.ca/tsp/concorde.html).\n\nPyConcorde allows you to compute solutions to the Traveling Salesman Problem\nwith just a few lines of Python code. It uses the state-of-the-art Concorde\nsolver and provides a convenient Python layer around it.\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"examples/us_state_capitals.py\"\u003e\n\t\u003cimg src=\"examples/us_state_capitals.png\" alt=\"US state capital tour\"/\u003e\n\t\u003c/a\u003e\n\u003c/p\u003e\n\nNote: until commit e065497 (pre version 0.1) PyConcorde was called PyTSP. It\nwas renamed to emphasize the central role of the underlying Concorde solver.\n\nHow do I install it?\n------\nPyConcorde runs under Python 3.7 and higher and requires a UNIX-like OS \n(Native Windows not supported, but it can be run under WSL). It needs the [Concorde TSP\nsolver](http://www.math.uwaterloo.ca/tsp/concorde.html) and [QSOpt linear\nprogramming library](http://www.math.uwaterloo.ca/~bico/qsopt/). Further\ninstructions on building/downloading those can be found below.\n\nTo build PyConcorde, clone the repository:\n\n    git clone https://github.com/jvkersch/pyconcorde\n\tcd pyconcorde\n\t\nThen run \n\n\tpip install -e .\n\t\nOr, alternatively, all in one line, run:\n\n\tpip install 'pyconcorde @ git+https://github.com/jvkersch/pyconcorde'\n\t\t\n\t\nThis will download and build Concorde (and its dependency QSOpt) and then build\nPyConcorde. While this may take a few minutes, downloading Concorde only\nhappens the first time the install script is run (unless you remove the `data`\ndirectory).\n\nIf you already have Concorde and/or QSOpt installed (or an equivalent linear\nsolver), you can use those instead. Simply set the environment variable\n`CONCORDE_DIR` (or `QSOPT_DIR`) to point to the folder where you installed\nConcorde (or QSOpt).\n\nDetailed instructions to build Concorde can be found at [this web\npage](https://github.com/perrygeo/pytsp/wiki/Installing-Solvers).\n\nWhat can I do with it?\n-------\n\nPyConcorde is a very light-weight library. The main entry point is the\n`TSPSolver` class. Here we use it to read in the Berlin52 dataset, a dataset of\n52 locations in Berlin (part of the TSPlib test data).\n\n```python\n    \u003e\u003e\u003e from concorde.tsp import TSPSolver\n    \u003e\u003e\u003e from concorde.tests.data_utils import get_dataset_path\n    \u003e\u003e\u003e fname = get_dataset_path(\"berlin52\")\n    \u003e\u003e\u003e solver = TSPSolver.from_tspfile(fname)\n    Problem Name: berlin52\n    Problem Type: TSP\n    52 locations in Berlin (Groetschel)\n    Number of Nodes: 52\n    Rounded Euclidean Norm (CC_EUCLIDEAN)\n```    \n\nAs you can see above, PyConcorde (or rather, Concorde) is somewhat chatty and\nwill print various message to the standard output. Now that we have a solver\ninstance, let's compute a solution. On my machine this is almost instantaneous.\n   \n```python    \n    \u003e\u003e\u003e solution = solver.solve()\n    (... output snipped for brevity ...)\n```\n\nAgain, Concorde will display a variety of messages while it's running. The end\nresult is a `ComputedTour` object called `solution` with information about the\ntour that we just computed:\n\n```python\n    \n    \u003e\u003e\u003e solution.found_tour\n    True\n    \u003e\u003e\u003e solution.optimal_value\n    7542.0\n    \u003e\u003e\u003e solution.tour\n    array([ 0, 48, 31, 44, 18, 40,  7,  8,  9, 42, 32, 50, 10, 51, 13, 12, 46,\n           25, 26, 27, 11, 24,  3,  5, 14,  4, 23, 47, 37, 36, 39, 38, 35, 34,\n           33, 43, 45, 15, 28, 49, 19, 22, 29,  1,  6, 41, 20, 16,  2, 17, 30,\n           21], dtype=int32)\n    \n```\n\nOther TSP solvers for Python\n----------------------------\n\nSeveral other TSP implementations exist. The following are written in pure\nPython:\n\n- [tsp-solver](https://github.com/dmishin/tsp-solver)\n- [python-tsp](https://github.com/fillipe-gsm/python-tsp)\n\nIf you have another TSP algorithm that can be called from within Python, and\nyou want to have it added here, please open an issue.\n\nTechnical Notes\n-------\n\nPyConcorde needs Concorde and QSOpt. Downloading and building these packages\nshould happen automatically on Linux/Mac OS, but please file an issue if you\nexperience any trouble during this step.\n\nNote that Windows is currently unsupported. If you get the library to work on\nWindows, please open a ticket to describe any tweaks (or better yet, a Pull\nRequest).\n\nLicense\n-----\n\nPyConcorde is licensed under the [Modified BSD license](COPYING). Note that\nConcorde and QSOpt are released under different licenses, and that PyConcorde\ndoes not include any code from these packages.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjvkersch%2Fpyconcorde","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjvkersch%2Fpyconcorde","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjvkersch%2Fpyconcorde/lists"}