note
tye
<p>
Okay, how many crate sizes can you buy at UHaul? Or are you expecting him to buy sheet cardboard and build a custom crate in order to achieve maximal packing? The number of crate sizes to try is just a few. But then, I wouldn't try any sizes of crates at all!
</p><p>
Where did you get this crazy idea to try every possible origin for a package? If I put packages together tightly, then every package shares part of a side with another package. And we aren't talking about some theory trying to <em>prove</em> that we have the maximally tightest packing (which would be very hard, sure). Just assume that a reasonable packing exists where one package hits a corner of the crate (when was the last time <em>you</em> put packages in a crate in such a way that <b>no</b> package shared a corner with the crate?).
</p><p>
Now all you have to do is place a package in the corner of an infinite box (the positive octant) and add boxes in the resulting "corners". As you place boxes, keep track of the bounding crate. Iterate through all of the possibilities. Sure, this isn't trivial to code and the number of possiblities is huge. If you have a large number of packages, then try at random and report the best solution so far once you are tired of waiting. Who cares if it is brute force? Also, if you haven't placed all of the boxes yet and you are already worse off then your best solution so far, no need to continue adding packages.
</p><pre>
Take N boxes.
First box: N choices (orientation doesn't matter yet)
Second box: N1 boxes * <=3 corners * 6 orientations
Third box: N2 boxes * <=5 corners * <=6 orientations
...
</pre><p>
If I change the *3*5*7*9... terms to *4*6*8*10... then we are bounded by N! * 2^(N1)*N! * 6^(N1) == N!^2 * 12^(N1). So assuming a worsethanworstpossible case where we don't trim any chunks from the decision tree (we try all of the combinations in exactly the wrong order and don't eliminate overlapping boxes until we've placed all boxes), then we can still exhaustively search for 5 packages pretty quickly.
</p><p>
For 6 or 7, easy trimming of the decision tree might let you exhaustively search (hard to predict). For more than 7, you'd probably have to settle for stopping early and having a less optimal solution.
</p><p>
Brute force is often a very good way to solve reallife problems. That is why they computers that are fast. (:
</p>

<a href="/index.pl?node=tye&lastnode_id=1072">tye</a>
(but my friends call me "Tye")
40304
40319