I have a problem in a chemistry optimization program that is equivalent to the following question. I can't find a good algorithm for it:
Suppose I get N identical free to move squares with known initial longitudes, fixed width, and M identical "obstacles" with fixed positions.
Is there a algorithm to get a "minimum" total horizontal movements of those squares that can:
- retain the order of squares
- result in no overlap ("no touching") of squares and obstacle; and no overlap between squares.
The "minimum total movements" generally describes the position difference of before & after the movement. It can be the sum of deviations, or root-mean-square deviation, etc, whichever is easier.
It doesn't have to be the minimum, but a close one is desired for a good optimization.
I may have up to 50 squares and 25 obstacles, so brute-force is too slow.
I also find this post. But it doesn't work with the fixed obstacles, and doesn't necessarily kept the order of squares.