Increase train path distance penalty

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Post Reply
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2915
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Increase train path distance penalty

Post by Optera »

In well connected networks trains often exhibits the following behavior:
A train in front is taking a similar path.
This makes the train behind repath to take a pointless detour instead of slowing down for one or two blocks.

This post showcases that behavior nicely. viewtopic.php?f=18&t=51885&p=303037#p303037

Increasing the penalty for taking longer paths to the point where trains are allowed to wait a few seconds before flipping to a less optimal path would conserve fuel, make train paths more predictable and in turn make optimizing networks simpler.

vanatteveldt
Filter Inserter
Filter Inserter
Posts: 945
Joined: Wed Nov 25, 2015 11:44 am
Contact:

Re: Increase train path distance penalty

Post by vanatteveldt »

+1 to preventing trains do really stupid stuff.

I had a no-loops rail system that worked perfectly (as far as I could see). Then I added a loop around my walls to be used for passenger transport... and all of a sudden sometimes a train would take a 15 minute detour around the whole base, presumably because some junction was congested on his 'normal' route.

(my in-car navigation sometimes does this too, but I just ignore it ;-) )

Hannu
Filter Inserter
Filter Inserter
Posts: 850
Joined: Thu Apr 28, 2016 6:27 am
Contact:

Re: Increase train path distance penalty

Post by Hannu »

I agree. In my opinion rail network without loops is not a rail network but childish cargo tram network without any fun or entertainment.

I suggest that if alternative route is 20 units longer than blocked, the train would wait instead of choosing alternate route. Limit would be easy to program moddable if someone wants to current behavior or something else. At least I want that train can use a parallel sidetrack to bypass another waiting train but they should never make longer changes to their routes (practically like real trains work). There could also be a special combinator which is connected to rail piece and add effective length (in best case it would depend on train number) so that I can make exact route for every train.

vanatteveldt
Filter Inserter
Filter Inserter
Posts: 945
Joined: Wed Nov 25, 2015 11:44 am
Contact:

Re: Increase train path distance penalty

Post by vanatteveldt »

Maybe we should try to make a minimal example that shows the 'bug' / suboptimal pathing behaviour.

I've noticed that in this 4 track siding station with two intersections trains consistently prefer to loop back through the station if their exit to the right is (temporarily) blocked:
bad
However, in a smaller example with a similar setup I can't convince the train to repath through the station loop, even by temporarily occupying the bottom station so it initially paths to the top station, and then emptying the bottom station again hoping for it to repath...
good
I'm not really sure why the second (simpler) example doesn't work: IIUC, the train should repath after 5 seconds at the chain signal (or did that change?), and then it should see an empty route to the onoccupied bottom station. And if the penalty here (longer distance plus station) doesn't outweigh the cost of an occupied station in the simpler example, why would it do so in the complex example (which has 2 stations in between plus a longer loop)?

Can we make an example that consistently leads to suboptimal pathing (and hopefully less complex than the first example above)?

burner
Long Handed Inserter
Long Handed Inserter
Posts: 65
Joined: Tue Jan 31, 2017 3:29 pm
Contact:

Re: Increase train path distance penalty

Post by burner »

Optera wrote:In well connected networks trains often exhibits the following behavior:
A train in front is taking a similar path.
This makes the train behind repath to take a pointless detour instead of slowing down for one or two blocks.

This post showcases that behavior nicely. viewtopic.php?f=18&t=51885&p=303037#p303037

Increasing the penalty for taking longer paths to the point where trains are allowed to wait a few seconds before flipping to a less optimal path would conserve fuel, make train paths more predictable and in turn make optimizing networks simpler.

I totally agree. Current pathing is just nightmare. Trains can make same detour 5 times because they try avoid some slow going trains. They try avoid traffic jams but actually because that pathing currently works so badly you need more trains and then just more trains loitering around of network.
Another problem currently is that trains are quite CPU hog when they constantly repathing. Train path finder make huge spikes at cpu time use.

Probably what can help to cpu and for stupid behavior is that:
- allow re pathing only if train speed of front is less than 1/4 of current train.
- When re pathing new route can be only 20% longer and also some kind hard maximum how much longer it can be (100 blocks?). That avoid stupid detours at dense core for long distance trains.
- Station penalty to "infinite" so that train go through station only when it is really only available route.
- Add settings for each locomotive what allow choose "shortest route only" it will calculate its shortest path when it left from station (with infinite station penalty) and it will ignore other trains at this path finding. It will do new path calculation only if current target station is closed.
That allows use to put trains to mode where their behavior is really predictable.

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2915
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Increase train path distance penalty

Post by Optera »

burner wrote:Add settings for each locomotive what allow choose "shortest route only" it will calculate its shortest path when it left from station (with infinite station penalty) and it will ignore other trains at this path finding. It will do new path calculation only if current target station is closed.
That allows use to put trains to mode where their behavior is really predictable.
For stackers and multi platform stations to work properly Trains have to repath on chain signals and circuit controlled signals.
See this topic for details on forcing repath with circuit controlled signals.

burner
Long Handed Inserter
Long Handed Inserter
Posts: 65
Joined: Tue Jan 31, 2017 3:29 pm
Contact:

Re: Increase train path distance penalty

Post by burner »

I just track some trains in my map. It is hard because train path is not visible at map when I zoom out. But anyway I draw route by my self after train was arrived to its destination. That is quite good example how totally rubbish that current path finder is with its current parameters.
There is shortest path (what is some times take
ok path
ok path
path1.png (446.6 KiB) Viewed 2461 times
And there is worst of idiotic paths what it take when I follow it
Idiotic path
Idiotic path
path2.png (448.08 KiB) Viewed 2461 times
So just for avoiding slow train stopped to several seconds to lights it choose to drive around whole map. There is only one "roksuosat" station and it is always open so slow train ahead or red signal was only reason why it did that detour.

Post Reply

Return to “Ideas and Suggestions”