[2.0.23] Recycler returns disproportionate amount of ingredients over a long time
[2.0.23] Recycler returns disproportionate amount of ingredients over a long time
What did you do?
I build the following assembler / circuit network contraption to make legendary bulk inserters. Using the requester chest, it requests only normal quality items from the logistic network to make a normal bulk inserters. The assembler and recycler are loaded with quality modules to sometimes make quality items. Any inserter that is not a legendary inserter will be put in the recycler to be recycled. The content of the recycler is put back in the blue requester chest. (Trash unrequested is not set, so any ingredients will not be removed from the box by robots.) The circuit network switches the assembler recipe to make uncommon, rare, epic or legendary bulk inserters, when there are enough ingredients for that quality inside the requester chest.
What happened?
The requester chest got filled over time with an disproportionate amount of ingredients of the same quality. This causes the chest to be clogged up over time with only a few of the ingredients for that quality. For example in the following screen shot you can see that there are 3.6k uncommon gears, 3.4k uncommon circuit networks and 150 uncommon fast inserters. However, no uncommon advanced circuit is in the box, also an ingredient of the bulk inserter. Similar for rare items. 264, 256, and 120, respectively, for gears, electronic circuits, and fast inserters. However, again no advanced circuits of this quality are present. For epic quality it seems to be slightly different, there are electronic circuits, advanced circuits but no gears. For legendary ingredients the resulting ratios seem similar to uncommon and rare ingredients ratios. The longer I let this run, the more uneven it becomes, I already upgraded the requester chest from a common chest to a legendary one to see if the problem persisted.
What did you expect to happen instead? It might be obvious to you, but do it anyway!
I expect, that over a long time, probabilities will even out, and I don't expect the requester chest to be clogged up with a few ingredients but no ingredients of the other. Meaning for uncommon and rare qualities I expect advanced circuits would have been returned in more proportional amounts compared to the other ingredients. If so, more bulk inserters of that quality would have been produced and we would see for example a lot less uncommon gears and uncommon electronic circuits clogged up in the box.
Does it happen always, once, or sometimes?
I can reproduce this with a copy of this set-up for bulk inserters. I have used copies of this set-up for other products, there I can not notice the effect, but this can at least partly be explained by the fact I have made a lot of bulk inserters using this set-up, and not many other products. This assembler has produced 125k bulk inserters (all qualities combined).
Save file can be downloaded here: https://drive.google.com/file/d/1A9FoVI ... sp=sharing
I build the following assembler / circuit network contraption to make legendary bulk inserters. Using the requester chest, it requests only normal quality items from the logistic network to make a normal bulk inserters. The assembler and recycler are loaded with quality modules to sometimes make quality items. Any inserter that is not a legendary inserter will be put in the recycler to be recycled. The content of the recycler is put back in the blue requester chest. (Trash unrequested is not set, so any ingredients will not be removed from the box by robots.) The circuit network switches the assembler recipe to make uncommon, rare, epic or legendary bulk inserters, when there are enough ingredients for that quality inside the requester chest.
What happened?
The requester chest got filled over time with an disproportionate amount of ingredients of the same quality. This causes the chest to be clogged up over time with only a few of the ingredients for that quality. For example in the following screen shot you can see that there are 3.6k uncommon gears, 3.4k uncommon circuit networks and 150 uncommon fast inserters. However, no uncommon advanced circuit is in the box, also an ingredient of the bulk inserter. Similar for rare items. 264, 256, and 120, respectively, for gears, electronic circuits, and fast inserters. However, again no advanced circuits of this quality are present. For epic quality it seems to be slightly different, there are electronic circuits, advanced circuits but no gears. For legendary ingredients the resulting ratios seem similar to uncommon and rare ingredients ratios. The longer I let this run, the more uneven it becomes, I already upgraded the requester chest from a common chest to a legendary one to see if the problem persisted.
What did you expect to happen instead? It might be obvious to you, but do it anyway!
I expect, that over a long time, probabilities will even out, and I don't expect the requester chest to be clogged up with a few ingredients but no ingredients of the other. Meaning for uncommon and rare qualities I expect advanced circuits would have been returned in more proportional amounts compared to the other ingredients. If so, more bulk inserters of that quality would have been produced and we would see for example a lot less uncommon gears and uncommon electronic circuits clogged up in the box.
Does it happen always, once, or sometimes?
I can reproduce this with a copy of this set-up for bulk inserters. I have used copies of this set-up for other products, there I can not notice the effect, but this can at least partly be explained by the fact I have made a lot of bulk inserters using this set-up, and not many other products. This assembler has produced 125k bulk inserters (all qualities combined).
Save file can be downloaded here: https://drive.google.com/file/d/1A9FoVI ... sp=sharing
- Attachments
-
- factorio-current.log
- (16.15 KiB) Downloaded 4 times
Re: [2.0.23] Recycler returns disproportionate amount of ingredients over a long time
Assuming the pRNG is working correctly, this is expected to some degree. It's a random walk.
A good way to test if the pRNG is NOT working correctly is if this is consistent for the same item times of the same quality. If say, epic inserters always have an excess of one ingredient, tested across multiple independent setups, then something is borked.
A good way to test if the pRNG is NOT working correctly is if this is consistent for the same item times of the same quality. If say, epic inserters always have an excess of one ingredient, tested across multiple independent setups, then something is borked.
Re: [2.0.23] Recycler returns disproportionate amount of ingredients over a long time
just to chime in here quickly, are you using provider chests for the output items?
In most cases of "clog due to 25% recycling rate not consistent" the most common issue I've seen is that the recycled ingredients are requested for other quality items you're producing somewhere else with requester chests, so over time an imbalance will manifest.
In most cases of "clog due to 25% recycling rate not consistent" the most common issue I've seen is that the recycled ingredients are requested for other quality items you're producing somewhere else with requester chests, so over time an imbalance will manifest.
Never Stop!
Re: [2.0.23] Recycler returns disproportionate amount of ingredients over a long time
No. I only request items for common quality through a requester chesr. I agree, in that case you can expect uneven amounts of items in the chest.Theragus wrote: ↑Sat Nov 30, 2024 6:54 am just to chime in here quickly, are you using provider chests for the output items?
In most cases of "clog due to 25% recycling rate not consistent" the most common issue I've seen is that the recycled ingredients are requested for other quality items you're producing somewhere else with requester chests, so over time an imbalance will manifest.
Re: [2.0.23] Recycler returns disproportionate amount of ingredients over a long time
Unfortunately, then I have no other ideas.
some discrepancy is to be expected although it should never reach a point where a whole 48-slot chest completely fills up with other ingredients.
some discrepancy is to be expected although it should never reach a point where a whole 48-slot chest completely fills up with other ingredients.
Never Stop!
Re: [2.0.23] Recycler returns disproportionate amount of ingredients over a long time
Do you have a savefile you can provide?
Never Stop!
Re: [2.0.23] Recycler returns disproportionate amount of ingredients over a long time
Oh yeah, sorry, im blind.
Never Stop!
-
- Burner Inserter
- Posts: 5
- Joined: Wed Nov 20, 2024 6:35 pm
- Contact:
Re: [2.0.23] Recycler returns disproportionate amount of ingredients over a long time
I can't replicate this.
I copied your setup 81 times and let it run at 64x speed.
All of them completed the 10 slot output without locking up, and had the expected proportion of materials left over (46-47.4% gear/circuits, 2.8-3.5% adv.circ/fast.ins, expected average of 46.9% and 3.1% respectively) ~105k crafts per setup
I then uncapped the output chests and let it run again.
19 (23.5%) of the chests locked up, but the total proportion of materials left over matched the expected (45.8-47.4%, 3-4.2% (that 4.2% from epic advanced circuits being a bit of an outlier, but not by enough to make me suspect anything is working incorrectly)). It is very likely just random variance.
Basically, you should be pulling out anything over a certain amount so it doesn't lock up. With enough other crafting setups any excess will even out. For instance, adding the quality ingredients to the requester chest and trashing unrequested, with a large enough storage elsewhere will make it take significantly longer to lock up (i.e. where two different setups make too much of different materials they can now share them), though it will eventually need sorting (e.g. a perfectly fair coin flipped infinitely many times will have infinitely many streaks of Heads overflowing any arbitrary non-infinite buffer)
I copied your setup 81 times and let it run at 64x speed.
All of them completed the 10 slot output without locking up, and had the expected proportion of materials left over (46-47.4% gear/circuits, 2.8-3.5% adv.circ/fast.ins, expected average of 46.9% and 3.1% respectively) ~105k crafts per setup
I then uncapped the output chests and let it run again.
19 (23.5%) of the chests locked up, but the total proportion of materials left over matched the expected (45.8-47.4%, 3-4.2% (that 4.2% from epic advanced circuits being a bit of an outlier, but not by enough to make me suspect anything is working incorrectly)). It is very likely just random variance.
Basically, you should be pulling out anything over a certain amount so it doesn't lock up. With enough other crafting setups any excess will even out. For instance, adding the quality ingredients to the requester chest and trashing unrequested, with a large enough storage elsewhere will make it take significantly longer to lock up (i.e. where two different setups make too much of different materials they can now share them), though it will eventually need sorting (e.g. a perfectly fair coin flipped infinitely many times will have infinitely many streaks of Heads overflowing any arbitrary non-infinite buffer)
Re: [2.0.23] Recycler returns disproportionate amount of ingredients over a long time
kaijyuu wrote: ↑Sat Nov 30, 2024 3:40 am Assuming the pRNG is working correctly, this is expected to some degree. It's a random walk.
A good way to test if the pRNG is NOT working correctly is if this is consistent for the same item times of the same quality. If say, epic inserters always have an excess of one ingredient, tested across multiple independent setups, then something is borked.
Thanks for the replies.warbob5000 wrote: ↑Sat Nov 30, 2024 3:55 pm I can't replicate this.
I copied your setup 81 times and let it run at 64x speed.
All of them completed the 10 slot output without locking up, and had the expected proportion of materials left over (46-47.4% gear/circuits, 2.8-3.5% adv.circ/fast.ins, expected average of 46.9% and 3.1% respectively) ~105k crafts per setup
I then uncapped the output chests and let it run again.
19 (23.5%) of the chests locked up, but the total proportion of materials left over matched the expected (45.8-47.4%, 3-4.2% (that 4.2% from epic advanced circuits being a bit of an outlier, but not by enough to make me suspect anything is working incorrectly)). It is very likely just random variance.
Basically, you should be pulling out anything over a certain amount so it doesn't lock up. With enough other crafting setups any excess will even out. For instance, adding the quality ingredients to the requester chest and trashing unrequested, with a large enough storage elsewhere will make it take significantly longer to lock up (i.e. where two different setups make too much of different materials they can now share them), though it will eventually need sorting (e.g. a perfectly fair coin flipped infinitely many times will have infinitely many streaks of Heads overflowing any arbitrary non-infinite buffer)
As you guys can't reproduce the problem, it makes it hard to keep justifying my claim.
I can't think of any way how ingredients of quality accidentally spilled in our out the requester chest, so that nags me a bit. The requester chest never received ingredients of quality, the requester chest never trashed ingredients, and at least not only specific ones. Furthermore, I have an exact duplicate of combinator this set-up for bulk inserters and the same thing is happening there too (see save game). (Again with an under representation of advanced circuits for most qualities)
I guess, as long as no dev responds or ask for more information I'll accept it has to be random variance or an oversight by me.
(I do hope it's a oversight by me or a bug, and not variance. In that case, hopefully some day, it will be fixed/resolved by me or the devs. As it's rather annoying you can't make a craft/recycler loop using a single chest and combinators, without it clogging up. which I think is fairly sexy.)
Re: [2.0.23] Recycler returns disproportionate amount of ingredients over a long time
At random, the numbers you're looking at should not even out over time. They should grow proportionally to the square root of the number of crafts.
If you do something N times, each time has a probability p of success, and you see X successes, you do expect to see that X/N is very close to p. That is, the relative error between X and p*N will be small.
However, the absolute error will usually be big: you can expect the number (X - p*N) to be on the order of sqrt(N) in size.
If you do something N times, each time has a probability p of success, and you see X successes, you do expect to see that X/N is very close to p. That is, the relative error between X and p*N will be small.
However, the absolute error will usually be big: you can expect the number (X - p*N) to be on the order of sqrt(N) in size.
Re: [2.0.23] Recycler returns disproportionate amount of ingredients over a long time
Thanks, now you explained it, this actually makes a lot of sense. Men the implications kinda suck, it means all these self contained up-cycle systems will therefore clog up at some point. That's just random processes for you. I guess I have to build in a way to remove excess materials. Or abandon these self contained up-cyclers all together and tackle quality differently.)Hurkyl wrote: ↑Mon Dec 02, 2024 11:03 am At random, the numbers you're looking at should not even out over time. They should grow proportionally to the square root of the number of crafts.
If you do something N times, each time has a probability p of success, and you see X successes, you do expect to see that X/N is very close to p. That is, the relative error between X and p*N will be small.
However, the absolute error will usually be big: you can expect the number (X - p*N) to be on the order of sqrt(N) in size.
Re: [2.0.23] Recycler returns disproportionate amount of ingredients over a long time
Thanks for the report however I do not believe there is any bug here as I have not seen anyone show a deterministic issue with specific recycling recipes over long periods of test cycles. Random is random, and people interpret that in the short term as unbalanced.
If you want to get ahold of me I'm almost always on Discord.
- eradicator
- Smart Inserter
- Posts: 5210
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: [2.0.23] Recycler returns disproportionate amount of ingredients over a long time
Have you tried a non-quality 300% productivity blue circuit recycling loop? In theory 400% output should exactly cancel out 25% recycling. Seeded with 100 blue circuits and no external inputs my loop stopped after only 2400 cycles with only green circuits left. If the ratios were correct it should run indefinetly, or at least end up empty, not with a large amount of a single resource. This is just an example though, I've seen the effect on all my quality loops (some with 200k cycles): Ingredients with low input count in the original recipe are returned at less than 25%, leading to an overflow of the other stuff.Rseding91 wrote: ↑Tue Dec 03, 2024 4:25 pm Thanks for the report however I do not believe there is any bug here as I have not seen anyone show a deterministic issue with specific recycling recipes over long periods of test cycles. Random is random, and people interpret that in the short term as unbalanced.
Re: [2.0.23] Recycler returns disproportionate amount of ingredients over a long time
Thank you for your time.Rseding91 wrote: ↑Tue Dec 03, 2024 4:25 pm Thanks for the report however I do not believe there is any bug here as I have not seen anyone show a deterministic issue with specific recycling recipes over long periods of test cycles. Random is random, and people interpret that in the short term as unbalanced.
Yes, I agree, my intuition was misleading me here.
Last edited by Visione on Tue Dec 03, 2024 10:24 pm, edited 1 time in total.
Re: [2.0.23] Recycler returns disproportionate amount of ingredients over a long time
(Preface to this post: if you know what a random walk is and understand why a random walk won't always stay very close to 0, you can skip reading this. This is what I hope is a helpful explanation for eradicator and anyone else that's still figuring out how recyclers work)
A recycler returns 25% of the material needed to craft a single item, and when that's a fraction, it randomizes the fractional part. For example, combinators take 5 wire to make, so a recycler tries to output 1.25 wires. It can't actually output 1.25 wires though, so instead, it always outputs a wire, and then it gives you a 25% chance of getting an additional wire.
This is NOT the same as a 25% chance of a wire, five times - it is not possible for you to get very lucky and get all five wires back, nor is it possible for you to get very unlucky and get zero wires back. And when an input is divisible by 4, for example blue chips take 20 green chips to make, it will always return 5 green chips, no random chance.
It is also NOT the same as getting exactly 25% of the input back. One blue chip takes two red chips to make, so recycling a blue chip gives a 50% chance of a red chip. If you recycle two blue chips, now you have a 50% chance of a red chip, twice. You will *probably* get back 1 red chip, but you *might* get back 0 or 2. Just like if you flip a coin twice, you will *probably* see 1 land on heads, but you *might* see 0 or 2 heads.
However, over a long time period, after flipping a coin 100,000 times, you probably *won't* see exactly 50,000 heads. You might see 50,114 heads. You might see 49,983 heads. That means that you might have 114 more of an item than you expected, or you might have 17 fewer than you expected. Too many and your chest can get clogged (like the OP of this thread), too few and you run out of red chips (like eradicator). This isn't a bug with the recycler random number generation, it is just what happens over long enough time spans with randomness. Recycler setups either need to have larger buffers, so it can go a longer period of time before it clogs, or need to have a way to get rid of excess material caused by the number of heads not exactly equaling the number of tails.
A recycler returns 25% of the material needed to craft a single item, and when that's a fraction, it randomizes the fractional part. For example, combinators take 5 wire to make, so a recycler tries to output 1.25 wires. It can't actually output 1.25 wires though, so instead, it always outputs a wire, and then it gives you a 25% chance of getting an additional wire.
This is NOT the same as a 25% chance of a wire, five times - it is not possible for you to get very lucky and get all five wires back, nor is it possible for you to get very unlucky and get zero wires back. And when an input is divisible by 4, for example blue chips take 20 green chips to make, it will always return 5 green chips, no random chance.
It is also NOT the same as getting exactly 25% of the input back. One blue chip takes two red chips to make, so recycling a blue chip gives a 50% chance of a red chip. If you recycle two blue chips, now you have a 50% chance of a red chip, twice. You will *probably* get back 1 red chip, but you *might* get back 0 or 2. Just like if you flip a coin twice, you will *probably* see 1 land on heads, but you *might* see 0 or 2 heads.
However, over a long time period, after flipping a coin 100,000 times, you probably *won't* see exactly 50,000 heads. You might see 50,114 heads. You might see 49,983 heads. That means that you might have 114 more of an item than you expected, or you might have 17 fewer than you expected. Too many and your chest can get clogged (like the OP of this thread), too few and you run out of red chips (like eradicator). This isn't a bug with the recycler random number generation, it is just what happens over long enough time spans with randomness. Recycler setups either need to have larger buffers, so it can go a longer period of time before it clogs, or need to have a way to get rid of excess material caused by the number of heads not exactly equaling the number of tails.
Re: [2.0.23] Recycler returns disproportionate amount of ingredients over a long time
Hiya, so, I think that what we are both witnessing and considered to be incorrect, based on our intuition, is actually something that we should expect. The key is in what Hurkyl posted:eradicator wrote: ↑Tue Dec 03, 2024 6:53 pmHave you tried a non-quality 300% productivity blue circuit recycling loop? In theory 400% output should exactly cancel out 25% recycling. Seeded with 100 blue circuits and no external inputs my loop stopped after only 2400 cycles with only green circuits left. If the ratios were correct it should run indefinetly, or at least end up empty, not with a large amount of a single resource. This is just an example though, I've seen the effect on all my quality loops (some with 200k cycles): Ingredients with low input count in the original recipe are returned at less than 25%, leading to an overflow of the other stuff.Rseding91 wrote: ↑Tue Dec 03, 2024 4:25 pm Thanks for the report however I do not believe there is any bug here as I have not seen anyone show a deterministic issue with specific recycling recipes over long periods of test cycles. Random is random, and people interpret that in the short term as unbalanced.
We both think that the returned ratio of the input ingredients should stay proportional to the input ingredients of the recipe once we start recycling products. The key factor is that we are thinking in relative terms here, which we both probably didn't realize. relatively speaking, the input ingredients should stay roughly proportional to the ingredients of the recipe. However, whatever we are measuring, in for example my chest, and you in your system, are not relative differences, but absolute differences. And the absolute difference, might end up to be rather big over time.Hurkyl wrote: ↑Mon Dec 02, 2024 11:03 am At random, the numbers you're looking at should not even out over time. They should grow proportionally to the square root of the number of crafts.
If you do something N times, each time has a probability p of success, and you see X successes, you do expect to see that X/N is very close to p. That is, the relative error between X and p*N will be small.
However, the absolute error will usually be big: you can expect the number (X - p*N) to be on the order of sqrt(N) in size.
So lets say we we recycle 1M normal blue circuits, 75% is lost, 25% is returned, of that ~25% becomes uncommon (it's actually 24.8% but lets use 25, as it's easy). Lets assume "random" was perfect for a moment and we end up with 125.000 uncommon red circuits and 1.250.000 uncommon green circuits. (1M * 0.25 * ~0.25, that multiplied by either 2 or 20 for red and green circuits respectively.) If that is the case, we end up with the expected ratio of a factor 10. Exactly the proportionals between the input ingredients of the blue circuit. However, lets now say we instead get 125.000 uncommon red circuits and 1.262.500 uncommon green circuits back. The ratio of the input ingredients is now a factor 10.1. That's not crazy far of from the expected ratio of 10. And only an deviation of 1%. However, now we have an overflow of 12.500 green circuits. This is what we are witnessing.
I do not completely understand yet why we mostly see over-abundance almost always in favour for the ingredient that is over represented in the recipe.
Disclaimer: I'm still not subject expert on statistics, but this is what I think Hurkyl meant in laymen's terms.
Last edited by Visione on Tue Dec 03, 2024 10:38 pm, edited 5 times in total.
Re: [2.0.23] Recycler returns disproportionate amount of ingredients over a long time
Well, large buffers are apparently not working The error just keeps growing.
Re: [2.0.23] Recycler returns disproportionate amount of ingredients over a long time
"larger buffers, so it can go a longer period of time before it clogs"
Getting rid of excess material is the solution to an uncloggable recycler setup. But a larger buffer might be good enough for people that only need it to produce a limited amount of items. In the coin flip analogy, a buffer that only gets stuck after a surplus of 500 heads is better than a buffer that gets stuck after a surplus of 100 heads. But at some point, if you keep flipping coins, you'll eventually be more than 500 off the 'expected' amount of heads.
Getting rid of excess material is the solution to an uncloggable recycler setup. But a larger buffer might be good enough for people that only need it to produce a limited amount of items. In the coin flip analogy, a buffer that only gets stuck after a surplus of 500 heads is better than a buffer that gets stuck after a surplus of 100 heads. But at some point, if you keep flipping coins, you'll eventually be more than 500 off the 'expected' amount of heads.
Re: [2.0.23] Recycler returns disproportionate amount of ingredients over a long time
In the bulk inserter example, you are about equally likely to be +50 or -50 red circuits from the expected value. When you are at +50 red circuits, you see 50 red circuits in the chest. When you are -50 red circuits, you see 750 green circuits and 750 gears in the chest. So over-abundances of the over-represented items are very noticeable, while an equally likely over-abundance of red circuits is easily ignored.