4-way intersections: Throughput and deadlocks [image heavy]

Smart setups of railway stations, intelligent routing, solutions to complex train-routing problems.
Please provide - only if it makes sense of course - a blueprint of your creation.
mrvn
Smart Inserter
Smart Inserter
Posts: 4050
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: 4-way intersectios: Throughput and deadlocks [image heavy]

Post by mrvn »

Tallinu wrote: I'd be interested in screenshots and/or a blueprint, particularly for a setup where it's just two parallel spawners with circuit-controlled merging. I'd had an idea about doing something like that, since it doesn't seem like there's any way to force trains to stop or slow down before reaching a red signal and then begin accelerating when the other train is about to clear the merge point. I was thinking that a series of signals along the incoming tracks, cross-wired to the parallel line of signals, each line reading its own state and closing if its partner in the other line was closed, might do the job. But I haven't had time to set up and test such a thing.
Model it after
https://forums.factorio.com/viewtopic. ... n#p280178

The idea is simple. There is a clock that advances every 76 ticks (sorry, remembered it wrong). Then an arithmetic combinator to compute the <clock> % <number of signals> and then each signal is set to be enabled on a different tick. Order the signals so at each junction it always alternates.

For two spawners you just have one signal green for X ticks and then the other for X ticks. Add some rails so the trains accelerate and then merge the tracks.

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

Re: 4-way intersectios: Throughput and deadlocks [image heavy]

Post by mrvn »

