Is there a way to stop trains from choosing new stations mid-journey?

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
Frankvd
Burner Inserter
Burner Inserter
Posts: 15
Joined: Thu Jan 25, 2024 1:27 pm
Contact:

Is there a way to stop trains from choosing new stations mid-journey?

Post by Frankvd »

I'm building a big base where I use small twoheaded trains to transport goods, thinking incorrectly it would make the base more flexible to just make multiple small factories for individual goods and give stations names like "GreenCircuitsLoad" and "GreenCircuitsUnload". I assumed the trains would neatly transport things from the various loading stations to the various unloading stations.

What actually happens is that all trains will insist on using just the two stations closest together, but even worse, if one is assigned to a station a bit further away, the train often will decide halfway to switch to another station when it becomes available and the far station will not get any goods.

This completely ruins the efficiency of the base, of course, because trains constantly depart for the further away stations only to suddenly turn around on a roundabout and travel back the entire way it came, because another station became available next to its loading station and it was just a bit closer. And then a new train will be assigned to the far station, but the same thing will happen. If often see trains move in all kinds of crazy directions because it keeps choosing new stations, instead of sticking by the one it originally chose and leaving the newly available station for the next train that becomes available. This results in much longer ride times than necessary and a lot of extra congestion.

Is there a way to just prevents trains from ever choosing a new station when it's already on it's way to one? Is there maybe a mod that does this?

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2768
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Is there a way to stop trains from choosing new stations mid-journey?

Post by FuryoftheStars »

Use train limits on stations to get your trains to naturally spread out across the stations more. Either set them statically, or dynamically with circuits. And if you're doing any station disabling... don't.

Note that for 2.0, the devs are adding station priority and will be changing station disabling behavior (see latest FFF, 395).
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

Frankvd
Burner Inserter
Burner Inserter
Posts: 15
Joined: Thu Jan 25, 2024 1:27 pm
Contact:

Re: Is there a way to stop trains from choosing new stations mid-journey?

Post by Frankvd »

FuryoftheStars wrote:
Thu Feb 01, 2024 1:14 pm
Use train limits on stations to get your trains to naturally spread out across the stations more. Either set them statically, or dynamically with circuits. And if you're doing any station disabling... don't.

Note that for 2.0, the devs are adding station priority and will be changing station disabling behavior (see latest FFF, 395).
I already do that, no station will ever have more than 1 train assigned to it, but trains still cluster to a few stations because as Train 1 leaves an unloading station for example, Train 2 will get assigned to that station after a while and leave its loading station. But Train 1 will then immediately reroute to the loading station that now became accessible again, often following a horribly inefficient route because it was going somewhere else originally.

The end result is that although the trains could be going from 2 loading stations to 2 unloading stations, but they're going from 1 to 1, and waste a lot of time and create a lot of congestion because the routes they follow are so bad. None of this would be an issue if they just stuck by the stations they originally selected, so that's why I was hoping maybe some mod existed to fix this.

I'm looking forward very much to station priority TBH, that would solve this issue as well.

Loewchen
Global Moderator
Global Moderator
Posts: 8895
Joined: Wed Jan 07, 2015 5:53 pm
Contact:

Re: Is there a way to stop trains from choosing new stations mid-journey?

Post by Loewchen »

If a loading station has a full train load or more it's limit should be 1, otherwise 0.
If an unloading station can take a full train load or more it's limit should be 1 otherwise 0.
If the the loading stations run full and unloading empty you need more trains, if both run low you need more resources.
No 2.0 features are needed to make this work.

User avatar
Nosferatu
Fast Inserter
Fast Inserter
Posts: 247
Joined: Fri Jan 20, 2017 4:48 pm
Contact:

Re: Is there a way to stop trains from choosing new stations mid-journey?

Post by Nosferatu »

https://wiki.factorio.com/Railway/Train ... _operation

Basically. Whenever a train hits traffic it tries to repath.

Suggestions:
Try to eliminate turnarounds and roundabouts in your train system.
They give your trains many opertunites for strange behaviour and slow down path finding a lot.
Maybe you think that trains then will path through stations if you do that - but there is a high penalty in the path finder for that so it shouldn't happen often.

It's there by change something on the way to station 2 that makes them avoid it? Stations on the main line, Traffic jams, etc?

Other idea: You could oversaturate your station.
Make a third train.
Example:
2 Loading station set to 1 train max.
Train 1 finishes loading
Train 2 is enroute to station 2
Train 3 is waiting for destination in unloading station (or in a dedicated parking station)
--> when train 1 leaves train 3 reserves the spot. Train 2 gets no chance to repath

Frankvd
Burner Inserter
Burner Inserter
Posts: 15
Joined: Thu Jan 25, 2024 1:27 pm
Contact:

Re: Is there a way to stop trains from choosing new stations mid-journey?

Post by Frankvd »

