0

I have two nx2 matrices of doubles, A & B containing x and y coordinates in each row. I have to pair one point from A with one point from B such that its done optimally in terms of euclidean distance heuristic meaning suppose A contains people initial locations and B contains treasure positions. Each agent just wants to reach its nearest treasure as all treasures are equal.

This is slightly different than multi-TSP. I am looking for the optimal algorithm to implement which is not an overkill for this problem. Naive approach is to start with first agent and start pairing agents to treasures until all agents are done. And once an agent has been paired to a treasure the treasure is no more up for further allocation. This is what i implemented in Matlab for now but am open to better solutions.

user_1_1_1
  • 903
  • 1
  • 12
  • 27
  • 3
    The problem you described is the **weighted bipartite matching** problem (https://en.wikipedia.org/wiki/Matching_(graph_theory)#In_weighted_bipartite_graphs). The hungarian algorithm (https://en.wikipedia.org/wiki/Hungarian_algorithm) might be what you need - quite efficient and not so complex – Can Nguyen Nov 17 '16 at 02:28
  • Absolutely correct answer. It solved my problem! – user_1_1_1 Nov 18 '16 at 23:29

1 Answers1

0

I assume the exhaustive O(n * n) is out of the question? Using memoization you can improve on the exhaustive solution by aborting once the total distance of the current "best" is exceeded.

Eric M.
  • 642
  • 5
  • 16