Train based direct insertion challenge

Clever and beautiful constructions, bigger than two chunks
- Defense: killing biters as an art
- Castles, Throne Rooms, Decorations (comfortable living in the Factorio World)
- Main Bus Concepts
- Modular Systems, Factory Streets, show how all works together
- Megabases
Please provide us with blueprints or saves, if that makes sense of course.
Forum rules
Clever and beautiful constructions, bigger than two chunks
Amarula
Filter Inserter
Filter Inserter
Posts: 319
Joined: Fri Apr 27, 2018 1:29 pm
Contact:

Re: Train based direct insertion challenge

Post by Amarula »

I started doing some small science runs to see how everything works, and it didn't take very long for trains to start getting stuck. From observation and experimentation, it seems my issue is (hopefully was!) not matching the number of inserters unloading the train with the number of inputs being unloaded.

Where the number of inserters matched, for example two inserters and one, two, or four inputs, everything was fine. Factories that had three inputs got stuck. It seems that with two inserters unloading three inputs, the inputs came in unbalanced, and stayed unbalanced, until the supply train got stuck holding inputs that were not needed yet, and the factory blocked waiting for an input that had been exhausted.

My first attempt to fix this was to change the exit criteria from a simple train empty, to checking if any of the inputs were gone. That resulted in the train taking off when the factories would have been happy to remove the remaining items, so I changed it to check any inputs were zero AND the train was inactive. That made things a little better, but ended up just pushing the problem further down the supply chain, until for example a train delivering iron plates was sitting in the station with 8 plates in one cargo wagon, the other three were empty, and the train to be loaded didn't need any more iron in the matching wagon to be loaded.

