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: 389
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.
Luck is not a robust control.

Amarula
Filter Inserter
Filter Inserter
Posts: 389
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 1499 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....
Luck is not a robust control.

Amarula
Filter Inserter
Filter Inserter
Posts: 389
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 1491 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 1491 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 1491 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 1491 times
Luck is not a robust control.

mrvn
Smart Inserter
Smart Inserter
Posts: 4450
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: 389
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:
Luck is not a robust control.

Amarula
Filter Inserter
Filter Inserter
Posts: 389
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 1410 times
Luck is not a robust control.

Amarula
Filter Inserter
Filter Inserter
Posts: 389
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 1410 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:
Luck is not a robust control.

User avatar
ickputzdirwech
Filter Inserter
Filter Inserter
Posts: 638
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.1, ick's Sea Block, ick's vanilla tweaks
Tools: Atom language pack
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: 389
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!
Luck is not a robust control.

User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1080
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: Train based direct insertion challenge

Post by ptx0 »

i did a build recently where i wanted to use 1 to 1 layout for my trains, that is, 1 train with n cargo wagons, feeding n columns of assemblers/chemplants, that feed another train with n cargo wagons. equal number of machines, modules, speed, etc. and for the life of me, it just continued occasionally getting stuck like you describe.

my solution was to measure a buffer at each wagon and send a green signal when it is low, so that the train will leave. i think that will solve your problem.
My Mods - Fish Per Minute base size metric - Use your crashed spaceship as a belt balancer?
• • •
Base: Bob's @ 1 Million SPM
• • •
Linear search and overflows are indicative of sloppy coding practices.

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

Re: Train based direct insertion challenge

Post by Amarula »

Happy New Year!
ptx0 wrote:
Fri Jan 01, 2021 3:29 am
my solution was to measure a buffer at each wagon
Yes checking the contents of a chest would work... except part of this challenge is not using any chests, going straight from the train direct into the factory. Hmm can I connect the factory to the circuit network? Sadly no...
However, I could connect to the inserters to count how much has been removed... and to balance how much each one takes! Let me think about that one for a while.
Luck is not a robust control.

Nidan
Long Handed Inserter
Long Handed Inserter
Posts: 57
Joined: Sat Nov 21, 2015 1:40 am
Contact:

Re: Train based direct insertion challenge

Post by Nidan »

You probably need to force all inserters to pick the same item every swing. Given all assemblers have the same amount of ingredients loaded, they should do that on their own, except for the swing where a wagon gets emptied of an item type. Some ideas:
a) If you happen to know which item the inserters are going to pick next you could limit their stack size so the items get split evenly between them
b) Upgrade to stack filter inserters so you control what the inserters will pick, then apply idea a. (I happen have some circuitry for balanced train unloading I could dig up in a few days when I return to the machine that map is stored on.)
c) Otherwise you could make the wagons carry multiples of (unloading inserters * stack size) of each item.

All of these probably require each wagon to carry ingredients in the right proportions and in multiples of (unloading inserters) but considering an earlier post that may already be the case
Amarula wrote:
Fri Jul 17, 2020 3:20 pm
I am choosing to set the trains to have the exact amounts so that everything runs out at the same time.

User avatar
disentius
Filter Inserter
Filter Inserter
Posts: 571
Joined: Fri May 12, 2017 3:17 pm
Contact:

Re: Train based direct insertion challenge

Post by disentius »

I am currently wrapping my head around the solutions of Fooluaintblack for item perfect loading trains; i think you could use some of his mechanisms to alleviate this problem. he made some video's with explanations, examples, and blueprints.
https://www.youtube.com/user/fooluaintblack

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

Re: Train based direct insertion challenge

Post by Amarula »

disentius wrote:
Sat Jan 02, 2021 11:08 am
I am currently wrapping my head around the solutions of Fooluaintblack for item perfect loading trains; i think you could use some of his mechanisms to alleviate this problem. he made some video's with explanations, examples, and blueprints.
https://www.youtube.com/user/fooluaintblack
Thank you!
Luck is not a robust control.

User avatar
NotRexButCaesar
Smart Inserter
Smart Inserter
Posts: 1044
Joined: Sun Feb 16, 2020 12:47 am
Contact:

Re: Train based direct insertion challenge

Post by NotRexButCaesar »

A simpler solution would be setting the unload condition to inactivity.
: Alea jacta est. Determine what you intend to accomplish with an action before execution.
Have you ever heard the gospel? Most have not.

User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1080
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: Train based direct insertion challenge