Loewchen wrote:
Thu Feb 01, 2024 4:16 pm
If a loading station has a full train load or more it's limit should be 1, otherwise 0.
If an unloading station can take a full train load or more it's limit should be 1 otherwise 0.
If the the loading stations run full and unloading empty you need more trains, if both run low you need more resources.
No 2.0 features are needed to make this work.
I only disable unloading stations, so that trains have always somewhere to go. The trouble with disabling loading stations too is that you can get the situation that a train can't go anywhere after unloading and gets stuck blocking an unloading station.
And because the unloading station is blocked, other trains cannot go there and will keep waiting at the loading stations, meaning new loading stations won't get available either, so the unloading station will remain blocked until the loading station is unblocked again.

Adding more trains is something I'm doing now, but this creates a lot of extra traffic so I can't just do that indefinitely.

Frankvd
Burner Inserter
Burner Inserter
Posts: 15
Joined: Thu Jan 25, 2024 1:27 pm
Contact:

Re: Is there a way to stop trains from choosing new stations mid-journey?

Post by Frankvd »

Nosferatu wrote:
Thu Feb 01, 2024 4:45 pm
https://wiki.factorio.com/Railway/Train ... _operation

Basically. Whenever a train hits traffic it tries to repath.

Suggestions:
Try to eliminate turnarounds and roundabouts in your train system.
They give your trains many opertunites for strange behaviour and slow down path finding a lot.
Maybe you think that trains then will path through stations if you do that - but there is a high penalty in the path finder for that so it shouldn't happen often.

It's there by change something on the way to station 2 that makes them avoid it? Stations on the main line, Traffic jams, etc?

Other idea: You could oversaturate your station.
Make a third train.
Example:
2 Loading station set to 1 train max.
Train 1 finishes loading
Train 2 is enroute to station 2
Train 3 is waiting for destination in unloading station (or in a dedicated parking station)
--> when train 1 leaves train 3 reserves the spot. Train 2 gets no chance to repath
Thank you for the suggestions.

I did not know about the roundabout issue. I'm indeed using a lot of them for crossings, I will try if I can replace them with some alternative.

My rail network is quite busy and although I'm trying to reduce traffic as much as I can, there probably will always be a few pauses en route to far away stations. Do I understand you correctly that that is the only time they're supposed to repath, or do they also do it at full speed?

Oversaturating stations is what I'm mainly trying now, I've entered a lot of extra trains into the network and it does help a bit. The flipside of this is that this greatly increases the number of trains I'm using and causes a lot of traffic. That's why I was looking for some way to prevent the repathing, because that's what causes trains to follow inefficient routes and makes it necessary to have more of them riding around in the first place.

User avatar
Nosferatu
Fast Inserter
Fast Inserter
Posts: 247
Joined: Fri Jan 20, 2017 4:48 pm
Contact:

Re: Is there a way to stop trains from choosing new stations mid-journey?

Post by Nosferatu »

Wiki wrote:Repaths that happen as part of normal train operation
A train fails a revalidation.
The train stop a train is heading to is renamed or destroyed.
The train is preparing to stop at a signal (chain or regular) that changes so that the train can now continue.
The train is braking for a signal (chain or regular) it cant reserve.
The train enters a new rail block and can't reserve the next needed signal (chain or regular).
The train has waited at a chain signal for a multiple of 5 seconds and there are multiple train stops with the same name as the destination.
The train has waited at a chain signal for a multiple of 30 seconds and there is only a single train stop with the same name as the destination.
The train wants to depart from a signal (chain or regular) that it stopped at.
The train wants to depart from a train stop.
The train is pathing to a train stop that gets disabled.
The bold ones are the most critical I think. As soon as he gets blocked a little bit he starts to search for alternate routes.
The last one in the list is why everybody says disabling stations is bad ;)
The flipside of this is that this greatly increases the number of trains I'm using and causes a lot of traffic.
The traffic should die down again. Once you reached over-saturation you have more trains but lots of them will wait in stations.

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2768
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Is there a way to stop trains from choosing new stations mid-journey?

Post by FuryoftheStars »

Frankvd wrote:
Thu Feb 01, 2024 6:17 pm
Loewchen wrote:
Thu Feb 01, 2024 4:16 pm
If a loading station has a full train load or more it's limit should be 1, otherwise 0.
If an unloading station can take a full train load or more it's limit should be 1 otherwise 0.
If the the loading stations run full and unloading empty you need more trains, if both run low you need more resources.
No 2.0 features are needed to make this work.
I only disable [...]
Just for clarity sake, there is an actual disable feature of train stops (currently) that is different from setting train limits to 0. Setting the limit to 0 keeps the stop open for any trains already pathed to it, but prevents new ones from pathing to it, whereas disabling makes even current trains pathing to it repath elsewhere.

So... which "disable" do you mean here? Disable disable, or train limit 0 "disable"? :)
Frankvd wrote:
Thu Feb 01, 2024 6:17 pm
the situation that a train can't go anywhere after unloading and gets stuck blocking an unloading station.
I recommend creating an intermediary train depot of sorts for this. You can even make multiple on different sides of your base so that it kind of forces some routing with the trains. Alternatively, stacker bays at your loading and/or unloading that use a train station for navigation.

