Tutorial:Quality upcycling math
How do we get the most amount of legendary items out of an upcycling plant?
The answer is not quite as straight forward as we'd like it to be, because it depends on a number of factors, luckily there is a finite number of possibilities of what the modules can be, and for the sake of simplicity this tutorial will ignore the productivity gain from infinite technologies.
The crafting machines
Crafting machine | Module slots | Base productivity bonus |
---|---|---|
Chemical plant | 3 | +0% |
Assembling machine 3 | 4 | +0% |
Foundry | 4 | +50% |
Electromagnetic plant | 5 | +50% |
Cryogenic plant | 8 | +0% |
Quality probability
When an item gets produced and the initial roll decides that the quality of the item will increase, there is a 90% chance it will rise one tier, a 9% chance it will rise two, a 0.9% chance it will rise three, and a 0.1% chance it will rise four. This is of course capped if the item already started out at a higher tier.
Mathematical model
The mathematical model is time discrete. As opposed to dealing with derivatives in respect to time, the next state is a direct function of the previous state.
- ... Number of materials of tier after the -th iteration before being crafted. (this doesn't mean that an item only needs one type of ingredient, but that "1 materials" can be crafted into 1 item from them)
- ... Number of items of tier after the -th iteration, after being crafted together.
- ... the crafting machines inherent productivity bonus
- ... number of modules the crafting machine can hold
- ... quality probability of the recyclers with 4 quality module 3's
- ... productivity due to legendary productivity module 3's in the crafting machine which takes -tier materials
- ... quality probability due to legendary quality module 3's in the crafting machine which takes -tier materials
Recycled materials
When a quarter of all items being recycled and the quality probability rules we can write the equations for the amount of materials received after recycling. This calculation is rather simple, as we the lowest tier can only come forth from it's own tier failing to raise in quality. The second tier are 90% of tier 1 items that did increase, and all those tier 2 items that didn't. This continues for all tiers as follows, but legendary items will not be recycled
which can also be written as a vector-matrix-multiplication
As we assume there is nothing to be done about recyclers to make them more effective but fill them with all quality modules, the value of is a constant, and therefore the matrix is also a constant. For legendary quality module 3's, it looks like:
Recrafted items
Once more we first check how many items are produced, which is, again, the sum of all possible ways to get to a tier, this time adding productivity , and bringing along all those items which are already legendary
This can once more be written as a vector-matrix-multiplication
Combined model
As such we gain an equation for the amount of items for every tier after any amount of iterations
A realistic starting point for is only items in tier 1, and if we do not care for any other tiers, we simply choose sufficiently large , and, through numeric means, try to maximize a single value. , which falls in the fifth row, first column, of the Matrix raised to the 100th power.
The choice of optimization method (simplex, branch and bound, etc.) itself is irrelevant, although most software will want the problem to be stated in a way so it can find a minimum, and may require the proper guard rails as to not pick values below 0 or higher than the maximum number of allowed modules.
Best ratios
This table shows the best ratio for quality to productivity modules in the crafting machines, while the recyclers always take only quality modules. The values are not given in whole numbers because often it is not just a single crafting machine per tier that will be used, then the ratios can change between different crafting machines in the same tier. e.g. "3.67 quality / 1.33 productivity" could have 4 machines where 3 have a ratio 4 to 1, and one a ratio 3 to 2.
"Modules in Tier X" means which Modules need to go into the machines that are set to produce the item at tier X.
Crafting machine | Modules in Tier 1 | Modules in Tier 2 | Modules in Tier 3 | Modules in Tier 4 | Modules in Tier 5 | percentage yield | items recycled* |
---|---|---|---|---|---|---|---|
Chemical plant | 3 quality 0 productivity |
3 quality 0 productivity |
3 quality 0 productivity |
3 quality 0 productivity |
0 quality 3 productivity |
0.034014% | 2940 |
Assembling machine 3 | 4 quality 0 productivity |
4 quality 0 productivity |
4 quality 0 productivity |
4 quality 0 productivity |
0 quality 4 productivity |
0.046275% | 2161 |
Foundry | 4 quality 0 productivity |
4 quality 0 productivity |
4 quality 0 productivity |
4 quality 0 productivity |
0 quality 4 productivity |
0.133814% | 747 |
Electromagnetic plant | 5 quality 0 productivity |
5 quality 0 productivity |
5 quality 0 productivity |
5 quality 0 productivity |
0 quality 5 productivity |
0.176712% | 566 |
Cryogenic plant | 6 quality 2 productivity |
6 quality 2 productivity |
6 quality 2 productivity |
6.5 quality 1.5 productivity |
0 quality 8 productivity |
0.119134% | 840 |
"Modules in Tier X" means which Modules need to go into the machines that are set to produce the item at tier X.
Crafting machine | Modules in Tier 1 | Modules in Tier 2 | Modules in Tier 3 | Modules in Tier 4 | Modules in Tier 5 | percentage yield | items recycled* |
---|---|---|---|---|---|---|---|
Chemical plant | 3 quality 0 productivity |
3 quality 0 productivity |
3 quality 0 productivity |
3 quality 0 productivity |
0 quality 3 productivity |
0.059498% | 1681 |
Assembling machine 3 | 3.75 quality 0.25 productivity |
3.75 quality 0.25 productivity |
3.8 quality 0.2 productivity |
3.9 quality 0.1 productivity |
0 quality 4 productivity |
0.082296% | 1216 |
Foundry | 4 quality 0 productivity |
4 quality 0 productivity |
4 quality 0 productivity |
4 quality 0 productivity |
0 quality 4 productivity |
0.243699% | 410 |
Electromagnetic plant | 4.7 quality 0.3 productivity |
4.67 quality 0.33 productivity |
4.75 quality 0.25 productivity |
4.9 quality 0.1 productivity |
0 quality 5 productivity |
0.324189% | 309 |
Cryogenic plant | 4.6 quality 3.4 productivity |
4.6 quality 3.4 productivity |
4.67 quality 3.33 productivity |
5 quality 3 productivity |
0 quality 8 productivity |
0.257621% | 389 |
"Modules in Tier X" means which Modules need to go into the machines that are set to produce the item at tier X.
Crafting machine | Modules in Tier 1 | Modules in Tier 2 | Modules in Tier 3 | Modules in Tier 4 | Modules in Tier 5 | percentage yield | items recycled* |
---|---|---|---|---|---|---|---|
Chemical plant | 2.8 quality 0.2 productivity |
2.8 quality 0.2 productivity |
2.9 quality 0.1 productivity |
2.9 quality 0.1 productivity |
0 quality 3 productivity |
0.100660% | 994 |
Assembling machine 3 | 3 quality 1 productivity |
3.1 quality 0.9 productivity |
3.2 quality 0.8 productivity |
3.33 quality 0.67 productivity |
0 quality 4 productivity |
0.145220% | 689 |
Foundry | 3.5 quality 0.5 productivity |
3.5 quality 0.5 productivity |
3.6 quality 0.4 productivity |
3.9 quality 0.1 productivity |
0 quality 4 productivity |
0.424039% | 236 |
Electromagnetic plant | 3.6 quality 1.4 productivity |
3.6 quality 1.4 productivity |
3.6 quality 1.4 productivity |
3.9 quality 1.1 productivity |
0 quality 5 productivity |
0.588510% | 170 |
Cryogenic plant | 3.6 quality 4.4 productivity |
3.6 quality 4.4 productivity |
3.6 quality 4.4 productivity |
3.9 quality 4.1 productivity |
0 quality 8 productivity |
0.565030% | 177 |
"Modules in Tier X" means which Modules need to go into the machines that are set to produce the item at tier X.
Crafting machine | Modules in Tier 1 | Modules in Tier 2 | Modules in Tier 3 | Modules in Tier 4 | Modules in Tier 5 | percentage yield | items recycled* |
---|---|---|---|---|---|---|---|
Chemical plant | 2.33 quality 0.67 productivity |
2.4 quality 0.6 productivity |
2.4 quality 0.6 productivity |
2.4 quality 0.6 productivity |
0 quality 3 productivity |
0.152486% | 656 |
Assembling machine 3 | 2.5 quality 1.5 productivity |
2.5 quality 1.5 productivity |
2.6 quality 1.4 productivity |
2.8 quality 1.2 productivity |
0 quality 4 productivity |
0.232966% | 430 |
Foundry | 2.7 quality 1.3 productivity |
2.7 quality 1.3 productivity |
2.75 quality 1.25 productivity |
3 quality 1 productivity |
0 quality 4 productivity |
0.664130% | 151 |
Electromagnetic plant | 2.6 quality 2.4 productivity |
2.6 quality 2.4 productivity |
2.67 quality 2.33 productivity |
2.9 quality 2.1 productivity |
0 quality 5 productivity |
0.974700% | 103 |
Cryogenic plant | 2.6 quality 5.4 productivity |
2.6 quality 5.4 productivity |
2.6 quality 4.4 productivity |
2.8 quality 4.2 productivity |
0 quality 8 productivity |
1.122444% | 90 |
"Modules in Tier X" means which Modules need to go into the machines that are set to produce the item at tier X.
Crafting machine | Modules in Tier 1 | Modules in Tier 2 | Modules in Tier 3 | Modules in Tier 4 | Modules in Tier 5 | percentage yield | items recycled* |
---|---|---|---|---|---|---|---|
Chemical plant | 1.67 quality 1.33 productivity |
1.67 quality 1.33 productivity |
1.67 quality 1.333 productivity |
1.8 quality 1.2 productivity |
0 quality 3 productivity |
0.344061% | 291 |
Assembling machine 3 | 1.67 quality 2.33 productivity |
1.67 quality 2.33 productivity |
1.67 quality 2.33 productivity |
1.8 quality 2.2 productivity |
0 quality 4 productivity |
0.586191% | 171 |
Foundry | 1.4 quality 2.6 productivity |
1.4 quality 2.6 productivity |
1.4 quality 2.6 productivity |
1.5 quality 2.5 productivity |
0 quality 4 productivity |
1.624266% | 62 |
Electromagnetic plant | 1 quality 4 productivity |
1 quality 4 productivity |
1 quality 4 productivity |
1 quality 4 productivity |
0 quality 5 productivity |
2.722332% | 37 |
Cryogenic plant | 0 quality 8 productivity |
0 quality 8 productivity |
0 quality 8 productivity |
0 quality 8 productivity |
0 quality 8 productivity |
4.835199% | 21 |
Number of crafting machines
If we assume a constant input stream of tier 1 items which will always fill back up, we can additionally figure out what ratio of items will be inside the system at once, and with that we can figure out how many crafting machines we need per tier. This is done by setting after each iteration.
Crafting machine | Recyclers | Machines producing Tier 1 items | Machines producing Tier 2 items | Machines producing Tier 3 items | Machines producing Tier 4 items | Machines producing Tier 5 items |
---|---|---|---|---|---|---|
Chemical plant | 1 | 3.4427 | 0.0290 | 1.0086 | 0.0077 | 0.2979 |
Assembling machine 3 | 1 | 3.3027 | 0.0365 | 1.0657 | 0.0108 | 0.3286 |
Foundry | 1 | 2.9551 | 0.0563 | 1.1528 | 0.0208 | 0.3653 |
Electromagnetic plant | 1 | 2.7239 | 0.0709 | 1.1726 | 0.0301 | 0.3474 |
Cryogenic plant | 1 | 2.3798 | 0.0972 | 1.1517 | 0.0470 | 0.2700 |
Crafting machine | Recyclers | Machines producing Tier 1 items | Machines producing Tier 2 items | Machines producing Tier 3 items | Machines producing Tier 4 items | Machines producing Tier 5 items |
---|---|---|---|---|---|---|
Chemical plant | 108.8978 | 374.9134 | 43.5367 | 12.7555 | 3.3856 | 1 |
Assembling machine 3 | 70.4576 | 232.7032 | 33.9340 | 10.9500 | 3.2432 | 1 |
Foundry | 33.0224 | 97.5872 | 21.8308 | 8.5164 | 3.1550 | 1 |
Electromagnetic plant | 24.1178 | 65.6959 | 18.4556 | 7.9448 | 3.3747 | 1 |
Cryogenic plant | 19.9316 | 47.4350 | 18.2124 | 8.8138 | 4.2654 | 1 |
Crafting machine | Recyclers | Machines producing Tier 1 items | Machines producing Tier 2 items | Machines producing Tier 3 items | Machines producing Tier 4 items | Machines producing Tier 5 items |
---|---|---|---|---|---|---|
Chemical plant | 92 | 318 | 37 | 11 | 3 | 1 |
Assembling machine 3 | 62 | 205 | 30 | 10 | 3 | 1 |
Foundry | 30 | 89 | 20 | 8 | 3 | 1 |
Electromagnetic plant | 20 | 56 | 16 | 7 | 3 | 1 |
Cryogenic plant | 17 | 41 | 16 | 8 | 4 | 1 |