You may look at this Boids page. It extends Craig Reynold's original Boid algorithm. Although it targets flock simulation, it shows a rule based system where one aspect is to avoid collision like you've described, besides avoiding obstacles, predator / prey behavior, and others.
However, w.r.t. the will to live also of soldiers ;) I want to hint that it is unlikely for a soldier in the 3rd row to try to push through the own lines towards the target. Perhaps you may try to drive the closest N soldiers purposeful towards the targets, while soldiers farther away just move up when a place gets available.