|
1 | | - |
2 | | -# fastlap |
| 1 | +# **fastlap** |
3 | 2 |
|
4 | 3 | **Python’s LAP (Linear Assignment Problem) solver — written in Rust for performance.** |
5 | 4 |
|
6 | | -`fastlap` provides a blazing-fast implementation of common assignment algorithms such as: |
| 5 | +`fastlap` delivers a blazing-fast implementation of popular assignment algorithms, including: |
7 | 6 |
|
8 | | -- Jonker-Volgenant (LAPJV) |
9 | | -- Hungarian (a.k.a. Munkres) |
| 7 | +* **Jonker–Volgenant (LAPJV)** |
| 8 | +* **Hungarian (a.k.a. Munkres)** |
| 9 | +* **LAPMOD** |
10 | 10 |
|
11 | | -Built with [Rust](https://www.rust-lang.org/) and exposed to Python via [PyO3](https://pyo3.rs), this library offers performance and interoperability in one package. |
| 11 | +Built with [Rust](https://www.rust-lang.org/) and exposed to Python via [PyO3](https://pyo3.rs), `fastlap` combines performance and interoperability in a single lightweight package. |
12 | 12 |
|
13 | 13 |
|
14 | | -## ✨ Features |
| 14 | +## 📖 Algorithms |
15 | 15 |
|
16 | | -- ✅ Fast and memory-safe implementation in Rust |
17 | | -- ✅ Python bindings via PyO3 |
18 | | -- ✅ Supports both `lapjv` and `hungarian` algorithms |
19 | | -- ✅ Can be used in native Rust projects or as a Python package |
| 16 | +* **LAPJV** — Efficient dual-based shortest augmenting path algorithm |
| 17 | + *(Jonker & Volgenant, 1987)* |
| 18 | +* **Hungarian Algorithm** — Classic method using row/column reduction and assignment phases |
| 19 | +* **LAPMOD** — A modified variant for better performance under specific conditions |
20 | 20 |
|
21 | 21 |
|
22 | | -## 📖 Algorithms |
| 22 | +## 🚀 Usage |
23 | 23 |
|
24 | | -* **LAPJV** – Efficient dual-based shortest augmenting path algorithm (Jonker & Volgenant, 1987) |
25 | | -* **Hungarian** – Classic method with row/column reduction and assignment phases |
| 24 | +```python |
| 25 | +import fastlap |
26 | 26 |
|
27 | | -## Roadmap |
| 27 | +# Example cost matrix |
| 28 | +matrix = [ |
| 29 | + [1, 2, 3], |
| 30 | + [4, 5, 6], |
| 31 | + [7, 8, 9] |
| 32 | +] |
28 | 33 |
|
29 | | -- [ ] Release first version |
30 | | -- [ ] Add more algorithms |
31 | | -- [ ] Add more features |
32 | | -- [ ] Add more examples |
33 | | -- [ ] Add more tests |
34 | | -- [ ] Add more benchmarks |
| 34 | +# Solve the LAP using LAPJV algorithm |
| 35 | +cost, row_assign, col_assign = fastlap.solve_lap(matrix, method="lapjv") |
35 | 36 |
|
| 37 | +print("Total cost:", cost) |
| 38 | +print("Row assignments:", row_assign) |
| 39 | +print("Column assignments:", col_assign) |
| 40 | +``` |
36 | 41 |
|
37 | | -## 📚 References |
38 | 42 |
|
39 | | -* Jonker, R., & Volgenant, A. (1987). *A shortest augmenting path algorithm for dense and sparse linear assignment problems*. Computing, 38(4), 325–340. |
40 | | -* Munkres, J. (1957). *Algorithms for the Assignment and Transportation Problems*. Journal of the Society for Industrial and Applied Mathematics. |
| 43 | +## 📄 Citation |
41 | 44 |
|
| 45 | +If you use `fastlap` in your research or project, please cite the following: |
| 46 | + |
| 47 | +``` |
| 48 | +@misc{fastlap2025, |
| 49 | + author = {Le Duc Minh}, |
| 50 | + title = {fastlap: A Python LAP solver powered by Rust}, |
| 51 | + year = {2025}, |
| 52 | + howpublished = {\url{https://github.com/8Opt/fastlap}}, |
| 53 | + note = {Python-Rust LAP solver implementing LAPJV, Hungarian, and LAPMOD} |
| 54 | +} |
| 55 | +``` |
42 | 56 |
|
43 | | -## 📃 License |
44 | 57 |
|
45 | | -MIT License © 2025 |
| 58 | +## 📃 License |
46 | 59 |
|
| 60 | +**MIT License** © 2025 — use it freely in commercial or open-source projects. |
0 commit comments