Factory Calculations using Sparse Linear Solvers

As we all know, factory calculations tend to slow down a lot. Of course, I have no clue how the implementation is currently done, but in my naive interpretation of the problem I believe it is possible to calculate factory ratios using highly optimised and well-studied numerical algorithms.

If sparse linear solvers or something equivalent are already implemented, or if their implementation was considered but ultimately deemed unfeasible, this thread can be closed and my foolishness shall linger here forever. If they were not considered, however, what follows is my best argumentation for why they might just work:

On the most fundamental level, the factory computations boil down to “all the production of X should be enough to satisfy all the consumption of X”. Such relations can be represented as linear equations, e.g. ax1 + bx2 = cx3 + dx4 + ex5 (where a, b, c, d, e are ratios derived from things like recipes, somerslooping etc. and x1, x2, … would probably either represent required production rate for a connection between machines or number of machines or equivalent). I have personally not investigated the influence of things like priority splurgers or the different kinds of storage containers, but if they cannot be formulated as linear equalities, perhaps Constrained Linear Optimizers are the next place to look.

In a very large factory plan, there might be tens and tens of different machines with hundreds of connections, all of which are entangled with hundreds of these linear relations. Together, they form a linear system. Such a system might be under- or over-constrained, depending on how many conditions on production rates (hard-coded item rates) are added by the user. Still, I believe that factory nerds have a decent intuition for how much information is needed to make the problem solvable, and if not, perhaps adding a little infobox about too few or too many constraints is fine too (some systems might also be sufficiently constrained but unsolvable due to weird setup).

In general, linear systems with arbitrarily many variables are notoriously difficult to solve, with the standard reduction algorithm of time complexity O(n³). In general, this should still be feasible for n as big as a couple hundred, thought it might take same time. However, we can make a key observation: most variables are only directly coupled to a few other variables, and in general do NOT couple with every other variable, in a sense that they will not appear in the same equation. After all, a manufacturer has at most five connections, which is far fewer than the total of hundreds of different connections for big factories. This means that the linear system is “sparse”, which is a very desirable property. Extremely robust iterative numerical solvers exist for finding solutions to sparse linear systems. While they don’t generate exact solutions, I am confident that 2 or 3 decimal places is plenty enough for factory building.

Either way, if it turns out that sparse solvers can’t be used, I would love to hear why that’s the case. And if it turns out they can, I would be more than thrilled.

Please authenticate to join the conversation.

Upvoters
Status

In Review

Board
💡

Suggestion

Date

3 months ago

Author

Julek AK

Subscribe to post

Get notified by email when there are changes.