Simple Solution To Thundering Train Herd

Suggestions that have been added to the game.

Moderator: ickputzdirwech

User avatar
Mike5000
Fast Inserter
Fast Inserter
Posts: 133
Joined: Sun Mar 25, 2018 3:57 am
Contact:

Simple Solution To Thundering Train Herd

Post by Mike5000 »

TL;DR
This is a simple suggestion to solve the thundering train herd problem in Vanilla.

What ?
Moving automatic trains are already linked to a destination station. When you select debug show-train-stop-point the destination is shown in addition to the stop point. Stationary automatic trains wanting to move search for candidate destination stations among those stations which have a matching name and which are enabled.

This suggestion adds an optional limit to the number of trains which can simultaneously target a destination station. When the limit has been reached a train searching for a destination skips the station in the same way as if the station were disabled.
Image
Why ?
There are many interesting suggestions for enhancements to Factorio trains.

This suggestion does only one simple thing. It solves the annoying thundering herd problem.
Attachments
factorio-station-destination-limit.png
factorio-station-destination-limit.png (1.33 MiB) Viewed 8939 times
User avatar
Oktokolo
Filter Inserter
Filter Inserter
Posts: 884
Joined: Wed Jul 12, 2017 5:45 pm
Contact:

Re: Simple Solution To Thundering Train Herd

Post by Oktokolo »

+1
Chrisi
Burner Inserter
Burner Inserter
Posts: 14
Joined: Tue Feb 05, 2019 11:55 am
Contact:

Re: Simple Solution To Thundering Train Herd

Post by Chrisi »

+1
Sad_Brother
Fast Inserter
Fast Inserter
Posts: 209
Joined: Mon Jan 08, 2018 4:54 pm
Contact:

Re: Simple Solution To Thundering Train Herd

Post by Sad_Brother »

"(0 = no limit)" seems wrong.
Other than that agree fully.
Chrisi
Burner Inserter
Burner Inserter
Posts: 14
Joined: Tue Feb 05, 2019 11:55 am
Contact:

Re: Simple Solution To Thundering Train Herd

Post by Chrisi »

An additional useful feature would be if the number of allowed trains per station could be circuit controlled.
mieze :3
Burner Inserter
Burner Inserter
Posts: 13
Joined: Tue Nov 18, 2014 7:17 am
Contact:

Re: Simple Solution To Thundering Train Herd

Post by mieze :3 »

It could look like the 'Override stack size' in the ui of inserters.
User avatar
TheBloke
Fast Inserter
Fast Inserter
Posts: 123
Joined: Mon Dec 03, 2018 2:48 am
Contact:

Re: Simple Solution To Thundering Train Herd

Post by TheBloke »

Yes please, +1
Chrisi wrote: Tue Feb 05, 2019 4:05 pm An additional useful feature would be if the number of allowed trains per station could be circuit controlled.
And yes definitely this.
SLB
Inserter
Inserter
Posts: 36
Joined: Mon Sep 25, 2017 10:47 am
Contact:

Re: Simple Solution To Thundering Train Herd

Post by SLB »

This does not solve any problems

To maintain the same capacity, the number of trains required on a line is determined by the length of the line.

When the station position at the other end of the line is changed, the line becomes longer or shorter. It is necessary to adjust the upper limit of the number of stations. This is more troublesome and less intuitive.
Sad_Brother
Fast Inserter
Fast Inserter
Posts: 209
Joined: Mon Jan 08, 2018 4:54 pm
Contact:

Re: Simple Solution To Thundering Train Herd

Post by Sad_Brother »

SLB wrote: Mon Feb 11, 2019 7:31 am This does not solve any problems

To maintain the same capacity, the number of trains required on a line is determined by the length of the line.

When the station position at the other end of the line is changed, the line becomes longer or shorter. It is necessary to adjust the upper limit of the number of stations. This is more troublesome and less intuitive.
Did not understood. Is it you are confused or me?
Limit of trains, allowed to move to station, represent number of blocks where trains can wait. Smart engineer should tune it himself.
And station position changes on reconstruction only.
SLB
Inserter
Inserter
Posts: 36
Joined: Mon Sep 25, 2017 10:47 am
Contact:

Re: Simple Solution To Thundering Train Herd

Post by SLB »

Sad_Brother wrote: Mon Feb 11, 2019 8:01 am
SLB wrote: Mon Feb 11, 2019 7:31 am This does not solve any problems