I started going down the rabbit hole trying to identify when one but not all of the cargo wagons were empty, but I realized that was going to fix a symptom, not the cause. (And I haven't got a solution for that one either ;)

What I have done is to change the factories with three inputs to have three inserters unloading the supply train. Hopefully this will keep the load balanced, so I can go back to a simple check for an empty train. Of course putting three inserters on the input side means removing and replacing the factories one space over, and limiting the output side to two long-handled inserters instead of three. I don't think this will be an issue as the products that are produced fast enough to keep all three long-handled inserters busy (gears, cables, and green circuits) only have one or two inputs so they work fine with two loading inserters.

Amarula
Filter Inserter
Filter Inserter
Posts: 319
Joined: Fri Apr 27, 2018 1:29 pm
Contact:

Re: Train based direct insertion challenge

Post by Amarula »

Double the silo loading fun!
No belts double the silo fun.png
No belts double the silo fun.png (1.5 MiB) Viewed 255 times
Now, how do I ensure that the trains load the silos evenly, instead of all choosing the first unloading zone? I think I will need a circuit that counts the trains and controls the entrance signal accordingly....

Amarula
Filter Inserter
Filter Inserter
Posts: 319
Joined: Fri Apr 27, 2018 1:29 pm
Contact:

Re: Train based direct insertion challenge

Post by Amarula »

I don't know if I was doing something wrong, or if there is some limit about a train stop with no wait condition, but when I tried to count the trains going through my input queue, none of the incoming trains registered.

So this is how I got it to work:
I read the train stopped as it is unloading or waiting to unload the materials for making the rocket parts.
Reading stopped train.png
Reading stopped train.png (112.6 KiB) Viewed 247 times
Note that I have changed the default signal to P (I am using T to control loading the satellites into the silo, so it only loads when there is a train waiting to take away the space science packs).

I save the state of the previous train in an arithmetic combinator, O for old state = P + 0.
I detect the rising edge in a decider combinator, when a train arrives, as that moment when P > O, which sets A for arrival to one for true.
I count the number of trains L on the left lane in a standard arithmetic counter, L = L + A.
Counting stopped trains.png
Counting stopped trains.png (218.38 KiB) Viewed 247 times
I do the same thing on the right hand lane, only keeping the variables unique: Q for the train in the station, N for the old state of the train, B for the arrival of the train, and R for the train count.

Both L and R feed into a final decider combinator, which determines if the trains are evenly matched, E is set to true if L = R.
Testing the train counts.png
Testing the train counts.png (418.73 KiB) Viewed 247 times
Finally, the train signals are forced closed, one when the counts are even, and one when not, so that the lanes take turns allowing the parts trains through. This ensures that the rocket silos in the near left hand lane do not get priority and reloaded before the other (which otherwise could happen if my input trains can't keep up with demand).
Closing the signal.png
Closing the signal.png (544.76 KiB) Viewed 247 times

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

Re: Train based direct insertion challenge

Post by mrvn »

Train stops with no condition never get any trains. The train skips to the next stop as soon as it would have to start breaking.

Amarula
Filter Inserter
Filter Inserter
Posts: 319
Joined: Fri Apr 27, 2018 1:29 pm
Contact:

Re: Train based direct insertion challenge

Post by Amarula »

mrvn wrote:
Wed Oct 07, 2020 10:56 am
Train stops with no condition never get any trains.
Ah! There are no trains! :lol:

Amarula
Filter Inserter
Filter Inserter
Posts: 319
Joined: Fri Apr 27, 2018 1:29 pm
Contact:

Re: Train based direct insertion challenge

Post by Amarula »

I am continuing to go with one zone per science pack, and sectors within the zone that produce the necessary components for science pack production. I have three main sector layouts: one for factories, one for train to train transfer, and a handful of variations on the oil refinery layouts depending on which oil product is being made.
Here is an overview of the yellow science zone:
NB Yellow science Z15.png
NB Yellow science Z15.png (237.43 KiB) Viewed 166 times

Amarula
Filter Inserter
Filter Inserter
Posts: 319
Joined: Fri Apr 27, 2018 1:29 pm
Contact:

Re: Train based direct insertion challenge

Post by Amarula »

Sadly my trains are continuing to unload unevenly which sometimes causes the train to block: each cargo wagon unloads to a pair of factories, and sometimes one factory will take all that remains of one input, while the partner factory takes all that remains of a second input. This leaves both factories blocked waiting for input materials, but the cargo wagon has no more of that input. If there are only two inputs, this usually resolves itself, as the wagon unloads, the train empties, and the next supply train pulls in.

However, in some cases, even with only two inputs, the load is sufficiently unbalanced that the cargo wagon is left holding a few input items, but neither factory will take them. This seems especially likely to happen if the recipe requires more of one of the items - for example purple SP needing 30 rails. In my latest run, all four purple trains are blocked. One of each factory pair holds 28 furnaces, the other holds 28 productivity modules, so both are blocked waiting for the other input, and the supply trains are left holding 696 rails in each wagon.

Blocked Purple SP trains.png
Blocked Purple SP trains.png (1.24 MiB) Viewed 166 times
I could try to force the train to leave when it runs out of one item and is inactive, but I have seen cases where each cargo wagon is left holding a different single input item, so that the train as a whole is not at zero for any of them. Even if I somehow was able to tell that the train was stuck say using the fact that there was a customer train in the lane for its factories, pushing an almost empty train to be refilled ends up unbalancing the supply sector, which just pushes the problem to more and more sectors. :(

For recipes taking amounts less than the maximum stack size (14), I could use a brute force approach. Replace the stack inserters with filtered ones, assign each inserter one input, and limit the stack size for that inserter to twice the recipe demand for that item. Then link all the inserters together so that they only work in unison, so a factory gets enough parts to exactly produce two outputs every time. Or possibly link the inserters assigned to each input type together so that both factories get for example electric furnaces loaded at the same time, so the pairs of factories stay balanced.

This still doesn't solve the issue of recipes like purple SP with input amounts that are greater than the maximum stack size, or what to do about recipes that take four inputs like flying robot frames (or research labs that take 7 types of science packs). For them I may have to count everything that gets loaded in, and only enable the inserter when the count for that type is less than what is needed to match the other inputs -- but how do I tell a filter inserter that loads say red and green science packs that I am only enabling for the red ones??? :roll: :?: :cry:

User avatar
ickputzdirwech
Filter Inserter
Filter Inserter
Posts: 282
Joined: Sun May 07, 2017 10:16 am
Contact:

Re: Train based direct insertion challenge

Post by ickputzdirwech »

How about using only one machine per wagon? This would certainly fix this issue. In order to keep the production at a decent speed you could place beacons in between. Each assembler could be hit by four beacons. Not a very nice solution but it certainly wouldn’t jam.

As for the labs you could try to place some inserters in between each pair that can transfer science packs between them.
Mods: Shortcuts for 1.0, ick's vanilla tweaks
Text quickly seems cold and unfriendly. Be careful how you write and interpret what others have written.
- A reminder for me and all who read what I write.

Amarula
Filter Inserter
Filter Inserter
Posts: 319
Joined: Fri Apr 27, 2018 1:29 pm
Contact:

Re: Train based direct insertion challenge

Post by Amarula »

ickputzdirwech wrote:
Wed Oct 14, 2020 8:18 am
but it certainly wouldn’t jam.
Now I have a mental picture of strawberries being loaded into the assemblers to make jam... :lol: Or maybe cucumbers to make pickles 'cuz I am in a pickle...
ickputzdirwech wrote:
Wed Oct 14, 2020 8:18 am
As for the labs you could try to place some inserters in between each pair
I had thought of using only one assembler per wagon as a last ditch resort, but not the option of using inserters to auto-balance between labs. Thank you!

Post Reply

Return to “Medium/Big/Gigantic Sized Structures”

Who is online

Users browsing this forum: No registered users