Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Find a permutation that minimizes a matrix sum
ResourceFunction["MinSumPermutation"][m] finds a permutation p such that the quantity |
Define a matrix:
In[1]:= | ![]() |
Return the minimizing permutation:
In[2]:= | ![]() |
Out[2]= | ![]() |
The sum:
In[3]:= | ![]() |
Out[3]= | ![]() |
Use on a larger example:
In[4]:= | ![]() |
Out[4]= | ![]() |
For an m×n matrix with m>n, a solution might not exist:
In[5]:= | ![]() |
Out[5]= | ![]() |
If m<n, the result might not necessarily be a permutation:
In[6]:= | ![]() |
Out[6]= | ![]() |
In[7]:= | ![]() |
Out[7]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License