To maintain the same capacity, the number of trains required on a line is determined by the length of the line.

When the station position at the other end of the line is changed, the line becomes longer or shorter. It is necessary to adjust the upper limit of the number of stations. This is more troublesome and less intuitive.
Did not understood. Is it you are confused or me?
Limit of trains, allowed to move to station, represent number of blocks where trains can wait. Smart engineer should tune it himself.
And station position changes on reconstruction only.
Sorry, English is not my native language.

I mean
For example, if you add another train station at the other end of the line or the position of the train station where you moved the other end, you need to change the number of trains pointing to this station.
Then you also need to expand the number of waiting areas
This does not make anything simple
mrvn
Smart Inserter
Smart Inserter
Posts: 5860
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Simple Solution To Thundering Train Herd

Post by mrvn »

I think you are not thinking of the same train design.

The setup is like this:

You have 20 iron ore mines spread all over the map. At each you have a station named "Iron Ore" that has a waiting bay for for an extra train. So each station can handle 2 trains without any blocking the normal line. You then have 20 trains with 2 stops: Iron Ore and Iron Smelter. Currently all 20 trains will go to the nearest station. 2 will fit and 18 will wait around on the normal line and block traffic. Some might reroute to other mines but they don't spread out well.

Making it more advanced each mine will disable the train stop when it doesn't have enough ore to fill a train. That way trains will reroute to mines that do have ore instead of all being stuck at the closest mine. This works somewhat better. But then you get the thundering herd problem:

Say all mines are fresh out of ore and disabled. All trains will park at the smelter awaiting some mine activating their stop. When one has mined enough ore to activate suddenly all 20 trains race to that stop. One will be filled and the stop is disabled again and 19 empty trains go back to the smelter as well as one full one.


The suggested solution of limiting the number of trains picking a stop as destination solves both the simple case as the advanced case with disabled stations. Each station would get at most 2 trains and the rest would stick around at the smelter till needed.
Sad_Brother
Fast Inserter
Fast Inserter
Posts: 209
Joined: Mon Jan 08, 2018 4:54 pm
Contact:

Re: Simple Solution To Thundering Train Herd

Post by Sad_Brother »

SLB wrote: Mon Feb 11, 2019 8:31 am Sorry, English is not my native language.

I mean
For example, if you add another train station at the other end of the line or the position of the train station where you moved the other end, you need to change the number of trains pointing to this station.
Then you also need to expand the number of waiting areas
This does not make anything simple
Not my as well ;)
Limit should be for specific station, not for "stations_named_the_same" .
If you change some railway far far away, no nearby trains should reroute. Number of wait places for trains on this station does not depend from other stations.
Also "the number of waiting areas" should not depend of routing, Here was suggested the way to tell routing system how many areas this station has.
mrvn wrote: Mon Feb 11, 2019 1:09 pm The setup is like this:
Exactly ;)
rldml
Fast Inserter
Fast Inserter
Posts: 180
Joined: Sun Mar 06, 2016 2:38 am
Contact:

Re: Simple Solution To Thundering Train Herd

Post by rldml »

this suggestion: +1
Sad_Brother wrote: Mon Feb 11, 2019 3:35 pm Limit should be for specific station, not for "stations_named_the_same" .
this modification of the suggestion: +1000(,3)

Greetings Ronny
Hive
Burner Inserter
Burner Inserter
Posts: 11
Joined: Thu Dec 14, 2017 7:48 pm
Contact:

Re: Simple Solution To Thundering Train Herd

Post by Hive »

this is a very nice idea ... the only problem i see is the train that got the first opportunity to rout to the next free station is by far not the one that is the closest.

lets say i have multiple smelting areas (named diffrent), mining sites (named the same) and waiting train stacks (after the smelting area).
to simplifie that, lets say there are 2 of each.
Smelting Area with waiting free Trains (A_waiting and B_waiting) and a mining Site (A_Mining, B_Mining)
A's are closer to each other than A to B.

Case 1
Lets say all Mining sites are closed due too less ore, now both will be opend with a tiny gap. The first Train active is from A_waiting and goes to B_Mining because it was open first. After A_Mining is open, the first active train ist yet again from A_waiting (because of the train id?) .... after both trains are full and going back to the smelting area and after that into the waiting position the mining sites may not be ready again... so it will happen agein that only trains from A_Waiting are getting handelt first. B_waiting got no opportunity to get some trains active.

