Tutorial:Quality upcycling math

From Official Factorio Wiki
Revision as of 17:34, 23 November 2024 by Untitled7 (talk | contribs) (Created page with "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 == {| class="wikitable" ! Crafting mac...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.

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.

Crafting machine Modules in Tier 1 Modules in Tier 2 Modules in Tier 3 Modules in Tier 4 Modules in Tier 5 Percentage yield of legendary items
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.344%
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.586%
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.624%
Electromagnetic plant 1 quality / 4 productivity 1 quality / 4 productivity 1 quality / 4 productivity 1 quality / 4 productivity 0 quality / 5 productivity 2.722%
Cryogenic plant 0 quality / 8 productivity 0 quality / 8 productivity 0 quality / 8 productivity 0 quality / 8 productivity 0 quality / 8 productivity 4.835%

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 0.863 0.100 0.029 0.0078 0.0023
Assembling machine 3 1 0.829 0.121 0.039 0.0115 0.0036
Foundry 1 0.744 0.167 0.065 0.024 0.008
Electromagnetic plant 1 0,688 0.193 0.083 0.035 0.010
Cryogenic plant 1 0.603 0.231 0.112 0.054 0.013

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 434.591 374.913 43.537 12.756 3.386 1
Assembling machine 3 280.8301 232.703 33.934 10.950 3.243 1
Foundry 131.090 97.587 21.831 8.516 3.155 1
Electromagnetic plant 95.471 65.696 18.456 7.945 3.375 1
Cryogenic plant 78.727 47.435 18.212 8.814 4.265 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 368 318 37 11 3 1
Assembling machine 3 247 205 30 10 3 1
Foundry 119 89 20 8 3 1
Electromagnetic plant 81 56 16 7 3 1
Cryogenic plant 68 41 16 8 4 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 375 350 40 10 4 1
Assembling machine 3 250 200 30 10 4 1
Foundry 120 90 20 8 4 1
Electromagnetic plant 80 60 16 8 4 1
Cryogenic plant 64 48 16 8 4 1