aaargha wrote:
Tallinu wrote:I'd be interested in screenshots and/or a blueprint, particularly for a setup where it's just two parallel spawners with circuit-controlled merging. I'd had an idea about doing something like that, since it doesn't seem like there's any way to force trains to stop or slow down before reaching a red signal and then begin accelerating when the other train is about to clear the merge point. I was thinking that a series of signals along the incoming tracks, cross-wired to the parallel line of signals, each line reading its own state and closing if its partner in the other line was closed, might do the job. But I haven't had time to set up and test such a thing.
I tried making something like that but ran in to some strangeness with trains stopping instantly, depending on which signals were closed (apparently it's not a bug), so I think you may need to make sure that only one signal on each line is closed via circuits at a time for it to work, but I haven't looked into it too much.
I made a parallel line of signals with all but one red. Trains wait before the signal and when it turns green they accelerate and merge. After the first signal no other signals are controlled. Time the signals right and the trains start and accelerate so they slot perfectly into gaps as they merge.

aaargha
Filter Inserter
Filter Inserter
Posts: 317
Joined: Wed Dec 07, 2016 8:35 am
Contact:

Re: 4-way intersectios: Throughput and deadlocks [image heavy]

Post by aaargha »

I've added a few of the intersections posted and one I was working on before going away which turned out to be not too far behind Windmill MK2 but more compact. Complete list: Inscribed square (aaargha), Windmill MK2 (Tallinu), Double squareabout (19wolf, Tallinu), 4-lane Multi-cross (Tallinu)

Still a few more to go. I'll also have to look into restructuring the deadlock ratings as the 0.15.27 bugfix seems to have made path changing deadlocks much less of an issue.
mrvn wrote:I made a parallel line of signals with all but one red. Trains wait before the signal and when it turns green they accelerate and merge. After the first signal no other signals are controlled. Time the signals right and the trains start and accelerate so they slot perfectly into gaps as they merge.
Ah alright. I was trying to build a more generic merge that would work even if the incoming trains were already moving.

User avatar
db48x
Fast Inserter
Fast Inserter
Posts: 105
Joined: Wed Mar 13, 2013 12:15 pm
Contact:

Re: 4-way intersectios: Throughput and deadlocks [image heavy]

Post by db48x »

aaargha wrote:I've added a few of the intersections posted and one I was working on before going away which turned out to be not too far behind Windmill MK2 but more compact. Complete list: Inscribed square (aaargha), Windmill MK2 (Tallinu), Double squareabout (19wolf, Tallinu), 4-lane Multi-cross (Tallinu)
Your Inscribed Square is quite interesting. It doesn't lose much for having one fewer buffer.

User avatar
Tallinu
Fast Inserter
Fast Inserter
Posts: 119
Joined: Sun Jun 14, 2015 8:14 am
Contact:

Re: 4-way intersectios: Throughput and deadlocks [image heavy]

Post by Tallinu »

aaargha wrote:I've added a few of the intersections posted and one I was working on before going away which turned out to be not too far behind Windmill MK2 but more compact. Complete list: Inscribed square (aaargha), Windmill MK2 (Tallinu), Double squareabout (19wolf, Tallinu), 4-lane Multi-cross (Tallinu)

Still a few more to go. I'll also have to look into restructuring the deadlock ratings as the 0.15.27 bugfix seems to have made path changing deadlocks much less of an issue.
Oooh, inscribed square is an interesting (and pretty!) layout. At a glance I'd say it has a lot of similarities structurally to my Windmill design, except with the right turns avoiding conflict with the through traffic by making the through traffic a huge square that leaves room for buffers inside it, instead of by taking them out of the center using pre and post lane swaps. For really large junctions that might actually be an easier way to get them through... Although I'm wondering if having them cross in an X through the center instead of a swirly square pattern might help by providing an extra buffer between four pairs of intersections. Might have to expand the square a little to provide room.
aaargha wrote:
mrvn wrote:I made a parallel line of signals with all but one red. Trains wait before the signal and when it turns green they accelerate and merge. After the first signal no other signals are controlled. Time the signals right and the trains start and accelerate so they slot perfectly into gaps as they merge.
Ah alright. I was trying to build a more generic merge that would work even if the incoming trains were already moving.
You can lower the speed of a moving train by putting two signals spaced some distance apart with a wire connecting them. The first one is set to read, sending the same signal output for green or yellow, and the second set to close when the first is transmitting that signal, so that a train which is moving too quickly begins decelerating to avoid overshooting the red signal but as soon as it passes into the block the signal turns green allowing it to proceed at the slower speed (if it can reserve the next blocks, at least). Putting the two signals closer together results in lower speed limits, and you can repeat these along a length of track, as long as you don't try to merge the second signal of one with the first signal of another. I believe they can even overlap without conflicting, though: If you have several such signal pairs, A1 A2, B1 B2, C1 C2, ... then you probably can arrange them not just as A1 === A2 B1 === B2 C1 === C2 but also as A1 == B1 = A2 = C1 = B2 == C2 and if I'm right, both should function, the difference being that the latter should maintain a smoother speed instead of the more varying speed that putting them back to back or farther apart would create. I have not tested placing them in such a fashion, though.

Edit: Actually it might be possible to merge the signals, but only if you do two things: alternate between green and red wire so that circuit network transmissions can't propagate beyond one signal's immediate neighbors, and alternate which circuit channel each rail signal transmits and receives on. So if A1 transmits on channel A, A2/B1 receives on channel A and transmits on B, B2/C1 receives B and transmits A, C2/D1 receives A and transmits B, etc. Again, this is untested, but theoretically should work. It might be harder to tie in other logic to lock down individual incoming track lines though, due to the problems that bridging the network wires would cause.

TBTerra2
Inserter
Inserter
Posts: 33
Joined: Wed Apr 05, 2017 12:57 pm
Contact:

Re: 4-way intersectios: Throughput and deadlocks [image heavy]

Post by TBTerra2 »

Something else that im not sure about the best way of tackling. particularly relevant for non 4 way intersections

At the moment the testing makes the major assumption that the amount of traffic coming from each direction is the same. For 4 way intersections this is not to unreasonable (although major crossing minor junctions do happen)

but for T junctions this is almost never the case, the two most common traffic patterns are:
  • Trunk end to 2 branches - lots of traffic going from bottom to left/right, about half that going from each left/right to bottom, and a very small amount going from left/right to right/left
  • 1 branch off trunk - lots of traffic going left/right to right/left, small amount going left/right to bottom and the same reverse
we dont have any way to adjust the relative amounts of trains heading into the junction from different directions, so these situations arnt really testable

aaargha
Filter Inserter
Filter Inserter
Posts: 317
Joined: Wed Dec 07, 2016 8:35 am
Contact:

Re: 4-way intersectios: Throughput and deadlocks [image heavy]

Post by aaargha »

TBTerra2 wrote:Something else that im not sure about the best way of tackling. particularly relevant for non 4 way intersections

At the moment the testing makes the major assumption that the amount of traffic coming from each direction is the same. For 4 way intersections this is not to unreasonable (although major crossing minor junctions do happen)

but for T junctions this is almost never the case, the two most common traffic patterns are:
  • Trunk end to 2 branches - lots of traffic going from bottom to left/right, about half that going from each left/right to bottom, and a very small amount going from left/right to right/left
  • 1 branch off trunk - lots of traffic going left/right to right/left, small amount going left/right to bottom and the same reverse
we dont have any way to adjust the relative amounts of trains heading into the junction from different directions, so these situations arnt really testable
If you place a variable delay between the sentry rail signal and the output station you can create a delay between when each train is spawned. The blueprint below shows how each output station would be changed. You would also need to add a red 1 signal to the -10k green constant combinator. The signal D is the number of ticks you want between each train. You could set each arm to use a different delay signal to only slow down the spawning on some inputs (just remember to not use the signal S).
Delay

caterpie
Manual Inserter
Manual Inserter
Posts: 3
Joined: Fri May 12, 2017 3:17 pm
Contact:

Re: 4-way intersectios: Throughput and deadlocks [image heavy]

Post by caterpie »

Alright, I've spent all day doing a testing setup for the 32 lane intersection. It doesn't quite reach 1000 trains per minute but it's very close. I'm sure it could be improved with optimized signaling but I think I'll leave it as it is. In my test it reached 972 trains per minute (though for the effective speed you'd have to divide that number by 4, since I'm getting just 15 ups).

If anyone is interested I can upload the save file with the testing rig, so that you can easily improve it.

aaargha
Filter Inserter
Filter Inserter
Posts: 317
Joined: Wed Dec 07, 2016 8:35 am
Contact:

Re: 4-way intersectios: Throughput and deadlocks [image heavy]

Post by aaargha »

Added the "New Gauge Interchange", or however it's supposed to be spelled (blueprint and guide differs). Tested without U-turns and I borrowed the lane changer Tallinu posted to deal with the specialized rails.

Now I think I only have the 8-lane multi-cross and some kind of links to the larger ones (I probably won't test them) left before I start diving into examining how deadlocks work nowadays and trying to find other consequences of that bugfix.

aaargha
Filter Inserter
Filter Inserter
Posts: 317
Joined: Wed Dec 07, 2016 8:35 am
Contact:

Re: 4-way intersectios: Throughput and deadlocks [image heavy]

Post by aaargha »

Sorry Tallinu, the 8-lane will have to wait, inspiration struck on the chain signal testing :)

OK, so the change in 0.15.27 does NOT fix all path changing deadlocks (especially in roundabouts). It fixes them for many intersections but it also introduces some strange path locking problems. More details are available in my bug report.

So while some intersections can no longer deadlock (except of course when disabling stations/deleting rails which may cause a hard re-path) I'm not going to update the OP until I know what will happen, if anything, to this change. Hopefully the issue will be corrected as the fix, or at least the concept of it, does not seem too hard.

HiddenWolf
Inserter
Inserter
Posts: 45
Joined: Thu Sep 24, 2015 1:37 pm

Re: 4-way intersectios: Throughput and deadlocks [image heavy]

Post by HiddenWolf »

Can anyone point me to a blueprint for an 'optimal' 2 or 4-lane T-junction?
I assume there is a reference design, and the people in this thread have it, but I've been unable to find it.

aaargha
Filter Inserter
Filter Inserter
Posts: 317
Joined: Wed Dec 07, 2016 8:35 am
Contact:

Re: 4-way intersectios: Throughput and deadlocks [image heavy]

Post by aaargha »

I'd guess the one Tallinu posted on the last page is probably pretty close to optimal, though you'd have to scale it down for a 2lane design.

Alternatively you could look at the "2x 3-way" and "2x high-perf-3-way" entries for 2-lane alternatives that are probably smaller, though worse throughput wise.

aaargha
Filter Inserter
Filter Inserter
Posts: 317
Joined: Wed Dec 07, 2016 8:35 am
Contact:

Re: 4-way intersectios: Throughput and deadlocks [image heavy]

Post by aaargha »

Added the 8-lane Multi-Cross. Managed to include a picture of it as well, 13270x13268 resolution so that even the people on 4k monitors need to scroll to see it all :) Also managed to optimize the filesize down to about 4.5 MB as PNG is apparently crazily efficient once you find some good programs.