Case 2
Because of activation order the trains from A_Waiting goes allways to B_Mining and B_Waiting is going to A_Mining. So they take the maximum Path instead of the minimum.


Both behaviors are not intuitive and getting worse than expanding to 3,4 or more setups. Your Suggestion is only usefull if there is a 1 to n ratio but not a m to n.
also the trains destination is recalculated after every stop to look for the shortest path. in your case the train is unable to define a new destination if all stations are served (but mybe not good), or it will change the station if one that is closer is opened while waiting on an intersection....

so either you have to kill the rerouting system for all station with limits or you also have strange behavior




edit:
so your sotultion of thundering herd will introduce new problems ...
why not just play with the path lenght... a station that is served got +1000 pathlenght or something. A Train that is heading to that station and is close to, is adding this value to the station. every other train in the network will be more likly to take a other rout or station if closer.
Sad_Brother
Fast Inserter
Fast Inserter
Posts: 209
Joined: Mon Jan 08, 2018 4:54 pm
Contact:

Re: Simple Solution To Thundering Train Herd

Post by Sad_Brother »

Hive wrote: Wed Feb 13, 2019 12:09 am this is a very nice idea ... the only problem i see is the train that got the first opportunity to rout to the next free station is by far not the one that is the closest.
...
This suggestion not for path optimisation. It is more like for traffic protection.

Without this suggestion in both cases all trains would rush to station, unable to serve more than one. So fuel spent, traffic locked, problems.
Hive wrote: Wed Feb 13, 2019 12:09 am also the trains destination is recalculated after every stop to look for the shortest path. in your case the train is unable to define a new destination if all stations are served (but mybe not good), or it will change the station if one that is closer is opened while waiting on an intersection....
If some train recalculate path, it is clearly release place in the "welcome list" of the station. But as the station probably still the closest, it would get it's place back if possible. So no problems.
Hive wrote: Wed Feb 13, 2019 12:09 am so either you have to kill the rerouting system for all station with limits or you also have strange behavior
You have enough tools to kill or tune your rerouting system. Here is another one ;)
Hive wrote: Wed Feb 13, 2019 12:09 am so your sotultion of thundering herd will introduce new problems ...
why not just play with the path lenght... a station that is served got +1000 pathlenght or something. A Train that is heading to that station and is close to, is adding this value to the station. every other train in the network will be more likly to take a other rout or station if closer.
So problem in your understanding this suggestion. It is not optimisation, it is protection. All your "play with the path length" will not help.
mrvn
Smart Inserter
Smart Inserter
Posts: 5860
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Simple Solution To Thundering Train Herd

Post by mrvn »

The +1000 penalty per routed train is a nice idea too to balance trains between multiple stations. But has basically zero effect on the Thundering Train Herd.

To reiterate the worst case: All trains are idle at the smelter. Then one mine outpost activates it's station. 100 trains race to the stations. The path to the mine outpost deadlocks or at least gets very congested because it gets overloaded with trains. Since it's the only active station it doesn't matter that it gets a +100000 penalty. It's the only station.

In a more normal situation I'm not sure the penalty is that helpful either. If you have a near and far station limited to two trains each but only 2 trains drive around and always pick the near station is that so wrong? It's faster and the throughput is sufficient and you allowed for 2 trains to pick that station. If you don't want 2 trains to go there then set the limit to 1. And if more throughput is needed a 3rd train will add it and stop at the far station. Introducing the penalty would reduce throughput because now one train would go to the far station needlessly.
GrumpyJoe
Filter Inserter
Filter Inserter
Posts: 491
Joined: Fri Apr 06, 2018 7:10 pm
Contact:

Re: Simple Solution To Thundering Train Herd

Post by GrumpyJoe »

i understand the problem, but i dont understand why anyone would set it up like this

take the example of 10 ore stations (with one waiting bay) x2 trains into one big smelter with (hopefully) a stacker that can hold 20 trains

I doubt anyone sets up 10 mining outpost at the same time and places 20 trains at once in that scenario.
So why dont you numerate each outpost and send 2 new trains to each, while having the same destination at the smelter? All that while building them? Is it so hard to click the station and rename it? You could even have the name in the blueprint and only add a number.
You´d end up with 10 different schedules, but whats the time needed to set up one, compared to building one outpost? You could even copy an "old" schedule (with a different outpost number), only having to change one stop.

I have seen circuit controlled waiting stations and saw the exact same problem there, with train numbers <1 and never bothered to make that work
Circling through trains and stations to see how many are sent is like adding LTN to vanilla.

