Train based direct insertion challenge
Forum rules
Clever and beautiful constructions, bigger than two chunks
Re: Train based direct insertion challenge
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.
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.
My own personal Factorio super-power - running out of power.
Re: Train based direct insertion challenge
Double the silo loading fun!
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....
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....
My own personal Factorio super-power - running out of power.
Re: Train based direct insertion challenge
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. 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.
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. 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).
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. 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.
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. 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).
My own personal Factorio super-power - running out of power.
Re: Train based direct insertion challenge
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.
Re: Train based direct insertion challenge
Ah! There are no trains!
My own personal Factorio super-power - running out of power.
Re: Train based direct insertion challenge
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:
Here is an overview of the yellow science zone:
My own personal Factorio super-power - running out of power.
Re: Train based direct insertion challenge
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.
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???
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.
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???
My own personal Factorio super-power - running out of power.
- ickputzdirwech
- Filter Inserter
- Posts: 768
- Joined: Sun May 07, 2017 10:16 am
- Contact:
Re: Train based direct insertion challenge
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.
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
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
Re: Train based direct insertion challenge
Now I have a mental picture of strawberries being loaded into the assemblers to make jam... Or maybe cucumbers to make pickles 'cuz I am in a pickle...
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!ickputzdirwech wrote: ↑Wed Oct 14, 2020 8:18 amAs for the labs you could try to place some inserters in between each pair
My own personal Factorio super-power - running out of power.
Re: Train based direct insertion challenge
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 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.
Re: Train based direct insertion challenge
Happy New Year!
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.
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.
My own personal Factorio super-power - running out of power.
Re: Train based direct insertion challenge
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
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
Re: Train based direct insertion challenge
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
https://www.youtube.com/user/fooluaintblack
Re: Train based direct insertion challenge
Thank you!disentius wrote: ↑Sat Jan 02, 2021 11:08 amI 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
My own personal Factorio super-power - running out of power.
- NotRexButCaesar
- Smart Inserter
- Posts: 1121
- Joined: Sun Feb 16, 2020 12:47 am
- Contact:
Re: Train based direct insertion challenge
A simpler solution would be setting the unload condition to inactivity.
Ⅲ—Crevez, chiens, si vous n'étes pas contents!
Re: Train based direct insertion challenge
this results in unnecessary rail traffic.AmericanPatriot wrote: ↑Tue Jan 05, 2021 2:54 pmA simpler solution would be setting the unload condition to inactivity.
- NotRexButCaesar
- Smart Inserter
- Posts: 1121
- Joined: Sun Feb 16, 2020 12:47 am
- Contact:
Re: Train based direct insertion challenge
Only if your factory backs up.ptx0 wrote: ↑Tue Jan 05, 2021 3:06 pmthis results in unnecessary rail traffic.AmericanPatriot wrote: ↑Tue Jan 05, 2021 2:54 pmA simpler solution would be setting the unload condition to inactivity.
Ⅲ—Crevez, chiens, si vous n'étes pas contents!
Re: Train based direct insertion challenge
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.
I used these Filters in this Setup:
Unloading-Train: Science Train:
The Blueprint above did now over a 1000 Cycles without any Interruptions (except i forgot to give Fuel to Trains (fixed in 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.
I used these Filters in this Setup:
Unloading-Train: Science Train:
The Blueprint above did now over a 1000 Cycles without any Interruptions (except i forgot to give Fuel to Trains (fixed in Blueprint) ).
Re: Train based direct insertion challenge
Happy New Year! and no, not really...
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...SackCFix wrote: ↑Wed Jan 06, 2021 2:40 pmLooks 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 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 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?
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
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!
My own personal Factorio super-power - running out of power.
Re: Train based direct insertion challenge
No problem, glad to help
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).
This Screenshot shows an array of Labs
There are no Boxes or fancy Circuitry
And this is what the Trains look after they left the Labs
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.
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).
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 )
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.
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.
Yes, the unloading isn't balanced at all... but let me explain:
This Screenshot shows an array of Labs
There are no Boxes or fancy Circuitry
And this is what the Trains look after they left the Labs
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.
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