I think that means that all submitted intersections that are 8-lane or less should be tested, if I've missed some please let me know.

User avatar
Tallinu
Fast Inserter
Fast Inserter
Posts: 119
Joined: Sun Jun 14, 2015 8:14 am
Contact:

Re: 4-way intersectios: Throughput and deadlocks [image heavy]

Post by Tallinu »

aaargha wrote:Tested without U-turns and I borrowed the lane changer Tallinu posted to deal with the specialized rails.
Cool. :D
aaargha wrote:I'd guess the one Tallinu posted on the last page is probably pretty close to optimal, though you'd have to scale it down for a 2lane design.

Alternatively you could look at the "2x 3-way" and "2x high-perf-3-way" entries for 2-lane alternatives that are probably smaller, though worse throughput wise.
Yeah, the high-performance 3-way is pretty close to the best you can do as long as the splits for the bypass lanes occur more than a train length away from the crossing, so that if a train is waiting to turn, another train can get around it to go the other way. Expanding it out to a big triangle where only two paths cross at a time instead of all three is the only way to improve on that, I believe. The screenshot I posted of the four lane buffered triangle would be easy to scale down to two lanes to accomplish that, although it would still want to have those bypass lanes added.
aaargha wrote:Added the 8-lane Multi-Cross. Managed to include a picture of it as well, 13270x13268 resolution so that even the people on 4k monitors need to scroll to see it all :) Also managed to optimize the filesize down to about 4.5 MB as PNG is apparently crazily efficient once you find some good programs.

