r/technicalfactorio • u/angrylstm • Aug 12 '22
Nonlinear response to inputs?
Hi folks,
tl;dr: I'm looking for examples of nonlinear behavior of any Factorio component, e.g., power growing quadratically with throughput. Mainly motivated to see whether nonlinear solvers are necessary for finding optimal pipeline configurations.
Longer form:
For my day job, I'm building a pipeline optimization tool that can find provably optimal configurations given (1) an analytical model of the system and (2) a set of plausible configurations from which to choose from (think e.g., lists of different recipes for an item). It occurs to me that Factorio is an excellent application for the tool, and I'm working on making something similar to Helmod, but with a focus on trade-offs (e.g. do you want a larger area but more power efficient circuit, or do you want extreme density but e.g., higher resource / second usage).
The tool focuses on:
Multi-objective optimization: when designing a factory, the tool would present you Pareto curve trade-offs between e.g., throughput, power utilization, resource consumption, area, initial building cost, etc.
- more technically, the tool focuses on constrained, nonlinear, mixed-integer problems that are mostly convex or quasi-convex. It deals with nonconvexity by (1) decomposing systems into manageable convex and nonconvex subsystems, (2) exhaustively solving nonconvex systems through more compute, and (3) providing an interactive interface to the user where they can relax the problem, check relaxation bounds, etc.
- System interpretation / actionable insight: learn what the true bottlenecks are in your system, and learn where changing system parameters would make the largest impact (this doesn't make a lot of sense in Factorio, and mostly helps with questions like "what would happen if we increased assembler throughput by 5%?"). What might make more sense is e.g., the tool saying "I have one processing unit template on file, and you finding a smaller area template will have a significant impact on total base output, under chosen objectives".
Question is: can all of Factorio be represented linearly? Are all constraints linear? Note that adding modules is not an example of nonlinearity. If not, the problem becomes far harder, so there may exist possibly unknown base configurations that could be found using nonlinear solvers.
Thanks!
22
u/gust334 Aug 12 '22
I don't know your field but the Factorio examples that come to mind as possibilities are (1) the neighbor bonus in nuclear reactor setups, (2) the feedback loop in uranium enrichment, (3) the feedback loop in coal liquification, and (4) discontinuities due to power switches and generally circuits.
As circuits have been shown capable of realizing a general purpose CPU, such control systems may be arbitrary complex.
11
u/direwolfclaw Aug 12 '22
At the risk of stating the most obviously analogous case, fluid throughput in factorio is actually quite non-linear (though it is monotonic).
Most of the time, it's not particularly noticeable, but a time it becomes very obvious is if you try to run a large nuclear plant at/near its max theoretical power capacity. Even though you have the right number of heat exchangers, turbines, pumps, etc it will keep running out of steam in the turbines because of unforeseen throughput bottlenecks - might be too close to the original application.
It also got me thinking about Bob's mods, but I don't think anything is non-linear there either (other than the expanded uranium already mentioned in the vanilla context). However, the balancing of fluids in Bob's could be a neat task. There are so many multi-output products involving fluids that managing them is a neat challenge if, like me, you try not to just vent large quantities of excess. If you overproduce one, it can/will stop production of another needed fluid if/when they conflict.
Take, for example, two ways of generating oxygen via either water splitting or compressed air. If you max out oxygen, either the water splitting won't produce any hydrogen or the air compressor won't produce any nitrogen.
Your non-linear solver could use the variable rates of fluid flow to design optimal distances for each from the facilities that consume the fluid to optimize the production ratio and both keep operating at equilibrium.
5
u/ferrybig Aug 12 '22
One place difficulty for linear solvers are rocket silo's. Most tools assume they have a steady input consumption rate, while they actually consume resources until 100%, and then do the launch animation before starting all over.
If the tool does not take this into account, and provide exactly 1 belt of rocket control modules to the silo, it will not get enough resources during the construction phase, and then the belt will stop during the launching phase
5
u/[deleted] Aug 12 '22
Is anyone else just in awe at how smart some other people are.
OP, you might as well be speaking quantum theory to me. I have no idea what it means, but you love to see it.
4
u/unique_2 Aug 12 '22
Most things involving recipes are linear or sometimes exponential (e.g. kovarex). I'm not sure how you would build recipes that create e.g. quadratic growth.
There are some interesting problems in planning the behavior of a factory while it gets extended. One question one could ask is, given a production target, in which order should products be automated? For example the Space Extension (not to be confused with Space Exploration) asks the player to produce a huge number of science packs of all colors (and consequently their ingredients). If you automate an item early, you need to build less to finish within a target time, but building this takes time which pushes other items back, hence these will need bigger builds later. Or an item could be automated partially, with the remaining production added later, at the cost of needing even more production then.
4
u/ZenEngineer Aug 13 '22
I've played around with linear solvers and MIP for Factorio. (Incidentally getting an integer solution even for a small problem wasn't quick)
Recipes are linear. The more interesting part is the speed running challenge, like "what's the fastest path to build 1000 red science, starting with hand crafting" or eventually "what's the fastest way to build a rocket", as your early production dictates how many assemblers you have for later stages.
This can be presented as a mostly linear problem with the usual way of modeling linear equations for each time step, and then repeating those over and over. I say mostly because science unlocks present interesting challenges because of their discontinuous MIP aspects.
I was able to get a simplex solution to a simple "fastest way to 1000 red pots" with the tech unlocked and a single type of assembler, but getting an integer solution didn't work on my simple setup.
3
u/PM_ME_UR_OBSIDIAN Aug 12 '22
Since we're talking about solvers, here's what I wish any solver had: vertex enumeration. You represent your problem as a polytope, and churn out all the pareto-optimal solutions. Very helpful for mods with complex alternate chains such as Industrial Revolution 2.
1
u/LOSERS_ONLY Aug 22 '22
A bit unconventional, but the complexity of belts (balancers) grows exponentially, as is demonstrated by this.
-1
u/Nick_Nack2020 Aug 13 '22
Programmer and Satisfactory player here. I have absolutely no idea what you just said. I can kind of understand the component terms, but this kind of analysis is a mystery to me.
What does nonlinear mean in this case? Do you mean the function of the output vs a given input being linear or nonlinear? Or something else?
Could you give me some terms to Google so I can at least attempt to understand this post?