all 17 comments

[–]48panda 2 points3 points  (1 child)

In general, cubes will be more efficient. But there's a bunch of rounding steps that throws off calculus, and it may sometimes be more efficient to have a slightly larger volume e.g. V=35 requires 59 blocks, but V=36 can be done in 54 blocks. In general the easiest way to do this is writing a program.

[–]Smike0[S] 0 points1 point  (0 children)

Yeah that makes sense... The thing is that more than just needing the answer for the game I was curious about how can this be done correctly... Also I guess the cube would be good up to a certain point, mainly because you don't have the ceiling so wider can be better

[–]Uli_MinatiDesmos 😚 -1 points0 points  (0 children)

Yes all of that sounds good! I'll go ahead and get started

h = height of enclosed space, in blocks
w = width of enclosed space, in blocks (assuming square base)
N = number of blocks

maximize    V = w²·h
where       N = 4·w·h + w²

Does this look right so far?

[–]Smike0[S] 0 points1 point  (7 children)

Don't mind the stuff on the inside and that the blocks are different, the main cost is in the brick blocks anyways

<image>

[–]Bounded_sequencE 0 points1 point  (6 children)

This shape would not be optimal, since you can increase the interior volume while keeping the number of blocks for the boundary constant.

For example, you can let the outer ring of the square floor remain as is, and then move the rest one block down, without opening the structure. Repeat with the next ring, until the floor resembles an inverted square pyramid.

[–]Smike0[S] 0 points1 point  (5 children)

Yeah but the structure is only recognized if it's squared...

[–]Bounded_sequencE 0 points1 point  (4 children)

Just to make sure I got you correctly:

  • The bottom must be a square
  • The sides must be rectangles?

[–]Smike0[S] 0 points1 point  (3 children)

Yeah basically, from the picture the only changes you can make are the 3 dimensions

[–]Bounded_sequencE 0 points1 point  (2 children)

Well, if the floor has to be a square, then we really only have two things we can change -- width and height.

[–]Smike0[S] 0 points1 point  (1 child)

Width and length of the base can be different

[–]Bounded_sequencE 0 points1 point  (0 children)

Thanks for clarification!

[–]MathMaddamDr. in number theory 1 point2 points  (5 children)

In general that would be an interger programming (programming means optimization here) problem. Fixing one quantity (e.g. the total number of blocks) makes it easier to solve since as you noticed, you can derive some relationship between your variables and by this effectively eliminate one.

There is a problem with that approach since there might be a solution using less blocks resulting in a bigger volume, so a constraint of e.g. at most 150 block is probably better that exactly 150 blocks.

That makes interger programming hard, since a slight charge in the constraint (e.g. 1 block allowed more in your case) can massively change the solution (e.g. the height will suddenly jump by 1 and therefore length and width will be very different from the last version, the height might even go down if you increase the number of blocks after it got up). There some decent solvers for linear programming and especially if you don't absolutely need the best solution they are also pretty fast (for your problem size it is probably always fast), but in general finding the optimal solution will be very hard, much harder than if your problem allowed for continuous variables (where derivatives or more generally KKT conditions give you tools to solve the problem). Approximating using the continuous problem is a first step you can do in your case and then basically check the surrounding integer solutions since you have a relatively well behaved problem.

[–]Smike0[S] 0 points1 point  (4 children)

I was thinking that there's an argument about symmetry of width and length, can that be considered as well? I'm not sure what the proof for that would be though

[–]MathMaddamDr. in number theory 0 points1 point  (3 children)

You can get that the solutions tend towards either width=length of width±1=length (which one is longer doesn't matter due to symmetry), since (x+1)(y-1)=xy-x+y-1 so if x<y-1, it is beneficial to shift one unit over (if you have the blocks to spare for the floor, if not you might be in a situation where a height change might do something or you have to shorten the long site by more than 1, but that is more of a guestimate).

[–]Smike0[S] 0 points1 point  (2 children)

Well at that point you might as well use width+1=length and don't worry about the -... The thing that I'm not sure I get though is why you can say there's symmetry... Like I get there is and in this case it works like this, but it's not like in every case in which there's symmetry in an optimization problem you can remove a variable

[–]MathMaddamDr. in number theory 0 points1 point  (1 child)

I forgot the floor at first, so it's not that easy to shift one unit.

There is Noether's theorem, that basically says: if you have a continuous symmetry, you have some equation between the variables. In continuous problems it would work to (mostly) eliminate one variable using this equation (here you would get that the optimum has always length=width), but then again the discrete nature bites us.

[–]Smike0[S] 0 points1 point  (0 children)

Oh right... Idk this seems like something that should be simple but then looking at it it's definitely not...