Page 1 of 1

Train stops with limit change assigned numbers of trains

Posted: Sun Jan 17, 2021 2:39 am
by Guenni7
I have all my train stops with a fixed number of train limit. Lately I noticed that the stations most far don't get served well, just occasionally a train gets there.
So I had a look at the assigned trains to that stop, and it was changing all the time like 1/6 to 2/6 to 1/6 to 0/6...
There were even trains in the stacker of the station that left over a bypass to go to another station.
Why do the trains re-path and go to another station?

Re: Train stops with limit change assigned numbers of trains

Posted: Sun Jan 17, 2021 3:39 am
by NotRexButCaesar
A picture would probably be helpful

Re: Train stops with limit change assigned numbers of trains

Posted: Sun Jan 17, 2021 3:57 pm
by mmmPI
My guess is that some closer train station are freed before the train that was routing to the further one had reached it.
Then this train using regular repath conditions switches its target destination to the newly found closest station.

Reading incoming train to the far station would then change accordingly,it being reached only when others station are slow to service trains.

Re: Train stops with limit change assigned numbers of trains

Posted: Sun Jan 17, 2021 10:21 pm
by Guenni7
AmericanPatriot wrote:
Sun Jan 17, 2021 3:39 am
A picture would probably be helpful
It's a simple station without wiring, what information would give a picture?

mmmPI wrote:
Sun Jan 17, 2021 3:57 pm
My guess is that some closer train station are freed before the train that was routing to the further one had reached it.
Then this train using regular repath conditions switches its target destination to the newly found closest station.

Reading incoming train to the far station would then change accordingly,it being reached only when others station are slow to service trains.
I always thought re-pathing means searching a new path to destination, not switching the destination (if not necessary)...

Re: Train stops with limit change assigned numbers of trains

Posted: Mon Jan 18, 2021 11:27 am
by mmmPI
Guenni7 wrote:
Sun Jan 17, 2021 10:21 pm
I always thought re-pathing means searching a new path to destination, not switching the destination (if not necessary)...

There are 2 differents things, what you describe would be "path-revalidation" in this https://wiki.factorio.com/Railway/Train_path_finding

While what happens i think is triggering this rule : "A train stop that is part of the train's schedule gets enabled, renamed or created." or this one "The train limit of a train stop that is part of the train's schedule becomes not full." This causes repath, and not just revalidation.

It's unfortunate if it causes a train to also change destination when it was located in a stacker just next to the stop you'd expect it to go and instead realize another trains stop now has available room on the other side of the map.

You could maybe mitigate the effect by having more train than strictly necessary. It would reduce the likelyhood of having the train with this behavior being the same as the one that was on route to the far and less serviced train stop.

Re: Train stops with limit change assigned numbers of trains

Posted: Mon Jan 18, 2021 6:41 pm
by NotRexButCaesar
Guenni7 wrote:
Sun Jan 17, 2021 10:21 pm
AmericanPatriot wrote:
Sun Jan 17, 2021 3:39 am
A picture would probably be helpful
It's a simple station without wiring, what information would give a picture?
There might be something adding a penalty to that station.

Re: Train stops with limit change assigned numbers of trains

Posted: Mon Jan 18, 2021 8:26 pm
by Guenni7
mmmPI wrote:
Mon Jan 18, 2021 11:27 am
While what happens i think is triggering this rule : "A train stop that is part of the train's schedule gets enabled, renamed or created." or this one "The train limit of a train stop that is part of the train's schedule becomes not full." This causes repath, and not just revalidation.
That souds like the explanation...
All my stations have limit on loading side and the unloading side is activated/deactivated by need ad I use N:N trains routes, so all my 100 trains re-path all the time, which explains why I have 2K update time for just 100 trains... I'm wondering how people can run 300+ trains and don't get into UPS problems?
AmericanPatriot wrote:
Mon Jan 18, 2021 6:41 pm
There might be something adding a penalty to that station.
There was indeed a penalty because I had set up the incoming rail signal to be red til station has a full load for a train.
I removed that and got less re-pathing, but it still happens that trains in the stacker leave to another station.
Untitled.png
Untitled.png (1.4 MiB) Viewed 5194 times

Re: Train stops with limit change assigned numbers of trains

Posted: Tue Jan 19, 2021 8:40 am
by Zavian
Guenni7 wrote:
Mon Jan 18, 2021 8:26 pm
There was indeed a penalty because I had set up the incoming rail signal to be red til station has a full load for a train.
I removed that and got less re-pathing, but it still happens that trains in the stacker leave to another station.
Why do you have the bypass? Having a bypass means that trains waiting in the stacker might choose to go to other stations.
Alternatively put another station of the bypass, to add a penalty that will discourage trains from choosing to go another station.

