Let's allow that there is a matrix of approachibilities of the NN size (N >= 500), a matrix of costs of NM and K of points with coordinates (x1, y1), (x2, y2)..., (xk, yk)
In a matrix of costs movement cost from a point of I (by xi, yi) in J point (xj, yj) is described. Thus cost is a tupple of two elements: tij - time for moving from i point to j and dij - distance between i and j points. If time is equal, it is necessary to take a point to which the distance is the smallest.
There are K of points (P1, P2, P3, P4). It is necessary to find such a point X which cost would be minimum.
The K is much smaller than N, M