shortest path across matrix

58 Views Asked by At

I have a matrix of real numbers, $D$, of dimensions $n\times m$ where $n\neq m$.

The elements of this matrix are $d_{ij}$ where $i=1,...,n$ and $j=1,...,m$

\begin{bmatrix} d_{11} & d_{12} & d_{13} & \dots & d_{1m} \\ d_{21} & d_{22} & d_{23} & \dots & d_{2m} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ d_{n1} & d_{n2} & d_{n3} & \dots & d_{nm} \end{bmatrix}

For each row I wish to find the element $d_{ij}$, so that the sum of these $n$ elements is the minimum. The only constraint to this is that none of these elements can share the same $j$-index, even though $\min\{d_{i1},d_{i2},...,d_{im}\}$ and $\min\{d_{(i+1)1},d_{(i+1)2},...,d_{(i+1)m}\}$ might occur at the same $j$.

For example, if $n=5$ and $m=6$ we cannot pick $[d_{11},d_{22},d_{32},d_{44},d_{56}]$ because $d_{22}$ and $d_{32}$ share the same $j$. But we can have $[d_{11},d_{22},d_{33},d_{44},d_{56}]$.

Of course, if there were no such constraint, I could just take the minimum value of each row and be done with it, but I don't know how to tackle this additional constraint.

1

There are 1 best solutions below

1
On BEST ANSWER

This is a matching problem!

There are several well researched and understood algorithms to solve this kind of problems, of which the hungarian algorithm is perhaps the most famous one.