Understanding ratios in Factorio is crucial for building efficient and scalable factories. Whether you’re aiming for a perfectly balanced science production line or optimizing your smelting setup, grasping the underlying math and principles of ratios will significantly enhance your gameplay. This guide delves into the essential concepts behind Factorio ratios, explaining how they work and why they are so important for automation and resource management.
The Foundation: Recipes as Equations
At its core, calculating ratios in Factorio involves understanding recipes as mathematical equations. Each recipe defines how many input resources are needed to produce a certain amount of output items. Let’s start with a simple example: crafting Red Science Packs.
According to the recipes:
1 Red Science Pack = 1 Iron Gear + 1 Copper Plate
1 Iron Gear = 2 Iron Plate
To determine the raw resource requirement for one Red Science Pack, we can substitute the second equation into the first:
1 Red Science Pack = 2 Iron Plate + 1 Copper Plate
This simple equation tells us that to create one Red Science Pack, you need 2 Iron Plates and 1 Copper Plate. This is the fundamental ratio for Red Science production in terms of raw resources.
Let’s consider a slightly more complex example: Green Science Packs.
1 Green Science Pack = 1 Inserter + 1 Yellow Belt
1 Inserter = 1 Green Circuit + 1 Iron Gear + 1 Iron Plate
2 Yellow Belt = 1 Iron Gear + 1 Iron Plate
1 Green Circuit = 3 Copper Cable + 1 Iron Plate
2 Copper Cable = 1 Copper Plate
By systematically substituting and simplifying these equations, we can break down the Green Science Pack recipe into its basic resource requirements. This process, while potentially tedious manually for complex recipes, is the algorithmic foundation for Factorio calculators. These tools automate the substitution and simplification process, allowing players to quickly understand the resource ratios for any item in the game.
Scaling Production Over Time
While knowing the resource ratio per item is useful, in Factorio, we often need to think in terms of production rates over time, such as items per minute or items per second. To convert our item-based ratios to time-based ratios, we need to consider crafting times.
For example, Red Science Packs take 5 seconds to craft in an Assembler. Therefore, to find the per-second ratio, we divide our previous equation by the crafting time:
(1/5) Red Science Pack per second = (1/5) Iron Gear per second + (1/5) Copper Plate per second
Assemblers and other production buildings also have crafting speeds that affect these ratios. Furthermore, modules like Speed Modules increase crafting speed, requiring adjustments to the ratios to maintain balance. Productivity Modules, on the other hand, introduce a non-linear effect by increasing output without proportionally increasing input, making them incredibly efficient for resource utilization but also complicating ratio calculations.
Linear Algebra and Recipe Ratios
Stepping back and looking at the bigger picture, we can see that calculating Factorio ratios is essentially solving a system of linear equations. Each recipe represents an equation, and each item is a variable. This system can be represented using linear algebra, specifically with matrices.
Imagine a matrix where each column represents a recipe and each row represents an item. The values within the matrix indicate how much of each item is consumed (negative value) or produced (positive value) by a particular recipe. This is often referred to as the “recipe matrix.”
By using linear algebra techniques, we can solve for the number of machines needed (represented as a vector ‘x’) to achieve a desired output rate of final products (represented as a vector ‘b’). The equation we aim to solve is Ax = b, where ‘A’ is the recipe matrix.
In practice, the recipe matrix in Factorio is nearly “triangular,” which simplifies the solution process. The algorithmic substitution method described earlier is a way to solve these sparse triangular matrices efficiently.
Linear Programming for Optimization
However, Factorio introduces a complication that prevents a purely triangular matrix: oil and uranium processing. These processes create loops in the production chain, meaning we cannot always perfectly satisfy all output demands simultaneously. For example, you can’t demand 10 heavy oil per second and zero petroleum gas per second, as their production is interconnected.
This necessitates shifting from solving Ax = b to Ax ≥ b, meaning we aim to meet or exceed the desired output ‘b’. With inequalities, there can be multiple solutions, and we often want to find the best solution. This is where linear programming comes in.
Linear programming helps us find the optimal solution by minimizing a “cost function,” represented as c·x, where ‘c’ is a cost vector. In Factorio, a reasonable cost function could be power consumption or raw resource usage. Linear programming also inherently includes the constraint that x ≥ 0, which makes sense as we can’t have negative factories.
Therefore, the most accurate way to calculate optimal ratios in Factorio, especially for complex production chains like oil processing, is to use linear programming. This involves creating a linear program with the recipe matrix, desired production rates, and a cost vector, and then using specialized solvers to find the optimal solution.
Oil Processing Ratios: A Practical Example
The complexity of oil processing ratios highlights the power of linear programming. In vanilla Factorio, the oil processing sub-system has 8 recipes producing 4 outputs (solid fuel, heavy oil, light oil, and petroleum gas). Linear programming reveals that at any optimal solution “vertex,” only 4 of these 8 recipes will be actively used.
Considering that producing solid fuel requires one recipe and basic oil refining is essential, this limitation implies choices. You might prioritize cracking both heavy and light oil (using two cracking recipes) while converting only one oil type to solid fuel. Alternatively, you might choose to convert multiple oil types to solid fuel and forgo cracking some oil types depending on your needs and resource balance.
Conclusion: Ratios are Key to Factorio Mastery
Understanding and applying ratios is fundamental to efficient factory design in Factorio. From simple science production to complex oil processing, grasping these mathematical relationships allows you to optimize resource utilization, scale production effectively, and ultimately, achieve greater automation and factory efficiency. While manual calculations can become complex, especially for advanced recipes, tools and calculators leverage these underlying principles to simplify ratio planning and empower you to build truly optimized Factorio factories.