Train queuing and station preference

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
User avatar
Mango
Fast Inserter
Fast Inserter
Posts: 116
Joined: Fri Feb 22, 2013 6:27 pm
Contact:

Train queuing and station preference

Post by Mango »

I was creating a setup for processing ore and encountered an interesting behaviour.

Lets first discusss the unloading.
I have following setup:
Image

As you can see I have waiting stations which are also used to load the trains with iron ore for testing (All named Load) and 3 unload stations (All named Unload). Unload stations have disabled train limit.

All trains have a schedule to go to fully load at Load and then unload at Unload.

When I left this setup going i noticed at first trains prefer to go to empty stations, then to those with no train waiting and then they stay before the
chain signal. This is interesting, because that means the train at chan signal wants to go to the left most station (red 1).

Now the question is why did it choose the left one and not any other.
I had these ideas:
1) Every station has its internal ID and red 1 is first in some list
2) It is the closest one to the train
3) It is decided by position of the station in world, so maybe it depends on some ID of the chunk it is placed in

1) is not true, because when I delete the stations and rebuild them in any order it doesn't change the behaviour.

Now this is my loading setup at the end of the pocessing:
Image

Which means that 2) is also not true, because here it also prefers station on the left.

Only remaining idea is 3), but I somehow doubt that trains would decide by that. Yet it sems to corelate with the behaviour.

So does anybody know, how do trains choose to which station they'll go if there are multiple with the same name and all of them have the same number of trains going to them?

Maybe it can be somehow managed using circuits network?

Anyway what I would like to achieve is this:
Image
Hm.... so we have a mystery donor... intriguing.
User avatar
Nosferatu
Filter Inserter
Filter Inserter
Posts: 251
Joined: Fri Jan 20, 2017 4:48 pm
Contact:

Re: Train queuing and station preference

Post by Nosferatu »

https://wiki.factorio.com/Railway/Train_path_finding
"When the rail block contains a train currently waiting at a rail signal -> Add a penalty of 100 + 0.1 for every tick the train has already waited."

You can manipulate the decision by setting red lights by circuit network but I recommend: Don't go down this road
FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2768
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Train queuing and station preference

Post by FuryoftheStars »

I'm sure there are better and more elegant ways, but personally, I'd just create a stacker that could output to any of the stations.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
Tertius
Filter Inserter
Filter Inserter
Posts: 938
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Re: Train queuing and station preference

Post by Tertius »

As far as I researched this, I found out that to maximize train throughput at loading/unloading stations, you have to combine 3 different techniques.
1. as few crossings and junctions as possible in the accesses and exits area (you did this)
2. space for a queue of length 1 (1 train) directly in front of a station (you did this)
3. a larger stacker with one depot station in front of it on the lane that goes to a number of loading/unloading stations (this would be where you placed your testing loaders)

If you use this for a bunch of unloading stations, use circuits to set the train limit of an unloading station to 1 if the station chests are full and 2 if the station chests can receive at least 1 full train. This way one train is unloading if there is buffer space and 1 train is waiting for unload.
The other trains are waiting in the stacker in front of the depot station and start as soon as one of the unloading stations get an available slot. Give the depot station a proper limit so if you have other unloading station facilities like this, trains evenly distribute over both unloading station facilities. If you only have one, don't use a limit.
The tracks between the depot station and the queue in front of the unloading station is not for trains to wait, only for driving. This avoids congesting the lane with a train waiting for the nearest station, while a station more far away is starving (this is what you encountered).
Usually, Factorio directs trains into empty stacker lanes, however sometimes it also directs a train into a lane that's about to empty but only after a short waiting time, which congests the stacker entry. This is not fatal, since it only happens if the stacker is almost full, and if the stacker is almost full it has enough trains to feed the stations even with a congestion at the entry.

If it helps, this is my lab setup where I developed a minimum crossing mine-to-smelter and smelter-to-consumer setup with 1-8 (slow acceleration) trains for ore and 1-4 trains for steel.
Unbenannt.jpg
Unbenannt.jpg (1.82 MiB) Viewed 2892 times
Blueprint: https://factoriobin.com/post/vD1zq2Ai
Loewchen
Global Moderator
Global Moderator
Posts: 9248
Joined: Wed Jan 07, 2015 5:53 pm
Contact:

Re: Train queuing and station preference

Post by Loewchen »

Tertius wrote: Wed Nov 16, 2022 10:12 pm As far as I researched this, I found out that to maximize train throughput at loading/unloading stations, you have to combine 3 different techniques.
1. as few crossings and junctions as possible in the accesses and exits area (you did this)
2. space for a queue of length 1 (1 train) directly in front of a station (you did this)
3. a larger stacker with one depot station in front of it on the lane that goes to a number of loading/unloading stations (this would be where you placed your testing loaders)
4. signals in between the wagons inside the station so that the next train can start entering the station before the previous one has completely cleared it.
mmmPI
Smart Inserter
Smart Inserter
Posts: 3643
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Train queuing and station preference

Post by mmmPI »

Mango wrote: Wed Nov 16, 2022 3:42 pm So does anybody know, how do trains choose to which station they'll go if there are multiple with the same name and all of them have the same number of trains going to them?

Maybe it can be somehow managed using circuits network?

Anyway what I would like to achieve is this:
Image
As it was pointed the pathfinder penalty makes the "closer" station more desirable than the "further"

You can use dummy train station on the "closer" branch to change that, those a a very strong penalty associated to it, for example in the vertical area where the 2nd train is queued, place 2 train stop on the closer lane, and 1 on the middle one. If the limit is 3 on the unloading station that should do the trick, it would make the furthest lane "prefered" so the first one to get 3 trains but no more, then the middle one, then the close one.
User avatar
Mango
Fast Inserter
Fast Inserter
Posts: 116
Joined: Fri Feb 22, 2013 6:27 pm
Contact:

Re: Train queuing and station preference

Post by Mango »

Thanks for the explanation.

I added number of dummy stations increasing from far to close to the waiting places before unload stations and it does what I wanted.

You were right!
Hm.... so we have a mystery donor... intriguing.
Post Reply

Return to “Gameplay Help”