Something Wrong with Train Path Finding

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
DeckerCHAN@gmail.com
Burner Inserter
Burner Inserter
Posts: 8
Joined: Wed Apr 18, 2018 12:31 pm
Contact:

Something Wrong with Train Path Finding

Post by DeckerCHAN@gmail.com »

I have built a train network to distribute goods between each station. Rails are in grid layout which similar like manhattan block. However, when trains finding path between stations, it simply avoid go straight when where is intersection, even doing circling around blocks.

I have attached two images. Second one showing the design on intersection. The first one demonstrating a path finding, the red and green lines are path it actual found, the blue is obviously the SHORTEST path.
Attachments
TIM截图20180418223540.png
TIM截图20180418223540.png (761.73 KiB) Viewed 7581 times
Untitled.png
Untitled.png (1.82 MiB) Viewed 7582 times
Last edited by DeckerCHAN@gmail.com on Thu Apr 19, 2018 11:41 am, edited 2 times in total.

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

Re: Something Wrong with Train Path Finding

Post by Loewchen »

This is just very bad signalling resulting in unnecessarily occupied blocks.

DeckerCHAN@gmail.com
Burner Inserter
Burner Inserter
Posts: 8
Joined: Wed Apr 18, 2018 12:31 pm
Contact:

Re: Something Wrong with Train Path Finding

Post by DeckerCHAN@gmail.com »

Loewchen wrote:This is just very bad signalling resulting in unnecessarily occupied blocks.
Why it is bad and any suggestion to improve it?

Jap2.0
Smart Inserter
Smart Inserter
Posts: 2339
Joined: Tue Jun 20, 2017 12:02 am
Contact:

Re: Something Wrong with Train Path Finding

Post by Jap2.0 »

DeckerCHAN@gmail.com wrote:
Loewchen wrote:This is just very bad signalling resulting in unnecessarily occupied blocks.
Why it is bad and any suggestion to improve it?
You should have signals before and after the intersections, and include some normal ones at the end of intersections, to break up blocks - I don't see anything other than chain inserters, and to be quite honest I'm surprised that it's worked as well as it is. How well do you know the signalling?
There are 10 types of people: those who get this joke and those who don't.

Aeternus
Filter Inserter
Filter Inserter
Posts: 835
Joined: Wed Mar 29, 2017 2:10 am
Contact:

Re: Something Wrong with Train Path Finding

Post by Aeternus »

The blue lined block is occupied by the waiting train to the top left of it (carrying copper wire) thats trying to turn into the path of that train that's already waiting there. You've got a deadlock there actually.

Using chain signals like this is going to cause issues. Chain signals reserve the entire path - from the trains departure to it's arrival station, if they only encounter additional chain signals. So each time a train moves, it's entire route is blocked to all other trains.

[Edit] Nevermind, images are different now. Signalling issue still remains.
Last edited by Aeternus on Thu Apr 19, 2018 2:31 pm, edited 1 time in total.

mrvn
Smart Inserter
Smart Inserter
Posts: 5682
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Something Wrong with Train Path Finding

Post by mrvn »

You only have chain signals. That means every train plans out the whole trip to the next station and reserves the full path. Each train can only find a path that no other train will be using. So most times they have to take quite a detour blocking even more paths for other trains.

Note how all the signals are red on your blue path. The train might like to go there but that would mean waiting for the signals to turn bkue/green. The other path is free now.

DeckerCHAN@gmail.com
Burner Inserter
Burner Inserter
Posts: 8
Joined: Wed Apr 18, 2018 12:31 pm
Contact:

Re: Something Wrong with Train Path Finding

Post by DeckerCHAN@gmail.com »

Jap2.0 wrote:
DeckerCHAN@gmail.com wrote:
Loewchen wrote:This is just very bad signalling resulting in unnecessarily occupied blocks.
Why it is bad and any suggestion to improve it?
You should have signals before and after the intersections, and include some normal ones at the end of intersections, to break up blocks - I don't see anything other than chain inserters, and to be quite honest I'm surprised that it's worked as well as it is. How well do you know the signalling?
From my understanding, signalling split rail to multiple blocks. As long as train paths do not overlapping, trains are able to work at same time.

I understand this is not a common approach and the best way is to put signals after and before interaction.

However, you may consider my set up as an "extreme" case to test train signalling.

Currently, I suspect the reason that trains circling instate go straight, is to trying to avoid to step into blocks which shorter than length of train it self.

So that when trains doing routing, shorter blocks has extra penalty than other blocks.

But when blocks created by chain signals, this penalty should not apply due to train will wait for entire route clear.

In fact, I have done some test. I have disconnect those bends to "force" trains go straight and they achieved to do that without "route not found" error(see attachement).

I did not find any document explain this and think this might be a bug.
Attachments
Untitled.png
Untitled.png (478.08 KiB) Viewed 7590 times

Zavian
Smart Inserter
Smart Inserter
Posts: 1641
Joined: Thu Mar 02, 2017 2:57 am
Contact:

