Skip to main content

Module assignment

Module assignment 

Source
Expand description

The linear sum assignment problem (SciPy’s linear_sum_assignment): match rows to columns of a cost matrix, one-to-one, to minimise (or maximise) the total cost, by the shortest augmenting path algorithm of Jonker and Volgenant as described by Crouse (2016).

See the book entry Assignment, trust regions and global optimisation.

Functions§

linear_sum_assignment
The optimal assignment: pairs (rowᵢ, colᵢ), as many as the smaller dimension, sorted by row, minimising Σ cost[rowᵢ][colᵢ] (maximising with maximize). Each row in turn is joined to the current matching by a shortest augmenting path in the reduced costs, and the dual variables u, v are updated so that all reduced costs stay non-negative (the Hungarian method’s invariant). A tall matrix is transposed first. O(n³). Infinite costs forbid a pair; an error is returned if no complete assignment avoids them, or for NaN or −∞.