Re: Train stops with limit change assigned numbers of trains

Posted: Tue Jan 19, 2021 8:48 am
by 5thHorseman
I've found that having exactly as many trains as you do slots keeps all stations full and all trains waiting as expected.

So if you have 4 mining outpost stations, each with 2 trains, and 1 big smelting area with 3 stations each with 2 trains, that's 4*2+3*2=8+6=14 trains.

Most of them will be idle and you'll get "no free station" alarms when a train wants to leave and there's nowhere to go, but nothing actually gets jammed up and all stations get served equally.

You may be able to do an N-1 thing for that (in the example have 13 trains for your 14 slots) to avoid the warnings, but I'm not sure if that would then make sure all stations were served.

I'm also not sure how it'd work on trains that have routes that are more than the simple back-and-forth, but since they enacted train limits I've found no need to have trains going to multiple stations... yet.

Re: Train stops with limit change assigned numbers of trains

Posted: Tue Jan 19, 2021 8:50 pm
by Guenni7
Zavian wrote:
Tue Jan 19, 2021 8:40 am
Why do you have the bypass? Having a bypass means that trains waiting in the stacker might choose to go to other stations.
Alternatively put another station of the bypass, to add a penalty that will discourage trains from choosing to go another station.
The bypass is a relic from building various forms of different stations, now it's just good to leave the station quick when you work there.
Adding a train stop on the bypass is a good idea, will try that!
5thHorseman wrote:
Tue Jan 19, 2021 8:48 am
I've found that having exactly as many trains as you do slots keeps all stations full and all trains waiting as expected.
I think this stops working when the ways between the stations get longer and longer. Then you have more trains "en route" for a longer time and not all stations can be served with the amount of trains. You can then put more trains into the system, but that can cause several other problems though.

Re: Train stops with limit change assigned numbers of trains

Posted: Thu Jan 21, 2021 1:37 am
by Zanthra
You might consider adding holding stations into the schedule between the loading and unloading, then reduce the trains limit on the loading stations.

Trains departing the unloading will find the closest unloaded holding station and wait there for the next available loading station. This means you can have fewer train limit slots for the loading stations than you do total trains assigned to them, since the trains can still leave the unloading stations and wait at the holding stations even if all loading station slots are full.

There is a small efficiency loss due to having to travel and stop briefly at a holding station, but always having the trains waiting to fill the slots as they become available means even the furthest stations will be served well, and provide more consistent results.

Re: Train stops with limit change assigned numbers of trains

Posted: Thu Jan 21, 2021 5:48 am
by Guenni7
Zanthra wrote:
Thu Jan 21, 2021 1:37 am
You might consider adding holding stations into the schedule between the loading and unloading, then reduce the trains limit on the loading stations.

Trains departing the unloading will find the closest unloaded holding station and wait there for the next available loading station. This means you can have fewer train limit slots for the loading stations than you do total trains assigned to them, since the trains can still leave the unloading stations and wait at the holding stations even if all loading station slots are full.

There is a small efficiency loss due to having to travel and stop briefly at a holding station, but always having the trains waiting to fill the slots as they become available means even the furthest stations will be served well, and provide more consistent results.
I tried this on the unloading side once, and the results were... mhm, really bad. Instead of the planed increase of throughput I got exactly the opposite. So I don't think I will try this on the loading side either.

Adding a train-station to the bypass as Zavian suggested solved the problem mainly, just once in a while trains leave the stacker to another station.
Thanks Zavian!

Re: Train stops with limit change assigned numbers of trains

Posted: Thu Jan 21, 2021 6:40 am
by Zanthra
Guenni7 wrote:
Thu Jan 21, 2021 5:48 am
I tried this on the unloading side once, and the results were... mhm, really bad. Instead of the planed increase of throughput I got exactly the opposite. So I don't think I will try this on the loading side either.
If the throughput was limited by contention passing through the holding stations, then you might need more holding stations. For ideal throughput you would have one holding station per train on the route, each with a train limit of 1, but you could probably get away with one holding station for every two or three trains on the route. Distribute them around the network to keep the lanes in and out of the holding stations from being a bottleneck.

On the other hand if the throughput problems was the trains travelling from the holding stations to the loading stations, then you need a bigger stacker and a higher trains limit for the loading stations that are having throughput problems so more trains can be enroute at the same time, which may require more trains overall to keep all the slots filled.