And it looks like Nosferatu answered the other question I was going to comment on re: situations that cause repathing.
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

Frankvd
Burner Inserter
Burner Inserter
Posts: 15
Joined: Thu Jan 25, 2024 1:27 pm
Contact:

Re: Is there a way to stop trains from choosing new stations mid-journey?

Post by Frankvd »

Nosferatu wrote:
Thu Feb 01, 2024 8:09 pm

The bold ones are the most critical I think. As soon as he gets blocked a little bit he starts to search for alternate routes.
The last one in the list is why everybody says disabling stations is bad ;)
I also think it happens mostly when those two happen, because trains need to wait every once in a while. The repathing itself is not a problem if it's just finding a more efficient path to the same station, but when it starts choosing new stations it is an issue.
As for disabling stations, I only disable them when they have a certain amount of goods in storage, and they can only reach that threshold when a train is unloading. And because they all have a train limit of 1, whenever a train is unloading, it means there is no other train heading for the station. So it never happens that a station gets disabled while a train is heading for it.
The traffic should die down again. Once you reached over-saturation you have more trains but lots of them will wait in stations.
Unfortunately, due to this pathing behavior it will not, because when a train departs for a station 5 minutes away, travels 2 minutes, then turns around for a different station next to its starting point, traveling another 2 minutes back, it will have traveled for 4 minutes, even though it could have reached the same endpoint in a matter of seconds, as the endpoint is next to its starting station. So a lot of trains are following very inefficient routes, meaning there is a lot more traffic than necessary.
This wouldn't be an issue if it just chose a different path to the same station, as the train in that case would be heading for the same endpoint through the most efficient route, but if the endpoint completely changes halfway, everything a train has traveled up until that point is essentially wasted time and effort.

Frankvd
Burner Inserter
Burner Inserter
Posts: 15
Joined: Thu Jan 25, 2024 1:27 pm
Contact:

Re: Is there a way to stop trains from choosing new stations mid-journey?

Post by Frankvd »

FuryoftheStars wrote:
Thu Feb 01, 2024 8:21 pm

Just for clarity sake, there is an actual disable feature of train stops (currently) that is different from setting train limits to 0. Setting the limit to 0 keeps the stop open for any trains already pathed to it, but prevents new ones from pathing to it, whereas disabling makes even current trains pathing to it repath elsewhere.

So... which "disable" do you mean here? Disable disable, or train limit 0 "disable"? :)
The "hard" disable, but they only get disabled once there are enough goods in storage, which in turn can only happen when a train is unloading, and because the train limit is 1, there is never another train heading for the station when there is already one unloading and this threshold is reached. So this causes no issues.
I recommend creating an intermediary train depot of sorts for this. You can even make multiple on different sides of your base so that it kind of forces some routing with the trains. Alternatively, stacker bays at your loading and/or unloading that use a train station for navigation.

And it looks like Nosferatu answered the other question I was going to comment on re: situations that cause repathing.
This could be an option, it would require me to rename stations and have trains travel from loading->depot, and depot-> unloading. Maybe I can fit this in for some goods. What is a stacker bay?

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2768
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Is there a way to stop trains from choosing new stations mid-journey?

Post by FuryoftheStars »

Frankvd wrote:
Wed Feb 07, 2024 8:25 pm
What is a stacker bay?
Parallel rail lines prior to a stop (or set of stops) where trains wait. Similar concept as a depot, only meant to service a specific set of stations.

Kind of like this (and you can do diagonal, too):
stacker example.jpeg
stacker example.jpeg (493.56 KiB) Viewed 1178 times

Image taken from here: https://www.factorio.school/view/-LRiXaIKDuAdgArz5tuf
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

Frankvd
Burner Inserter
Burner Inserter
Posts: 15
Joined: Thu Jan 25, 2024 1:27 pm
Contact:

Re: Is there a way to stop trains from choosing new stations mid-journey?

Post by Frankvd »

FuryoftheStars wrote:
Wed Feb 07, 2024 8:45 pm
Frankvd wrote:
Wed Feb 07, 2024 8:25 pm
What is a stacker bay?
Parallel rail lines prior to a stop (or set of stops) where trains wait. Similar concept as a depot, only meant to service a specific set of stations.

Kind of like this (and you can do diagonal, too):
stacker example.jpeg


Image taken from here: https://www.factorio.school/view/-LRiXaIKDuAdgArz5tuf
Ah OK thank you, that makes it clear. I use similar models in my original base, but in the train base I build now the stations are small and close together, so unfortunately there is no space to build waiting areas like this. I use double-headed trains and stations where they go in with one locomotive and exit with the other, like this:
20240207222554_1.jpg
20240207222554_1.jpg (859.9 KiB) Viewed 1161 times

Post Reply

Return to “Gameplay Help”