Ive allways thought about renaming stations and creating schedules as the most tedious part of the game, even tho i love the train part in general, but even i can live with it.
Sad_Brother
Fast Inserter
Fast Inserter
Posts: 209
Joined: Mon Jan 08, 2018 4:54 pm
Contact:

Re: Simple Solution To Thundering Train Herd

Post by Sad_Brother »

GrumpyJoe wrote: Fri Feb 15, 2019 7:22 amtake the example of 10 ore stations (with one waiting bay) x2 trains into one big smelter with (hopefully) a stacker that can hold 20 trains

I doubt anyone sets up 10 mining outpost at the same time and places 20 trains at once in that scenario.
So why dont you numerate each outpost and send 2 new trains to each, while having the same destination at the smelter? All that while building them? Is it so hard to click the station and rename it? You could even have the name in the blueprint and only add a number.
You´d end up with 10 different schedules, but whats the time needed to set up one, compared to building one outpost? You could even copy an "old" schedule (with a different outpost number), only having to change one stop.
So you are made stacker for all the trains in your system. Then it should work without problems. But you will find soon your stacker is never full, so you can add more trains to it. Then in some moment your stacker become full and more trains blocked your railways.

From the other way you need to place two trains and give them destinations each time you place new ore station. And you need to remove them each time you remove ore station. If you prefer several trains with just "ore"<->"smelting" route, than all you need to add or remove ore stations is just add or remove them, nothing more. Trains would find nearest station, able to accept them.
Zavian
Smart Inserter
Smart Inserter
Posts: 1649
Joined: Thu Mar 02, 2017 2:57 am
Contact:

Re: Simple Solution To Thundering Train Herd

Post by Zavian »

Sad_Brother wrote: Fri Feb 15, 2019 10:58 am From the other way you need to place two trains and give them destinations each time you place new ore station. And you need to remove them each time you remove ore station. If you prefer several trains with just "ore"<->"smelting" route, than all you need to add or remove ore stations is just add or remove them, nothing more. Trains would find nearest station, able to accept them.
Then you are back to not only having what this thread is calling the thundering herd problem, but also the problem that if no ore mining station is enabled (eg no station has enough ore to load a train), your empty ore train won't leave the unloading station, which is also undesirable. (And I don't see a way to solve that without adding more stations in a stacker like arrangement, and adding circuits for control).

GrumpyJoe's solution works. It works now, and doesn't require game changes. (Ok, yes, you want to use a bit of discipline and not overflow the smelter's stacker, but even with your proposed solution, there is nothing actually preventing a player from adding extra trains, and overflowing the smelter's stacker, so this potential problem exists in both designs).
Sad_Brother
Fast Inserter
Fast Inserter
Posts: 209
Joined: Mon Jan 08, 2018 4:54 pm
Contact:

Re: Simple Solution To Thundering Train Herd

Post by Sad_Brother »

Zavian wrote: Fri Feb 15, 2019 11:36 am
Sad_Brother wrote: Fri Feb 15, 2019 10:58 am From the other way you need to place two trains and give them destinations each time you place new ore station. And you need to remove them each time you remove ore station. If you prefer several trains with just "ore"<->"smelting" route, than all you need to add or remove ore stations is just add or remove them, nothing more. Trains would find nearest station, able to accept them.
Then you are back to not only having what this thread is calling the thundering herd problem, but also the problem that if no ore mining station is enabled (eg no station has enough ore to load a train), your empty ore train won't leave the unloading station, which is also undesirable. (And I don't see a way to solve that without adding more stations in a stacker like arrangement, and adding circuits for control).
He did not mention enabling/disabling. So I suppose empty trains should wait at ore stations.
Zavian wrote: Fri Feb 15, 2019 11:36 amGrumpyJoe's solution works. It works now, and doesn't require game changes. (Ok, yes, you want to use a bit of discipline and not overflow the smelter's stacker, but even with your proposed solution, there is nothing actually preventing a player from adding extra trains, and overflowing the smelter's stacker, so this potential problem exists in both designs).
It is not about railway is unusable now. It is way to improve efficiency. His stacker for all trains prevents overflow on smelting stations. But he did not attempt second smelting station. Would he add another 20 trains? Would he halve trains equally? Both ways can be bad.

He prefer big buffer to prevent overflow. I prefer logical preventing/redirecting. It is not about forbidding to play as now.
Post Reply

Return to “Implemented Suggestions”