{"id":17222767,"url":"https://github.com/cheind/py-lapsolver","last_synced_at":"2025-05-16T05:04:12.831Z","repository":{"id":29249040,"uuid":"120568765","full_name":"cheind/py-lapsolver","owner":"cheind","description":"Fast linear assignment problem (LAP) solvers for Python based on c-extensions","archived":false,"fork":false,"pushed_at":"2024-11-29T07:44:14.000Z","size":219,"stargazers_count":160,"open_issues_count":3,"forks_count":24,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-16T05:03:45.860Z","etag":null,"topics":["linear-assignment-problem","python","solver"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cheind.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-07T05:42:25.000Z","updated_at":"2025-04-03T14:49:02.000Z","dependencies_parsed_at":"2024-06-18T18:34:30.687Z","dependency_job_id":"8e337b9f-7954-4976-8518-6f0414cf9b9a","html_url":"https://github.com/cheind/py-lapsolver","commit_stats":{"total_commits":86,"total_committers":6,"mean_commits":"14.333333333333334","dds":"0.11627906976744184","last_synced_commit":"347b73f7216dd39e3689f2f64827d45141250962"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Fpy-lapsolver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Fpy-lapsolver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Fpy-lapsolver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheind%2Fpy-lapsolver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cheind","download_url":"https://codeload.github.com/cheind/py-lapsolver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254471061,"owners_count":22076585,"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":["linear-assignment-problem","python","solver"],"created_at":"2024-10-15T04:06:18.721Z","updated_at":"2025-05-16T05:04:12.804Z","avatar_url":"https://github.com/cheind.png","language":"Python","readme":"## py-lapsolver\n\n**py-lapsolver** implements a Linear sum Assignment Problem (LAP) solver for dense matrices based on shortest path augmentation in Python. In practice, it solves 5000x5000 problems in around 3 seconds.\n\n### Install\n\n```\npip install [--pre] lapsolver \n```\n\nWindows binary wheels are provided for Python 3.5/3.6. Source wheels otherwise.\n\n### Install from source\n\nClone this repository \n\n```\ngit clone --recursive https://github.com/cheind/py-lapsolver.git\n``` \n\nThen build the project and exectute tests\n\n```\npython setup.py develop\npython setup.py test\n```\n\nExecuting the tests requires `pytest` and optionally `pytest-benchmark` for generating benchmarks.\n\n### Usage\n\n```python\nimport numpy as np\nfrom lapsolver import solve_dense\n\ncosts = np.array([\n    [6, 9, 1],\n    [10, 3, 2],\n    [8, 7, 4.]\n], dtype=np.float32)    \n\nrids, cids = solve_dense(costs)\n\nfor r,c in zip(rids, cids):\n    print(r,c) # Row/column pairings\n\"\"\"\n0 2\n1 1\n2 0\n\"\"\"\n```\n\nYou may also want to mark certain pairings impossible\n\n```python\n# Matrix with non-allowed pairings\ncosts = np.array([\n    [5, 9, np.nan],\n    [10, np.nan, 2],\n    [8, 7, 4.]]\n)\n\nrids, cids = solve_dense(costs)\n\nfor r,c in zip(rids, cids):\n    print(r,c) # Row/column pairings\n\"\"\"\n0 0\n1 2\n2 1\n\"\"\"\n```\n\n### Benchmarks\n\nComparisons below are generated by scripts in [`./lapsolver/benchmarks`](./lapsolver/benchmarks). \n\nCurrently, the following solvers are tested\n - `lapjv` - https://github.com/gatagat/lap\n - `munkres` - http://software.clapper.org/munkres/\n - `ortools` - https://github.com/google/or-tools **\n - `scipy` - https://github.com/scipy/scipy/tree/master/scipy\n - `lapsolver` - this project\n\n**reduced performance due to costly dense matrix to graph conversion. If you know a better way, please let me know.\n\nPlease note that the x-axis is scaled logarithmically. Missing bars indicate excessive runtime or errors in returned result.\n![](./lapsolver/etc/benchmark-dtype-int.png)\n![](./lapsolver/etc/benchmark-dtype-numpy.float32.png)\n\n#### Additional Benchmarks\n\nBerhane performs an in depth analysis of Python3 linear assignment problem solver at https://github.com/berhane/LAP-solvers\n\n### References\n**py-lapsolver** heavily relies on [code](https://github.com/jaehyunp/stanfordacm/blob/9e1375cd4eba68a59dd7b1e2f81692653e9908a9/code/MinCostMatching.cc) published by  @jaehyunp at https://github.com/jaehyunp/\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheind%2Fpy-lapsolver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcheind%2Fpy-lapsolver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheind%2Fpy-lapsolver/lists"}