Page 1 of 1

trains getting stuck

Posted: Thu Nov 19, 2020 12:45 pm
by altaykilic
why does this happen? they keep getting stuck like this, the upper train could take the red path but it just doesn't want to

Re: trains getting stuck

Posted: Thu Nov 19, 2020 12:57 pm
by Zavian
https://wiki.factorio.com/Railway/Train_path_finding

In particular the following bit.
When the path includes a train stop that is not the destination -> Add a penalty of 2000.

Re: trains getting stuck

Posted: Thu Nov 19, 2020 1:41 pm
by MassiveDynamic
It’s best to place your train stations off of the travel lanes so that all trains that are not using the station can bypass it, and also trains that use the station will not block traffic.

Re: trains getting stuck

Posted: Thu Nov 19, 2020 3:45 pm
by valneq
Why do you have the train signals set to be two-directional in this roundabout?
If you make the roundabout one-directional, you won't have this issue – irrespective if there is a train stop on the roundabout.

In any case, keep the rails coming from the south and from the east two-directional.

Re: trains getting stuck

Posted: Sat Nov 21, 2020 4:55 am
by Zanthra
Can you post the save for that? The train should not be getting stuck there. They upper train should sit there for 30 seconds max before repathing.
Zavian wrote:
Thu Nov 19, 2020 12:57 pm
https://wiki.factorio.com/Railway/Train_path_finding

In particular the following bit.
When the path includes a train stop that is not the destination -> Add a penalty of 2000.
Yes, but there is this penalty.
When the rail block is occupied by a train -> Add a penalty of 2 * length of the block divided by block distance from the start, so the far away occupied paths don't matter much.
Given that there is no distance to the start of the occupied block, it's effectively infinite path cost, so it will be greater cost than pathing through the train depot. At the next 30 second repath event for waiting at chain signals, that train should be taking the top path.

Re: trains getting stuck

Posted: Sat Nov 21, 2020 5:19 am
by Loewchen
Zanthra wrote:
Sat Nov 21, 2020 4:55 am
Yes, but there is this penalty.
When the rail block is occupied by a train -> Add a penalty of 2 * length of the block divided by block distance from the start, so the far away occupied paths don't matter much.
Given that there is no distance to the start of the occupied block, it's effectively infinite path cost, so it will be greater cost than pathing through the train depot. At the next 30 second repath event for waiting at chain signals, that train should be taking the top path.
The divisor can never go below 1:

Code: Select all

// Neighbor segment penalties
      if (!neighborSegment->getBlock()->isFree(request.train))
        costFromStart += (2 * neighborSegment->getLength()) / (currentNode->blockDistanceFromStart + 1);

Re: trains getting stuck

Posted: Sat Nov 21, 2020 5:51 am
by Zanthra
Loewchen wrote:
Sat Nov 21, 2020 5:19 am
Zanthra wrote:
Sat Nov 21, 2020 4:55 am
Yes, but there is this penalty.
When the rail block is occupied by a train -> Add a penalty of 2 * length of the block divided by block distance from the start, so the far away occupied paths don't matter much.
Given that there is no distance to the start of the occupied block, it's effectively infinite path cost, so it will be greater cost than pathing through the train depot. At the next 30 second repath event for waiting at chain signals, that train should be taking the top path.
The divisor can never go below 1:

Code: Select all

// Neighbor segment penalties
      if (!neighborSegment->getBlock()->isFree(request.train))
        costFromStart += (2 * neighborSegment->getLength()) / (currentNode->blockDistanceFromStart + 1);
Ah so it is distance +1 which is very different in a situation like this.

PS: It should however eventually clear up due to this condition.

When the path includes a train currently waiting at a rail signal -> Add a penalty of 100 + 0.1 for every tick the train has already waited.
Unless I am misunderstanding that one too.

Re: trains getting stuck

Posted: Sat Nov 21, 2020 7:49 am
by Nosferatu
Yes. After 5 - 6 minutes it should repath.

Re: trains getting stuck

Posted: Sat Nov 21, 2020 8:10 am
by Zanthra
Nosferatu wrote:
Sat Nov 21, 2020 7:49 am
Yes. After 5 - 6 minutes it should repath.
Which, i'll admit, would look like they are getting stuck.

Since the southwest bound trains are very reluctant to use the trainstop as a bypass, you either need another bypass, or you need to signal the main line as you would if the trainstop rail was not there. Replace the standard signals on the bidirectional route with chain sginals to force any trains to reserve the entire route before they enter. The only standard signal in that screenshot that can stay is the top left one direction signal that leads to the train stop.

Re: trains getting stuck

Posted: Sat Nov 21, 2020 2:27 pm
by altaykilic
Zanthra wrote:
Sat Nov 21, 2020 4:55 am
Can you post the save for that? The train should not be getting stuck there. They upper train should sit there for 30 seconds max before repathing.
yes, it resolves itself after 30 seconds or so. I just didn't wait long enough to see that until you pointed it out.
I'll post the save when I figure out how to do it :P

Re: trains getting stuck

Posted: Sat Nov 21, 2020 2:30 pm
by altaykilic
here's the save file

Re: trains getting stuck

Posted: Sat Nov 21, 2020 9:21 pm
by Zanthra
altaykilic wrote:
Sat Nov 21, 2020 2:27 pm
Zanthra wrote:
Sat Nov 21, 2020 4:55 am
Can you post the save for that? The train should not be getting stuck there. They upper train should sit there for 30 seconds max before repathing.
yes, it resolves itself after 30 seconds or so. I just didn't wait long enough to see that until you pointed it out.
I'll post the save when I figure out how to do it :P
I set it up so that trains meet at that location, and it did take more than 5 minutes to clear on it's own, which could hurt throughput a fair bit.

In this image the red marks are regular signals on the main bidirectional trunk highlighted in green that you may want to replace with chain signals.
Chain Singal Protection.jpg
Chain Singal Protection.jpg (119.06 KiB) Viewed 2415 times