I think that means that all submitted intersections that are 8-lane or less should be tested, if I've missed some please let me know.
Hah, my browser tab basically hangs if I try to zoom in on that picture! Thanks aaargha, hopefully someone will find a use for some of that crazy stuff. ;)

Also, I did some work the other day on lane merge control circuitry, and have something which only lets incorrect trains in about 5% of the time, and quickly sorts itself out even if that does happen, while also responding very quickly to lighter, free-flowing traffic, almost eliminating situations where the only thing making a train stop is the timed signals not lining up with its arrival. I was hoping to make it a tad more reliable but I think I'm just running into fine-grain timing issues that occasionally occur when two high-speed trains reserve the detection and control signals on two lanes at almost but not quite identical times and in just the right order, so the first one gains access right as the controller switches lanes and then allows the other train in as well. More thorough control system changes might be required to keep that from happening, but since it's designed to sort itself out by not opening the next lane if there are more trains than desired already present in the acceleration zone, I'll probably go ahead and post it.

The difference it makes isn't tremendous, only squeezing out another 3-5 trains per minute on a junction that was already pushing the 85-90 TPM range, but getting past that hurdle at all probably requires something along these lines. Another thing I like about the design is that it isn't reliant on fixed delays that don't necessarily fit trains moving at different speeds, as the trains themselves trigger lane cycling when they reach a "tripwire" partway down the acceleration tracks. If no train is present, it falls back on rapidly cycling between lanes until it detects one incoming. (That's the part that's probably responsible for the extra slipping in occasionally. If I can come up with a detection scheme where all lanes watch simultaneously and fire off a signal the moment a train reserves the block before the controlled signals, and a priority system in case that happens on the same tick... lol!)

spitfire_23
Inserter
Inserter
Posts: 23
Joined: Fri Jun 24, 2016 3:36 am
Contact:

Re: 4-way intersections: Throughput and deadlocks [image heavy]

Post by spitfire_23 »

hi, is there a version of this post for 3-way intersection throughput also?

aaargha
Filter Inserter
Filter Inserter
Posts: 317
Joined: Wed Dec 07, 2016 8:35 am
Contact:

Re: 4-way intersections: Throughput and deadlocks [image heavy]

Post by aaargha »

spitfire_23 wrote:hi, is there a version of this post for 3-way intersection throughput also?
Not that I'm aware of at least, though I'll admit to not really having looked for one either.

It would be pretty easy to adapt my setup to also handle 3-way intersections (others already have), it would only need some new profiles and a couple of clean-up stations I think. For the post most of the code for the OP could be re-used, as well as the templates for the intersections.

The reason I've not made one myself is, basically, that I do not have a collection of 3-way intersections to test, and also didn't have one when I got the idea for the post. The material for the initial version of this post was collected here and there as I looked at other properties for 4-way intersections, mostly deadlocks and, as 3-way intersections weren't as interesting in that regard, I never saved any great number of them (most people just seem to use the same design anyway).

