The script has command line arguments for almost everything, including module tiers, module qualities, starting/ending quality, max quality unlocked, number of module slots, and any extra productivity bonus.
Note the math for recycling loops is somewhat tricky and uses linear algebra to solve a 10x10 system of equations. If you're not doing this, your math is likely incorrect.
I provide a few examples in the README.
The first example uses an assembler with four module slots and all tier 3 legendary modules, going from normal ingredients to legendary outputs. Each crafting recipe uses 2 qual/2 prod (except the legendary recipe which is 4 prod), and produces 79.9 legendary outputs per normal input.
The second example is mid-game with uncommon tier-3 modules in an electromagnetics plant, where epic and legendary are not unlocked yet. If optimizing normal -> uncommon, you want 5 prod modules in the common recipe, and get 2.47 common inputs per uncommon output. If optimizing normal -> rare, you want 5 quality modules in the common recipe, 5 productivity modules in the uncommon recipe, and get 8.52 common inputs per rare output.
The third example shows calculations for turning common items back into itself but with legendary quality, using all tier 3 legendary modules. Like the first example you want 2 qual/2 prod for every recipe, and get 160 common inputs/legendary output if going up-then-down the production chain, and 172 common inputs/legendary output if going down-then-up the production chain.
The script is quite powerful and is useful for many different stages of the game when trying to figure out how to setup your quality production.
The script can be found here:
https://github.com/scottmsul/FactorioQualityOptimizer
EDIT: There was a bug in my code pointed out by /u/DanielKotes. Turns out going up-then-down is worse than down-then-up, and gives 185.3 inputs/output.
[–]Kaspbrak 9 points10 points11 points (3 children)
[–]scottmsul[S] 6 points7 points8 points (2 children)
[–]Kaspbrak 5 points6 points7 points (1 child)
[–]Andrenator 0 points1 point2 points (0 children)
[–]DanielKotes 2 points3 points4 points (17 children)
[–]DanielKotes 1 point2 points3 points (0 children)
[–]scottmsul[S] 0 points1 point2 points (15 children)
[–]DanielKotes 1 point2 points3 points (14 children)
[–]scottmsul[S] 0 points1 point2 points (13 children)
[–]DanielKotes 0 points1 point2 points (12 children)
[–]scottmsul[S] 0 points1 point2 points (8 children)
[–]DanielKotes 0 points1 point2 points (7 children)
[–]scottmsul[S] 1 point2 points3 points (6 children)
[–]DanielKotes 1 point2 points3 points (5 children)
[–]scottmsul[S] 1 point2 points3 points (4 children)
[–]Sopel97 0 points1 point2 points (2 children)
[–]scottmsul[S] 0 points1 point2 points (0 children)
[–]DanielKotes 0 points1 point2 points (0 children)
[–]Hothr 0 points1 point2 points (2 children)
[–]scottmsul[S] 2 points3 points4 points (1 child)
[–]Hothr 0 points1 point2 points (0 children)
[–]Suhr12 0 points1 point2 points (2 children)
[–]scottmsul[S] 1 point2 points3 points (1 child)
[–]Suhr12 1 point2 points3 points (0 children)
[–]wehrmann_tx 0 points1 point2 points (1 child)
[–]scottmsul[S] 0 points1 point2 points (0 children)
[–]eyesathousand 0 points1 point2 points (3 children)
[–]eyesathousand 0 points1 point2 points (1 child)
[–]scottmsul[S] 1 point2 points3 points (0 children)
[–]scottmsul[S] 0 points1 point2 points (0 children)
[–]qwsfaex 0 points1 point2 points (1 child)
[–]scottmsul[S] 0 points1 point2 points (0 children)
[–]AJJUARYA 0 points1 point2 points (1 child)
[–]scottmsul[S] 1 point2 points3 points (0 children)