I'm stuck on a problem and I would need help please.
Let's imagine a set of points of the plane big enough $X \in \mathbb{R}^{n \times 2}$ (with $n=10 000$ for example) and another smaller set $Y \in \mathbb{R}^{p \times 2}$ (with $p=100$ smaller). We would like to find the $p$ points of $X$ that are closest to the points of $Y$. So we try to minimize $\sum_{i \leq p} || (\Pi X)_i - Y_i ||_2^2$ where $\Pi \in \mathbb{R}^{p \times n}$ is a selection matrix. Let us imagine that $n=5$ , $p=3$ and that the solution is given by the 1st, 4th and 5th point of $X$. For example: $X= \begin{pmatrix} 0.5 & 0.4 \\ 1 & 2 \\ 1 & 2 \\ -1 & 4 \\ 3 & 0.7 \\ \end{pmatrix}$ and $Y= \begin{pmatrix} 0.49 & 0.39 \\ -1.1 & 3.9 \\ 2.9 & 0.71\\ \end{pmatrix}$
then $\Pi = \begin{pmatrix} 1 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \end{pmatrix}$
ps : The notation $Y_i \in \mathbb{R}^{2}$ designates the i-th point of $Y
You can solve this as a linear assignment problem in a complete bipartite graph with $n+p$ nodes and $n \times p$ edges. The cost of edge $(i,j)$ is the squared Euclidean distance between the two points.