Quality

From Official Factorio Wiki
Revision as of 08:56, 9 December 2024 by Raw Salad (talk | contribs) (Added illustrative examples and explanations.)
Jump to navigation Jump to search

Optimal module usage

It is optimal to improve quality on the lead-up to the target output item due to the recycler only giving back 25% of the input items, except for cases where the chosen item has a productivity research available, in which case looping through a recycler is optimal and has no added material cost (ignoring fluids).

The following tables summarize the number of normal crafts (rounded up) needed to produce 1 legendary output using ideal ratios of Quality module 3s to Productivity module 3s, with 4 matching Quality module 3 in the recycler.

It is important to emphasize that these ratios maximize return per input material. If input capacity isn't a concern and the goal is speed rather than material efficiency, then switch out productivity modules for quality modules as needed. Beware, however, that in many cases material inefficiency nearly keeps pace with the legendary output rate.

Max Modules Base Prod. No. of
Productivity module 3.png
Rare
No. of
Quality module 3.png
Rare
Crafts
2 0% 0 2 891
3 0% 0 3 533
4 0% 1 3 342
4 50% 0 4 97
5 50% 1 4 67
8 0% 4 4 70
Max Modules Base Prod. No. of
Productivity module 3.png
Epic
No. of
Quality module 3.png
Epic
Crafts
2 0% 0 2 608
3 0% 1 2 356
4 0% 1 3 212
4 50% 1 3 62
5 50% 2 3 40
8 0% 5 3 34
Max Modules Base Prod. No. of
Productivity module 3.png
Legendary
No. of
Quality module 3.png
Legendary
Crafts
2 0% 0 2 309
3 0% 1 2 153
4 0% 2 2 80
4 50% 3 1 25
5 50% 4 1 14
8 0% 8 0 7
For example, suppose the goal is to produce
Processing unit.png
Legendary
and legendary T3 modules are available. If each electromagnetic plant producing epic quality or below has 1
Quality module 3.png
Legendary
and 4
Productivity module 3.png
Legendary
, and the electromagnetic plant with the legendary recipe has 5
Productivity module 3.png
Legendary
, then on average we expect 280
Electronic circuit.png
Normal
and 28
Advanced circuit.png
Normal
to produce 1
Processing unit.png
Legendary
.


Derivation

Derivation of the tables above was as follows: Starting with 1 set of common ingredients, with an assembly quality chance of Q and total productivity bonus of P, the statistical expected number of product is as follows:

Normal Uncommon Rare Epic Legendary
(1 + P) * (1 - Q) (1 + P) * (Q * (100 - 10-1)) (1 + P) * (Q * (10-1 - 10-2)) (1 + P) * (Q * (10-2 - 10-3)) (1 + P) * (Q * 10-3)
(1 + P) * (1 - Q) (1 + P) * Q * 9/10 (1 + P) * Q * 9/100 (1 + P) * Q * 9/1000 (1 + P) * Q * 1/1000

In a similar vein, the same calculations can be done for recycling products, except that there is, in effect, -75% productivity bonus, where only a quarter of the items are returned.

Normal Uncommon Rare Epic Legendary
(1 + -0.75) * (1-Q) (1 + -0.75) * (Q * (100 - 10-1)) (1 + -0.75) * (Q * (10-1 - 10-2)) (1 + -0.75) * (Q * (10-2 - 10-3)) (1 + -0.75) * (Q * 10-3)
0.25 * (1-Q) 0.25 * Q * 9/10 0.25 * Q * 9/100 0.25 * Q * 9/1000 0.25 * Q * 1/1000

For example, recycling an uncommon ingredient with a Q of 25%:

Output
Input
Normal Uncommon Rare Epic Legendary
Uncommon - 0.1875 0.05625 0.005625 0.000625

Combining these results allows a 'Transition Matrix' to be developed (see Stochastic Matrix on wikipedia) which after iteration can generate the expected number of legendary products from 1 set of common ingredients via matrix multiplication. An example matrix for P of 50% and Q of 25% for both recycling and assembly is copied below. Note that since legendary products are the goal, they are not recycled.

INormal IUncommon IRare IEpic ILegendary PNormal PUncommon PRare PEpic PLegendary
INormal 0 0 0 0 0 1.125 0.3375 0.03375 0.003375 0.000375
IUncommon 0 0 0 0 0 0 1.125 0.3375 0.03375 0.00375
IRare 0 0 0 0 0 0 0 1.125 0.3375 0.0375
IEpic 0 0 0 0 0 0 0 0 1.125 0.375
ILegendary 0 0 0 0 0 0 0 0 0 1.5
PNormal 0.1875 0.5625 0.005625 0.0005625 0.0000625 0 0 0 0 0
PUncommon 0 0.1875 0.05625 0.005625 0.000625 0 0 0 0 0
PRare 0 0 0.1875 0.05625 0.00625 0 0 0 0 0
PEpic 0 0 0 0.1875 0.0625 0 0 0 0 0
PLegendary 0 0 0 0 0 0 0 0 0 1

To iterate this matrix (M) apply the matrix to itself. For example, M6 would indicate 6 iterations, corresponding to 3 crafting steps and 3 recycling steps. To see how much 1 ingredient set produces after a given iteration, x, multiply an input vector by Mx. The vector format follows that of the matrix labels, so with the table arranged as above, left multiply a row vector of ingredient(s) by the matrix. If you want to see the product of 1 set of normal ingredients, then the vector will have '1' in the first column. Likewise, a set of uncommon ingredients will correspond to '1' in the second column of the vector.

It is important to note that since the recycling step has a material loss of 75% most recycling loops will be well behaved and converge quickly.
Extreme productivity from research breaks this pattern and will prevent convergence, but all this means is that there is a positive material cycle, so 1 set of ingredients will produce infinite legendary crafts, on average. The closer the total productivity is to 400%, the slower the convergence of the matrix iteration and the higher you need to calculate x in Mx.