Picking one element per row per column to give the smallest combination of absolute values

I am trying to find the minimum combination of absolute values from this matrix.

mat =
{{-348, -194, -191, -101, -67, 31},
{-293, -139, -136, -46, -12, 86},
{-261, -107, -104, -14, 20, 118},
{-139, 15, 18, 108, 142, 240},
{-151, 3, 6, 96, 130, 228},
{4, 158, 161, 251, 285, 383}}


I want to find a set of 6 elements that have the smallest sum of the absolute values when taking one element per row and per column. So in this case, either {4, 3, 18, 14, 12, 31} or {4, 15, 6, 14, 12, 31}.

• What do you mean by minimum combination? At least two non-equal elements? Please define. – Mauricio Fernández Aug 1 '17 at 8:03
• If you mean two non-equal elements, try first evaluating eval = Flatten[ Table[{{i1, j1}, {i2, j2}, Abs@mat[[i1, j1]] + Abs@mat[[i2, j2]]}, {i1, 1, n}, {j1, 1, n}, {i2, DeleteCases[Range@n, i1]}, {j2, DeleteCases[Range@n, j1]}], 3]; and then extracting the minimum with min = Extract[eval, First@Position[eval[[;; , 3]], Min@eval[[;; , 3]]]] – Mauricio Fernández Aug 1 '17 at 8:10
• @MauricioLobos He needs 6 numbers chosen such that each row/column is used exactly once, e.g. the numbers at positions {{1, 2}, {5, 6}, {6, 4}, {4, 5}, {2, 1}, {3, 3}}. There is dim! possibilities and for the matrix he mention there are two with minimal summed absolute value – Coolwater Aug 1 '17 at 8:12
• Same problem: stackoverflow.com/questions/37949485 – Coolwater Aug 1 '17 at 8:33
• Hey all, thank you leading me to the hungarian algorithm. That makes so much sense to tackling this problem. My issue is that my mathematica coding skills are terrible. Any hints to this would be very much appreciated. Thank you! – gweeish Aug 2 '17 at 6:43