Copyright | © 2024–present Mark Karpov |
---|---|

License | BSD 3 clause |

Maintainer | Mark Karpov <markkarpov92@gmail.com> |

Stability | experimental |

Portability | portable |

Safe Haskell | Safe-Inferred |

Language | GHC2021 |

A solution to the assignment problem.

# Documentation

:: (a -> b -> Int) | How to calculate the cost |

-> [a] | The first collection |

-> [b] | The second collection |

-> [(a, b)] | The resulting optimal assignment (no guarantees about order) |

\(\mathcal{O}(n^4)\). Assign elements from two collections to each other so that the total cost is minimal. The cost of each combination is given the by the first argument and it can be negative. If any of the collections is empty the result is the empty list. The sizes of the collections need not to match. Finally, there is no guarantees on the order of elements in the returned list of pairs.

See: https://en.wikipedia.org/wiki/Hungarian_algorithm#Matrix_interpretation