Documentation

CslibFrontier.Algorithms.WordRAM.Hungarian.Instance

Problem instances and encodings for the Word-RAM Hungarian method #

Defines Instance together with its row-major signed-word encoding (Instance.encode), word-width envelope (Instance.wordBound), optimal assignment (Instance.assignment), and minimum matching cost (Instance.encodedMinCost).

An instance of the n × n balanced bipartite minimum-cost assignment problem with integer edge costs.

  • n : ℕ

    Common side size n of the balanced bipartite graph Fin n × Fin n.

  • cost : Fin self.n × Fin self.n → ℤ

    Signed integer cost of pairing row u with column v.

Maximum absolute cost max_{u, v} |cost (u, v)| (0 when n = 0).

Encode an n × n assignment instance as n followed by the n² row-major Signed.encode cost words.

Sufficient word-value envelope covering all input words, array addresses, shifted potentials, slacks, and accumulated matching costs.

Column matched to row u in (hungarian inst.cost).matching.

Row-indexed list [col_0, …, col_{n - 1}] of column indices assigned to rows 0, …, n - 1.

Minimum perfect-matching cost of inst, encoded as an unsigned word via Signed.encode.

The Finset of pairs (u, inst.assignedCol u) equals (hungarian inst.cost).matching.

The induced matching of inst.assignment is a minimum-cost perfect matching of inst.cost.

Summing inst.cost (u, inst.assignedCol u) over all rows equals the minimum matching cost.

Every instance's encoding fits at any word width admitting inst.wordBound.