If anyone else is interested in creating and maintaining a post for 3-way intersections they'd be more than welcome to use my test map to do so. If they would also like to structure the post like mine I'd be happy to share most of the source for the OP as well as the templates I've been using. So if anyone is interested, just send me a PM and I'll help as best I can.

If no one else is interested in maintaining such a post I might do so myself once I've finished up some other projects that seem more interesting. I wouldn't expect those to be done for at least a couple of months :)

User avatar
Tallinu
Fast Inserter
Fast Inserter
Posts: 119
Joined: Sun Jun 14, 2015 8:14 am
Contact:

Re: 4-way intersections: Throughput and deadlocks [image heavy]

Post by Tallinu »

Windmill Mk2 modified with Merge-O-Matic exit lane optimizer, pushing two-lane performance to 93-94 TPM:
Blueprint String
Here's a smaller blueprint with just a single example MoM build:
Blueprint String
Screenshot
Each lane has a set of combinator logic which is identical (except for a constant with its lane ID) and there's an additional master unit set into one of the lanes, responsible for selecting the current lane, which needs to have a constant in a decider updated if a different number of lanes are used (it's the one set up as "L < 3 output L" where 3 is the number of lanes). The track lengths and spacing of the two "tripwire" rows of signals before and after the stopping point in this example is set up for six car trains, and everything would need to be scaled up to achieve optimal timing for longer trains. Not too difficult, although each lane's red data line has to stay separate from the main red line (which the tripwire signals are on) to function correctly. If anyone wants more information feel free to ask.

TBTerra2
Inserter
Inserter
Posts: 33
Joined: Wed Apr 05, 2017 12:57 pm
Contact:

Re: 4-way intersections: Throughput and deadlocks [image heavy]

Post by TBTerra2 »

I am currently working on a 3way tester. im using my own map but with the same end station consept as the 4way (though ive made it so theres one input train per test, instead of one input per test per line)

the intention was to test the standard 2-4-0 a long 4-8-0 and a heavy 2-(4liquid)-0, for three usage cases (equal usage of all directions, east/west trunk - south branch, south trunk - east/west branch)

the challenge atm with getting the 2nd and 3rd use cases working properly. but once that down it should be ready for use

Also im using nitro for getting trains out the station (20x accel for 1 second)

User avatar
db48x
Fast Inserter
Fast Inserter
Posts: 105
Joined: Wed Mar 13, 2013 12:15 pm
Contact:

Re: 4-way intersections: Throughput and deadlocks [image heavy]

Post by db48x »

Tallinu wrote: Each lane has a set of combinator logic which is identical (except for a constant with its lane ID) and there's an additional master unit set into one of the lanes, responsible for selecting the current lane, which needs to have a constant in a decider updated if a different number of lanes are used (it's the one set up as "L < 3 output L" where 3 is the number of lanes). The track lengths and spacing of the two "tripwire" rows of signals before and after the stopping point in this example is set up for six car trains, and everything would need to be scaled up to achieve optimal timing for longer trains. Not too difficult, although each lane's red data line has to stay separate from the main red line (which the tripwire signals are on) to function correctly. If anyone wants more information feel free to ask.
That works really well:


User avatar
Tallinu
Fast Inserter
Fast Inserter
Posts: 119
Joined: Sun Jun 14, 2015 8:14 am
Contact:

Re: 4-way intersections: Throughput and deadlocks [image heavy]

Post by Tallinu »

db48x wrote:That works really well:
Thanks! Nice recording, shows behavior for both light and heavy traffic.
spitfire_23 wrote:hi, is there a version of this post for 3-way intersection throughput also?
I have a save where I added a very basic 3-way test profile (east, west, and south stations are used), as well as a lane changer test profile (only really works for 4-lane setups, must have either the inner pairs or outer pairs of lanes from the east and west stations connected). I'll attach it here.

The 3-way doesn't support anything fancy, it behaves just like the 4-way test, bringing trains in equally from all directions -- the only difference is that it doesn't attempt to send any trains to the north.
Attachments
aaarghas - Cleared 6-car w 2-3 way profiles.zip
(12.71 MiB) Downloaded 43 times

Post Reply

Return to “Railway Setups”

Who is online

Users browsing this forum: No registered users