Page 1 of 1

Ensuring trains visit all stops with the same name fairly.

Posted: Tue Dec 04, 2018 5:26 am
by Ingolifs
I am currently transitioning my base into a rail-based megafactory for the endgame.

The plan is to have most of the intermediate products for research and launches produced in individual bases and transported by rail. Each output of one base (e.g. circuits) is delivered by train to one of many stations, all with the same name. Once a station has more than enough of this intermediate, a circuit condition disables the stop.

I've done some testing, and while everything functions perfectly when there is a slight overpressure of starting materials (i.e. where slightly more of each starting material is produced than is consumed), it doesn't work so well when starting material supply is diminished.

When material is consumed faster than it can be replenished, the train stops are perpetually enabled, and the train only ever chooses to go to the nearest station, rather than visiting all stations fairly.

How do I ensure that trains all visit all stations fairly when they can't supply enough to disable any one station? Are there clever circuit conditions I can use?

Also, I don't have terribly much experience with these sort of rail megabases. Any other general pieces of advice about layout and design are welcome.

Re: Ensuring trains visit all stops with the same name fairly.

Posted: Tue Dec 04, 2018 5:46 am
by DaveMcW
Why do you need them to be fair? The production line that is getting more will back up eventually and stop demanding supplies. You can speed up the process by minimizing the use of buffers.

Re: Ensuring trains visit all stops with the same name fairly.

Posted: Tue Dec 04, 2018 6:05 am
by Ingolifs
Okay. When starting material production is greater than consumption there is no problem.

I am not referring to that situation. I am referring to situations where because of a depleted mining base or because of a train deadlock (which seeing as I still don't truly understand train signals, is pretty likely), materials get consumed faster than they get produced.

If iron is needed by both the gears base and the circuits base, and not enough iron gets produced to satisfy both, both train stations requesting iron will be perpetually on. In that case, the station that's closest (let's say gears) will always receive iron, and the circuits base will never receive iron.

The situation is akin to using spaghetti belts rather than a main bus and splitters.

to reiterate my question:
How do I ensure that trains all visit all stations fairly when they can't supply enough to disable any one station? Are there clever circuit conditions I can use?

Re: Ensuring trains visit all stops with the same name fairly.

Posted: Tue Dec 04, 2018 6:17 am
by Koub
A counter ? Every station counts "+1" whenever supplied, and you always deliver to the lowest count needing supplies.

Re: Ensuring trains visit all stops with the same name fairly.

Posted: Tue Dec 04, 2018 6:23 am
by DaveMcW
Ingolifs wrote:
Tue Dec 04, 2018 6:05 am
the station that's closest (let's say gears) will always receive iron, and the circuits base will never receive iron.
The gear station produces gears.
The gears are delivered to the inserter station.
The inserter station does not produce anything because it has no circuits.
The inserter station fills up with gears.
The gear station fills up with gears.
The gear station fills up with iron.
Iron is delivered to the circuit station.

Problem solved!

The smaller your buffers are, the faster the problem will solve itself.

Re: Ensuring trains visit all stops with the same name fairly.

Posted: Tue Dec 04, 2018 6:41 am
by Ingolifs
Koub wrote:
Tue Dec 04, 2018 6:17 am
A counter ? Every station counts "+1" whenever supplied, and you always deliver to the lowest count needing supplies.
I do not know enough about circuits to implement this. How would you add a +1 count to a station? How do you compare multiple signals to find the lowest? And how do you get a train to go to the station selected as the lowest?

I feel like if you answer these questions, I should be able to figure it out from there. Thanks.

Re: Ensuring trains visit all stops with the same name fairly.

Posted: Tue Dec 04, 2018 7:48 am
by Zavian
Ingolifs wrote:
Tue Dec 04, 2018 6:05 am
ow do I ensure that trains all visit all stations fairly when they can't supply enough to disable any one station? Are there clever circuit conditions I can use?
I'd just use the simple solution of letting backpressure balance things. In general you don't want the a true even distribution scheme, since some stations need more resources than others. eg circuit and gears both need lots of iron plates, however by comparison inserters needs relatively few iron plates.

Re: Ensuring trains visit all stops with the same name fairly.

Posted: Wed Dec 05, 2018 12:47 pm
by Blinky
Nobody seems to have mentioned the obvious solution of increasing your supply. If all the iron is going to gears and not circuits then increase iron production to compensate.

Re: Ensuring trains visit all stops with the same name fairly.