Post by ptx0 »

AmericanPatriot wrote:
Tue Jan 05, 2021 2:54 pm
A simpler solution would be setting the unload condition to inactivity.
this results in unnecessary rail traffic.
My Mods - Fish Per Minute base size metric - Use your crashed spaceship as a belt balancer?
• • •
Base: Bob's @ 1 Million SPM
• • •
Linear search and overflows are indicative of sloppy coding practices.

User avatar
NotRexButCaesar
Smart Inserter
Smart Inserter
Posts: 1044
Joined: Sun Feb 16, 2020 12:47 am
Contact:

Re: Train based direct insertion challenge

Post by NotRexButCaesar »

ptx0 wrote:
Tue Jan 05, 2021 3:06 pm
AmericanPatriot wrote:
Tue Jan 05, 2021 2:54 pm
A simpler solution would be setting the unload condition to inactivity.
this results in unnecessary rail traffic.
Only if your factory backs up.
: Alea jacta est. Determine what you intend to accomplish with an action before execution.
Have you ever heard the gospel? Most have not.

User avatar
SackCFix
Burner Inserter
Burner Inserter
Posts: 16
Joined: Sun May 31, 2020 8:17 am
Contact:

Re: Train based direct insertion challenge

Post by SackCFix »

Hey Amarula, have you yet found a solution to your uneven Unloading? If not, you might want to look in that Blueprint:




Looks exactly like your build, but with only one Stackinserter per Assembler and the Schedule as shown in the Screenshot below. The 3 Second Inactivity in this Case allows more stuff to be put out of the Train before it leaves. One Thing you need to make sure is to not have any Items in the Train that is loading the purple Science before it enters the Station, otherwise the Items in the Assemblers will be uneven and your Train can not unload its Stuff and fullfill its Wait Condition.
Purple Unloading.jpg
Purple Unloading.jpg (401.88 KiB) Viewed 1024 times


I used these Filters in this Setup:

Unloading-Train:
Purple Train Inventory.jpg
Purple Train Inventory.jpg (70.19 KiB) Viewed 1024 times
Science Train:
Science Train Inventory.jpg
Science Train Inventory.jpg (44.57 KiB) Viewed 1024 times

The Blueprint above did now over a 1000 Cycles without any Interruptions (except i forgot to give Fuel to Trains (fixed in Blueprint) :lol: ).

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

Re: Train based direct insertion challenge

Post by Amarula »

SackCFix wrote:
Wed Jan 06, 2021 2:40 pm
Hey Amarula, have you yet found a solution to your uneven Unloading?
Happy New Year! and no, not really...
SackCFix wrote:
Wed Jan 06, 2021 2:40 pm
Looks exactly like your build, but with only one Stackinserter per Assembler and the Schedule as shown in the Screenshot below. The 3 Second Inactivity in this Case allows more stuff to be put out of the Train before it leaves. One Thing you need to make sure is to not have any Items in the Train that is loading the purple Science before it enters the Station, otherwise the Items in the Assemblers will be uneven and your Train can not unload its Stuff and fullfill its Wait Condition.
I understand the 3 second delay, I have been working towards that style of exit condition so the train doesn't get stuck but it doesn't leave when things are still unloading...

I am not clear what you mean by don't 'have any items in the Train... before it enters the Station.'

Only one Stack inserter... hmmm... this seems to be the significant change from my design... ooh smoke is coming out my ears 8-) So if the uneven loading is caused by competition between inserters trying to grab the same items, having fewer inserters means less competition, so maybe that reduces the likelihood of uneven unloading leading to incomplete emptying of the train?
SackCFix wrote:
Wed Jan 06, 2021 2:40 pm
The Blueprint above did now over a 1000 Cycles without any Interruptions (except i forgot to give Fuel to Trains (fixed in Blueprint) :lol: ).
Ah yes... I very rarely run a train out of fuel, my personal Factorio super-power is finding new and interesting ways to run out of power :roll:

Looks like you have a working solution, not just theoretical! One thing, do you have a sense of how balanced the unloading is? You aren't using train empty so I'm thinking it isn't perfect, but how often does it have leftovers? And what is left over? Is is always or usually the same thing left over?

Thank you so much for sharing!
Luck is not a robust control.

User avatar
SackCFix
Burner Inserter
Burner Inserter
Posts: 16
Joined: Sun May 31, 2020 8:17 am
Contact:

Re: Train based direct insertion challenge

Post by SackCFix »

No problem, glad to help :D


