I have a 3D space where N spheres of identical size, identified by the location of their centers, are continually inserted. When a new sphere is inserted, I have the ability to efficiently query the locations of any other spheres that may intersect with this sphere.
I can also compute the vector two intersecting spheres will need to move along in order to resolve their intersection in the shortest distance. However, I can't simply move the new sphere over along this vector and call it a day, since this may cause new intersections with other spheres that will then need to be resolved.
My question is, upon inserting a new sphere into this space and finding other spheres it intersects with, how can I efficiently compute the change in position of each of the N spheres in the space that will resolve all intersections in the space? An optimal solution should minimize the total distance traveled by the centers, but near-optimal solutions are fine, and in fact preferred if they are significantly more efficient.
The solution must guarantee that no intersections remain in the space. For my purposes, the 3D space is infinite, and two spheres aren't considered intersecting if they are tangent to each other. Any sphere in the space can be moved.
Example scenario: There are four identical spheres aligned horizontally. The middle two intersect, and the minimum distance required to resolve their intersection is 1. If one of the intersecting spheres moves a distance greater than 0.75 away from the other, it will intersect with one of the outer spheres. An optimal solution here would be to move each of the intersecting spheres away from the other by a distance of 0.5, which results in the least overall distance traveled, since no other intersections would have to be resolved subsequently. 