# optimization – How to choose the k points that given a cost matrix with other points, give the minimum sum of distances

For two sets of n dimensional points this is their distance matrix:

``````      p1,1  p1,2  p1,3
p2,1  1     2     3
p2,2  2     5     3
p2,3  2     3     1
p2,4  2     1     8
``````

How can I get the n points of p1,i that give the minimum sum of distances in the most efficient way possible.

So far best I could do was apply the Hungarian assignment algorithm in a loop for all possible teams (this takes $$binom{i}{n}$$ loops though and is not very efficient)