Re: Something Wrong with Train Path Finding

Post by Zavian »

After every junction you need a block where a train is allowed to stop. So you need to add regular signals to the exit from every junction. The way you have your track laid out and signalled it is basically one large junction, and I don't think you can cleanly fix that without moving to a proper dual rail track system, with sidings for the stations, (ideally with enough waiting bays, to cope with the max number of trains assigned to that station). eg something similar to
Image
Image
(Images from Factorio blueprints https://factorioprints.com/view/-Kt7QxVushfraBweWaRk ).

At an absolute minimum you probably need to more to a grid of one way tracks. (Think a city street layout where this street is eastbound only, then the next street south is westbound only). If you don't add waiting bays, then you should signal the whole network as one big junction, (apart from any sidings where trains can stop). Doing that will probably work but throughput will get pretty bad.

Not having an exit block large enough for your longest train as part of the exit to every junction can lead to train deadlock. Not having enough waiting bays at stations can also cause deadlocks.

I'm pretty sure that it's impossible to adequately signal two-way sections of rail such that you separate the junctions and add exit blocks, without running into another possible case of deadlock. (This one is where a train is sitting waiting at the junction trying to go north, but it is blocked by another train sitting on the other side of that junction trying to go south. You might think that one of them could take the scenic route and turn east or west, but what if there are already two trains blocking those routes. One to the east of the junction wanting to go through the junction to anywhere, and another to the west, also wanting to path through the junction).
Last edited by Zavian on Thu Apr 19, 2018 2:23 pm, edited 1 time in total.

DeckerCHAN@gmail.com
Burner Inserter
Burner Inserter
Posts: 8
Joined: Wed Apr 18, 2018 12:31 pm
Contact:

Re: Something Wrong with Train Path Finding

Post by DeckerCHAN@gmail.com »

Aeternus wrote:The blue lined block is occupied by the waiting train to the top left of it (carrying copper wire) thats trying to turn into the path of that train that's already waiting there. You've got a deadlock there actually.

Using chain signals like this is going to cause issues. Chain signals reserve the entire path - from the trains departure to it's arrival station, if they only encounter additional chain signals. So each time a train moves, it's entire route is blocked to all other trains.
OK, maybe that example is not very good. I have done another attempt and this one, the blue block is not blocked by any other routing train.
Attachments
Untitled.png
Untitled.png (1.82 MiB) Viewed 7582 times

mrvn
Smart Inserter
Smart Inserter
Posts: 5682
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Something Wrong with Train Path Finding

Post by mrvn »

Still to many yellow, and red signals there. Looks like there is another train running across the path.

Zavian
Smart Inserter
Smart Inserter
Posts: 1641
Joined: Thu Mar 02, 2017 2:57 am
Contact:

Re: Something Wrong with Train Path Finding

Post by Zavian »

Are you disabling stations using the circuit network? There is a penalty for a train stop that is not the destination, but I have no idea what the penalty for a disabled station is, or even if the rail path algorithm considers that as a station.

Also if you actually want the devs to look at this you should upload the save. (One min to download and open a saved game vs 10+ mins to recreate your rail setup, and then they still don't know what your combinators are doing).

Serenity
Smart Inserter
Smart Inserter
Posts: 1000
Joined: Fri Apr 15, 2016 6:16 am
Contact:

Re: Something Wrong with Train Path Finding

Post by Serenity »

Still chain signals everywhere opposite each other. You need a chain signal before the crossing and a normal signal after. Then the train stops at the chain signal if it can't pass the normal signal, thus not blocking the intersection.

And as said, in general it's best to have one track for each direction

Zavian
Smart Inserter
Smart Inserter
Posts: 1641
Joined: Thu Mar 02, 2017 2:57 am
Contact:

Re: Something Wrong with Train Path Finding

Post by Zavian »

Serenity wrote:Still chain signals everywhere opposite each other. You need a chain signal before the crossing and a normal signal after
But doing will make the layout prone to deadlocks.
Zavian wrote:I'm pretty sure that it's impossible to adequately signal two-way sections of rail such that you separate the junctions and add exit blocks, without running into another possible case of deadlock. (This one is where a train is sitting waiting at the junction trying to go north, but it is blocked by another train sitting on the other side of that junction trying to go south. You might think that one of them could take the scenic route and turn east or west, but what if there are already two trains blocking those routes. One to the east of the junction wanting to go through the junction to anywhere, and another to the west, also wanting to path through the junction).

Serenity
Smart Inserter
Smart Inserter
Posts: 1000
Joined: Fri Apr 15, 2016 6:16 am
Contact:

Re: Something Wrong with Train Path Finding

Post by Serenity »

Yeah, but as you said that's because the distance between the intersections are too small. Not directly because of the signals. You need to space them at least a train length apart

mrvn
Smart Inserter
Smart Inserter
Posts: 5682
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Something Wrong with Train Path Finding

Post by mrvn »

Serenity wrote:Yeah, but as you said that's because the distance between the intersections are too small. Not directly because of the signals. You need to space them at least a train length apart
@serenity: All the tracks are bi-directional. Placing full signals would cause trains to halt in the middle of their path and then you quickly have trains going in opposite directions blocking each other. It's just not possible with his design.

If you want to keep your bi-directional design then you simply have to live with trains going out of their way to drive around other trains.

Zavian
Smart Inserter
Smart Inserter
Posts: 1641
Joined: Thu Mar 02, 2017 2:57 am
Contact:

Re: Something Wrong with Train Path Finding

Post by Zavian »

Serenity wrote:Yeah, but as you said that's because the distance between the intersections are too small. Not directly because of the signals. You need to space them at least a train length apart
No it's a general property of the two way rails. They enable two trains to approach head to head on the same track, which doesn't happen on a dual track system. See viewtopic.php?f=194&t=53937 . That's why I don't think you can cleanly separate the junctions without moving to one-way tracks, (or at least inserting sections of one way track as exit buffers). If you are going to do that, then you might as well make even lines run eastbound, and odd lines run westbound (and do the same with north and south lines). That effectively gives you one-way tracks, without needing all the space of a dual track system. And it will allow exit buffers without adding to the risk of deadlock.
mrvn wrote:
Serenity wrote:Yeah, but as you said that's because the distance between the intersections are too small. Not directly because of the signals. You need to space them at least a train length apart
@serenity: All the tracks are bi-directional. Placing full signals would cause trains to halt in the middle of their path and then you quickly have trains going in opposite directions blocking each other. It's just not possible with his design.

If you want to keep your bi-directional design then you simply have to live with trains going out of their way to drive around other trains.
Yeah, but a single large junction like that will almost certainly have terrible throughput.

Engimage
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Jun 29, 2016 10:02 am
Contact:

Re: Something Wrong with Train Path Finding

Post by Engimage »

First of all you should not use chain signals in your example. Chain signal looks all the way forward train's path up until normal signal or train's destination. In your case trains just won't move at all cause other train is somewhere there along his path (even if not near).
So try starting with replacing your signals with notmal ones.

Another problem is that when stopped at the signal your trains can't make a decision to change its path so this design will be deadlocked in no time. This is why the basic design of every intersection is placing chain signal before the intersections and normal after - the train will stop at chain signal and consider other path around if the initial one is blocked.

Third problem correlates with the first one and it is using dual way lines. Dual way railways are prone to deadlocks even more than any other faulty designs.

And the fourth problem in your design is not having train-fitting fragments between intersections. This generally does not allow for more valid solution in your layout. This was already noted by Zavian.

So yeah. This will never work fine as it is even with minor changes. You need more space for your stations and place chain signal after station before the intersection and normal signal on every intersection exit. This will end up having double signals everywhere but not inside intersections, with normal signal paired with chain signal. Not sure how effective will it end up but it will possibly somehow work.

ManaUser
Fast Inserter
Fast Inserter
Posts: 225
Joined: Sat Aug 12, 2017 9:41 pm
Contact:

Re: Something Wrong with Train Path Finding

Post by ManaUser »

Regardless of the fact that OP has created a very strange setup, it's still an interesting question why the train does that. I did a quick test and passing through disabled train-stops still seem to have the same penalty, so I don't think that's it.

For testing purposes, what would happen if you removed all trains but one?

Jap2.0
Smart Inserter
Smart Inserter
Posts: 2339
Joined: Tue Jun 20, 2017 12:02 am
Contact:

Re: Something Wrong with Train Path Finding

Post by Jap2.0 »

DeckerCHAN@gmail.com wrote:
Aeternus wrote:The blue lined block is occupied by the waiting train to the top left of it (carrying copper wire) thats trying to turn into the path of that train that's already waiting there. You've got a deadlock there actually.

Using chain signals like this is going to cause issues. Chain signals reserve the entire path - from the trains departure to it's arrival station, if they only encounter additional chain signals. So each time a train moves, it's entire route is blocked to all other trains.
OK, maybe that example is not very good. I have done another attempt and this one, the blue block is not blocked by any other routing train.

Image
Can you show the blocks? My guess is that the track just to the northeast of the intersection is unsignaled, so the train at the end of the red block is blocking it - although I thought in that case the signals would be flashing.
There are 10 types of people: those who get this joke and those who don't.

mrvn
Smart Inserter
Smart Inserter
Posts: 5682
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Something Wrong with Train Path Finding

Post by mrvn »

PacifyerGrey wrote:First of all you should not use chain signals in your example. Chain signal looks all the way forward train's path up until normal signal or train's destination. In your case trains just won't move at all cause other train is somewhere there along his path (even if not near).
So try starting with replacing your signals with notmal ones.
Yes, he should use chain signals. He MUST use chain signals. The design requires it since tracks are bidirectional and any full signal would cause instant deadlocks.

Post Reply

Return to “Gameplay Help”