I have a system with a small number of particles (4-10) at fixed locations in space. I then have a single target location. I would like to assign weights to each particle so that the weighted average of the particle locations is as close as possible to the target. The weights need to be assigned consistently in cases where multiple solutions are possible. For example, if I have 3 particles at [1,0,0] and at [-1,0,0] and [0,0,0] and my target is [0,0,0], there are three possible solutions, which would be weights of 0.333,0.333,0.333 or 0,0,1 or 0.5,0.5,0. The second option seems most intuitive but really it does not matter which solution is chosen as long as it is chosen consistently. Also, I am mostly interested in cases where an exact solution is not possible, but the chosen weights minimize the error. What is the most efficient algorithm to compute these weights?
EDIT: to make this more clear I have created a visual of the 2d case. In this example, there are 5 fixed positions and 1 target position. Currently I am using a clunky naive approach of starting with the average of all 5 (weights = 0.2,0.2,0.2,0.2,0.2) and then iteratively adjusting these weights and seeing if it helps the solution, gradually "walking" towards the target. This can take hundreds of steps. I need to process this on millions or even billions of target positions, so I am looking for a more direct analytical approach to the solution.