8

Given are two sets of three-dimensional points, a source and a destination set. The number of points on each set is arbitrary (may be zero). The task is to assign one or no source point to every destination point, so that the sum of all distances is minimal. If there are more source than destination points, the additional points are to be ignored.

There is a brute-force solution to this problem, but since the number of points may be big, it is not feasible. I heard this problem is easy in 2D with equal set sizes, but sadly these preconditions are not given here.

I'm interested in both approximations and exact solutions.

Edit: Haha, yes, I suppose it does sound like homework. Actually, it's not. I'm writing a program that receives positions of a large number of cars and i'm trying to map them to their respective parking cells. :)

mafu
  • 31,798
  • 42
  • 154
  • 247
  • Mapping cars to parking cells? Haha is right, If you want any help you should either give a fuller / more plausible explanation or come clean, add the "homework" tag yourself and sketch out what you've done so far. – MarkusQ Mar 09 '09 at 15:01
  • 2
    I'm sorry, but it is not homework. If i had a CS major and were able to figure out a usable algorithm myself i would not ask on SO. – mafu Mar 09 '09 at 15:07
  • 2
    What would it matter if it is homework? If it is, mafutrct only risks not getting the answers that are most beneficial to him/herself. The question itself is valid and not unlikely to be useful to others. – mweerden Mar 09 '09 at 15:26
  • It is just how lecturers use language that gives off that homework smell. – whatnick Apr 30 '12 at 06:53
  • @whatnick: I tried to formulate it in a neutral language, because it is best fit for understanding the problem at hand. I'm not a fan of verbose and too specific descriptions. Obviously, that's just what they do at higher schools, too. – mafu Apr 30 '12 at 10:54

3 Answers3

4

One way you could approach this problem is to treat is as the classical assignment problem: http://en.wikipedia.org/wiki/Assignment_problem

You treat the points as the vertices of the graph, and the weights of the edges are the distance between points. Because the fastest algorithms assume that you are looking for maximum matching (and not minimum as in your case), and that the weights are non-negative, you can redefine weights to be e.g.:

weight(A, B) = bigNumber- distance(A,B)

where bigNumber is bigger than your longest distance.

Obviously you end up with a bipartite graph. Then you use one of the standard algorithms for maximum weighted bipartite matching (lots of resources on the web, e.g. http://valis.cs.uiuc.edu/~sariel/teach/courses/473/notes/27_matchings_notes.pdf or Wikipedia for overview: http://en.wikipedia.org/wiki/Perfect_matching#Maximum_bipartite_matchings) This way you will end-up with a O(NM max(N,M)) algoritms, where N and M are sizes of your sets of points.

Grzenio
  • 35,875
  • 47
  • 158
  • 240
1

Although I don't really have an answer to your question, I can suggest looking into the following topics. (I know very little about this, but encountered it previously on Stack Overflow.)

Hope this helps a bit.

mweerden
  • 13,619
  • 5
  • 32
  • 32
1

Off the top of my head, spatial sort followed by simulated annealing.

Grid the space & sort the sets into spatial cells.

Solve the O(NM) problem within each cell, then within cell neighborhoods, and so on, to get a trial matching.

Finally, run lots of cycles of simulated annealing, in which you randomly alter matches, so as to explore the nearby space.

This is heuristic, getting you a good answer though not necessarily the best, and it should be fairly efficient due to the initial grid sort.

Mike Dunlavey
  • 40,059
  • 14
  • 91
  • 135