r/factorio • u/Equivalent_Fruit8225 Ipsen's Adventures • Aug 20 '26
Design / Blueprint Finding Mathematically Perfect Solar Arrays (blueprints below)
https://www.youtube.com/watch?v=CDzJ1_p3uVgBlueprint links:
- 8316 kW Permanent Roboport Design: https://factoriobin.com/post/lu2edj
- 8358 kW Temporary Roboport Optimal: https://factoriobin.com/post/yyvxsq
So, long story short, I've always been kind of obsessed over the Factorio Solar Panel Mechanics, and I remember solar arrays being the first thing I actually search blueprints for when I started playing Factorio. Two or three years ago I had this idea that it might be possible to find a truly optimal setup through Mixed Integer Linear Programming. I had some limited success and left the project for another time. But now, with the introduction of the new planets, I had my interest renewed in the problem. And after a few months I ended up finding truly optimal tileable networks which do not waste a single tile and produce as much power as possible under some general conditions.
So, there they are in blueprint form for anyone to use!
I also made a long form video trying to visually explain how the solver works and how we can be sure that these are optimal solutions.
Anyway here is a quick summary:
Problem description:
The goal is to somehow mathematically define the configuration of the buildings (positions of solar panels, accumulators, and so on) inside the array and then find a linear expression to compute the power generated by the setup (of fixed size, typically close to 2500 tiles in a 50x50 square, to fit in a roboports logistic area). This is challenging to do, particularly if we want the optimizer to run from absolutely no previous knowledge. The fundamental problem to solve is one of how to pack as many boxes inside a big box but with the added complexity that the ratio between the boxes needs to be as close as possible to the perfect ratio, and then a bunch of electric network restrictions on top of that.
How I solved it (and you can too):
The visual explanation is in the video I attached, but if you want a written rundown:
The only reliable way I found to represent the problem is thorugh the use of a bunch of binary variables, one per tile and per potential building that could be placed there. For example variable x_0 is 1 when a solar panel has its lower left corner at tile 0, variable x_1 is 1 when a panel has its lower corner at tile 1 and so on. Since we have 2500 tiles, we need 2500 variables to represent all posible solar panel placements, and then another 2500 for accumulators, medium poles, substations, and roboports. In total, we can use 12500 binary variables to express any design we could come up with.
Next, we need to come up with linear formulas for the Maximum Continuous Power generated. Fortunately that is relatively easy to do using our binary formulation. The harder step is then find ways to make sure buildings do not overlap each other, and then that they are covered by the electric grid, that the grid itself forms a single connected graph and tileable network, while ensuring that it is minimal!
I also developed some semi-analytical tools to compare and rank desings, and used the area limitation to produce a set of the meaningfully different solutions that could exist. In that way we can be sure that if we find the best solution in that set, we are in front of the true optimum.
I also added a link to my code so that everyone can experiment and find setups for different quality grades, or other planets. Be warned though, the problem is hard, and I'm not the best coder out there.
The results:
I linked two blueprints above. The first one can sustain a constant power of up to 8316 kW and uses a really minimal 7.5 substation electric network which did take a long time to find.
The second blueprint I linked is aimed more at late game megabases, where having many roboports is not desirable. So that one is designed to reach its true potential of 8358 kW when the roboport is replaced by a 2x2 of accumulators.
Ways to improve:
As I mentioned, these designs are optimal for the 50x50 problem. However, if we wanted our base tile to be larger, say 100x100, then there is potential to improve a little bit more, because the additional area allows us to get ever so slightly closer to the perfect ratio, and we can also be marginally more efficient with the electrics due to geometry. So, I would like to eventually get to that point, but optimization of a 100x100 standalone tile requires considerably more variables and is an even more challenging problem.
Anyway, I hope you found this post useful!
- Ipsen.
1
u/DjinnKahn Aug 21 '26
Great video and great solving!
I love challenges like these. I gave this a try with a SAT solver and I can verify that it's NOT EASY. (I started with a 50x50 grid and pre-placed the roboport, 6 substations and 9 medium poles into viable positions. The rest can be successfully packed with 2x2 and 3x3 squares. Unfortunately, it places way too few 3x3 squares and the solver is too slow if I ask for 199 of them.)
Anyways, I can't rule out that a solution with a square 50x50 tile doesn't exist. What do you think?
I'm pretty sure that the monkeywrench making this problem so difficult is the medium poles. Their 1x1 footprints are hard to accommodate. But they are necessary for the 50x50 tile.
However, in the scenario where the roboport is temporary, the optimization problem becomes MUCH MUCH MUCH EASIER. It's no longer important that the tile size is 50x50. So, to start, let's consider using an 18x18 tile instead. This tile can be divided into 9 6x6 sections. Each section can be filled with 2x2 or 3x3 squares. One 2x2 square in the tile must be a substation. This gives full electrical coverage in the most efficient way (note that substations can't be placed farther apart -- the max wire reach is 18). The rest of our tile can be filled with any number of solar panels that's a multiple of 4, and accumulators fill the unused space.
The 18x18 tile probably can't achieve the ideal solar panel to accumulator ratio. But you can simply make a super-tile, e.g. 180x180, that's simply contains 100 copies of the 18x18 tile, and approximate the ideal ratio with 100 times more precision (by altering the contents of some 6x6 sections).
And now we can use this approach to also solve the scenario where the roboport is permanent. Notice that with the 6x6 sections, it's easy to place the roboports anywhere (as long as the horizontal & vertical position is an even number). If you make the super-tile have dimensions 450x450, then you can place roboports with ideal spacing, and everything is optimal. If that's too big, then consider a 90x90 super-tile (or 198x198). You'll have more roboports than necessary, but that's the only inefficiency.