Sometime ago I posted my solution to what I think you are asking. Here is the entire post.
I had this problem and found a solution that worked:
At start of session, all was normal. Switch Z is the problem, being locked by a train (Train A) far away, making Train B wait.
Then Train A passed a jct X, but A was still a long way from switch Z.
Then Train B passed a jct Y, but B was less than .25 km away from switch Z.
Yet Train B got stuck just before switch Z and had to wait for Train A to pass thru switch Z. No way to run a railroad.
Solution: Somewhere along the stretch of track Train A would travel between X and Z, I added a siding. This makes switch Q. No plans to use the siding.
So now Train A is between X and Q instead of X and Z, which means Z will now be locked for use by Train B and all is well.
So in short, the AI must consider a section of track between switches as the controlling factor regardless of length.