Amarula wrote:
Wed Jan 06, 2021 3:23 pm
I understand the 3 second delay, I have been working towards that style of exit condition so the train doesn't get stuck but it doesn't leave when things are still unloading...
Sorry, that Inactivity might look strange and it works perfectly without them. So i explain my thoughts in Detail:

Without Inactivity:
-At the Point where one of the Items is 0, the Train will instantly leave the Station.

With Inactivity:
-At the Point where one of the Items is 0, the Train will wait 3 more Seconds just to give the Inserters a Chance to grab some more Items. So, this isn't really needed. But Stuff that is put out of the Train, will be replaced with new Stuff in Terms of Logistics-Efficency (i don't care in my Base).

Amarula wrote:
Wed Jan 06, 2021 3:23 pm
I am not clear what you mean by don't 'have any items in the Train... before it enters the Station.'
So if there's a single Purple Science Pack in that Train, your Assemblers will Produce different Amounts of Items. In combination with Prod-3-Modules this is going to be uncountable without lots of efford. The Key is, to make sure that every Assembler/Pair of Assemblers got the same Output every Cycle. Therefore, make sure the Train comes in without Purple Science Packs (or the exactly the same in every Wagon) and only leaves the Station when all its Cargo-Wagons are filled with the exact same amount of Purple Science Packs. This is a really precise Setup, but works for me even with 6-20-6' Trains. You may need to remove these Assemblers and put them back down! If one Assembler has just a little tiny bit more in its Productivity-Bar, things might go wrong (and they tend to go wrong :lol: )

Amarula wrote:
Wed Jan 06, 2021 3:23 pm
...So if the uneven loading is caused by competition between inserters...
Ahm... kind off. From what i've experienced, it's more that they lock each other if the timing of the Assemblers is messed up as mentioned above. This does work with more Inserters, but in this Case for the Purple Science Recipe its fine. There are other Recipes where you definetily need more than one Stack-Inserter.

Amarula wrote:
Wed Jan 06, 2021 3:23 pm
...is always or usually the same thing left over?
This Recipe will allways have leftovers. As you know, there are a few where the Slots of the Cargo Wagon can be filtered perfectly. So the leftovers are both 30 Furnaces and Modules in every Wagon. I would guess that at 10-15% It's both 54 Furnaces and Modules. The Rails *allways* empty the first.

Amarula wrote:
Wed Jan 06, 2021 3:23 pm
One thing, do you have a sense of how balanced the unloading is?
Yes, the unloading isn't balanced at all... but let me explain:

This Screenshot shows an array of Labs
Science Goo Converter.jpg
Science Goo Converter.jpg (496.68 KiB) Viewed 1005 times


There are no Boxes or fancy Circuitry
Science Direct Insertion to Labs.jpg
Science Direct Insertion to Labs.jpg (499.17 KiB) Viewed 1005 times


And this is what the Trains look after they left the Labs
Science Not Balanced.jpg
Science Not Balanced.jpg (557.2 KiB) Viewed 1005 times


The Trains aren't balanced, as you can see from the Screenshot. But, every Wagon of one Train has exact the same amount of leftovers. And there's your balanced unloading. And that's the Point. As long as the last part of your Production-Chain is used up equaly (similar to the Assembler-Timing), everything is fine, as long as this continues all the way down your Factory. And in the End/Start/Whatever your Miners are the real ones doing the balancing.
I'm not sure if i said this before but this is a little precise... researching a non-infinite-technology can result in an uneven Consumption of Science Packs along your Cargo-Wagons. I did this once, had to destroy the entire Research Facility, chase down every Train/Assembler/Inserter with different Items and then restart them... uff... Or, you click on a Train, switch it to Manual and then realize the last 3 Wagons are still in the Lane and emptied by Inserters... ups... again...


But after some hard lessons learned, this concept works perfect for me.

My current Blue Science Build for example produced over 16KSPM over 8 Hours before i shut it down again. Not a single locked Inserter or stucked Train...and 0 Combinators.
Train Based Engines.jpg
Train Based Engines.jpg (845.04 KiB) Viewed 1005 times


Amarula wrote:
Wed Jan 06, 2021 3:23 pm
I understand the 3 second delay, I have been working towards that style of exit condition so the train doesn't get stuck but it doesn't leave when things are still unloading...
I'm sorry, while writting this Post i realized what you ment now. You are correct, this only works in this specific setup. But i hope i haven't confused you too much and get the Idea of how simple this balancing is ;-)

Post Reply

Return to “Medium/Big/Gigantic Sized Structures”