Posted: Wed Dec 05, 2018 1:27 pm
by nosports
Blinky wrote:
Wed Dec 05, 2018 12:47 pm
Nobody seems to have mentioned the obvious solution of increasing your supply. If all the iron is going to gears and not circuits then increase iron production to compensate.
And that would be the one and only factorian way to address the problem here :mrgreen: 8-)

Re: Ensuring trains visit all stops with the same name fairly.

Posted: Wed Dec 05, 2018 1:49 pm
by 5thHorseman
Yeah it's just one stop in the perpetual Factorio loop of too much/too little. You always have too much of something and too little of something else, and you generally want too much of things closer to the start.

You want too much ore going to your smelters.
You want too many plates going to your intermediates.
You want too many intermediates going to your production.

Whenever this is not the case, you tend to have issues. Your setup (which I've done) just shows it far more quickly than most other setups.

Solution: MOAR SMELTING

Re: Ensuring trains visit all stops with the same name fairly.

Posted: Wed Dec 05, 2018 8:05 pm
by Amarula
I ran into the same problem when I started playing train based bases: The iron train trying to deliver to multiple clients didn't work as you found out. I tried a circuit train, going to get the inputs I needed for my circuits, and that didn't work (too much iron, no room to get copper, not using the iron I had because my factories stopped because they were out of copper). The solution I have that is working so far is one train for one purpose: one train for iron for circuits. One train for copper for circuits (actually I now have two trains for copper for circuits, one train wasn't enough). One train for iron for inserters. One train for circuits for inserters. It makes for a LOT of trains (120 trains and counting) but my problems are not from trains not delivering what is needed.
Good luck with your trains!

Re: Ensuring trains visit all stops with the same name fairly.

Posted: Mon Dec 10, 2018 12:32 pm
by JimBarracus
there is no good vanilla solution for this.
most obvious, produce more.

Your demand seems to be far from that what you can supply.

Re: Ensuring trains visit all stops with the same name fairly.

Posted: Mon Dec 10, 2018 12:47 pm
by mrvn
You need something like LTN to solve this easily.

The other way without waiting for backpressure to build up across all of creation is to use circuits to produce items only at a speed relative to the least filled station. So if circuit boards run out of iron the gear factory stops too and the iron can much quicker fill back up. It cuts down on the delay due to buffering at all the train stations.

And the third way is to use a transfer station, which you probably want anyway:

Create a station with N unloading stops and add N trains that collect all the iron plates form all the smelters. Unload the iron plates unto belts, merge, balance, split it up onto M loading stops. Create M trains and send them to deliver the iron plates to the various consumers. E.g. M=2 with one train going to the gear factory and one to the circuit board factory.

Re: Ensuring trains visit all stops with the same name fairly.

Posted: Mon Dec 10, 2018 1:48 pm
by Aeternus
It can be done with a small round-robin setup that manually flags signals red and reads them - as the signal is read, the next station in the chain's red signal is cleared so it can receive a train. It's critical to put a chain signal in front of the manually switched ones. I'm at work and can't provide a visual example unfortunately.
Played with the idea for some time, got it to work but it was far too much hassle to deal with in the long run. If you don't have enough incoming trains, make more mines, much easier. Oh, and if you want to almost halve the amount of traffic on your rail grid, put smelters at the mines and drag iron/copper plates home instead. Muuuuch more efficient as long as you can deal with pollution at the remote mines.

Re: Ensuring trains visit all stops with the same name fairly.

Posted: Mon Dec 10, 2018 3:14 pm
by mrvn
Aeternus wrote:
Mon Dec 10, 2018 1:48 pm
It can be done with a small round-robin setup that manually flags signals red and reads them - as the signal is read, the next station in the chain's red signal is cleared so it can receive a train. It's critical to put a chain signal in front of the manually switched ones. I'm at work and can't provide a visual example unfortunately.
Played with the idea for some time, got it to work but it was far too much hassle to deal with in the long run. If you don't have enough incoming trains, make more mines, much easier. Oh, and if you want to almost halve the amount of traffic on your rail grid, put smelters at the mines and drag iron/copper plates home instead. Muuuuch more efficient as long as you can deal with pollution at the remote mines.
That gets rather complex with multiple trains and handling trains waiting to be filled, trains on the way and trains unloading, ...

Re: Ensuring trains visit all stops with the same name fairly.

Posted: Tue Dec 11, 2018 8:09 am
by Aeternus
It can but not neccesarily. You just need to have a stacker and chain signal between the receiving stations and the arriving trains. The chain signal will prevent the arriving trains from pathing to the wrong station and repath if the active receiver changed.