With v^2 = vi ^2 * 2a (x-xo) you must be referring to:
<br />
(v_{f})^2 - (v_{i})^2 = 2a(x - x_{0})<br />
You have the initial velocity (158 km/h), the final velocity you need (27.2 km/h) and the distance between the two objects.
Assuming the locomotive and the train are moving in the same direction, your acceleration (or deceleration, if you prefer) looks like:
<br />
a = \frac{(v_{f})^2 - (v_{i})^2}{2(x - x_{0})}<br />
[/itex]<br />
<br />
Note: the negative sign of the acceleration means you are slowing down.<br />
<br />
Note 2: If the locomotive is coming at your train... then that's a whole new problem. i.e. you must define the meaning of "avoding collision" first. Then you must consider how much of "safe distance" you want to give to your train - if the locomotive is moving at 27.2 km/h, giving your train a second or two wouldn't make much sense, right? Thus, safe distance of 38m or less are out of the question (as the locomotive is moving in at 7.56 m/s) Say you give yourself a good 100 meters of safe distance. That means the distance your train covers + the distance the locomotive covers is less than or equal to (in maximum case) 599 meters, and t_{c} is same for both. Also, what is the final velocity you want to reach at? Ideally, you'd want to stop, but you need to know how much of a distance you have as a cushion, so you may not use the equation above. <br />
<br />
Considering the complexity this will bring, I have hard time convincing myself that the locomotive is actually coming at your train. But who knows? Maybe food for thought.