Let's say we have two sets $X = \{x_1, \ldots, x_n\} \subset \mathbb R^d$, $Y =\{y_1,\ldots, y_n\} \subset \mathbb R^d$, how can we find a permutation $\pi$ such that
$$D = \sum_{i=1}^n d(x_i, y_{\pi(i)})$$
is minimal? (Here $d$ is some distance function, for simplicity we can assume it is the Euclidean distance, or maybe the squared euclidean distance.)
As far as I remember this is a well studied problem, but can anyone tell me what it is called?