Hi!
Recently I've been working on a tool to calculate optimal route distance for max profit. Although I'm not finished with it I think it's good enough to show you: https://citymania.org/tools/profit. Not perfectly accurate yet (still have to reproduce some openttd bugs;) but it is pretty close so overall picture should be reasonable.
So let me know what you think of it, mb you'll have some ideas how to improve it. I was thinking of adding some train constructor instead of pre-defined trains and calculation for 4-station 2-way route (currently used 2-station one that isn't rly possible for, say, coal).