Example submission

Scoring

Run your program for as long as you'd like, and post your list of upper bounds together with the shapes that achieve each.

The winner will be the participant whose table is lexicographically the earliest (with "infinity" appended to the shorter submissions.) If two participants submit the same results, then the earlier submission wins.

4 Answers
4

C# and SAT: 1, 2, 4, 6, 9, 12, 17, 20, 26, 31, 37, 43

If we limit the bounding box, there is a fairly obvious expression of the problem in terms of SAT: each translation of each orientation of each free polyomino is a large conjunction; for each polyomino we form a disjunction over its conjunctions; and then we require each disjunction to be true and the total number of cells used to be limited.

I wanted to make the post self-contained, so I dug out a C# implementation of a SAT solver with a BSD licence which was state-of-the-art about 15 years ago, replaced its NIH list implementation with System.Collections.Generic.List<T> (gaining a factor of 2 in speed), golfed it from 50kB down to 31kB to fit in the 64kB post limit, and then did some aggressive work on reducing memory usage. This code can obviously be adapted to output a DIMACS file which can then be passed to more modern solvers.

Optimality

The code above keeps reducing the target size until it finds an unsatisfiable constraint, so it guarantees that the output is optimal (under the bounding box assumption) up to and including \$n=11\$. However, it runs out of memory (3GB for a 32-bit process or 4GB for a 64-bit process) with \$n=12\$ after producing a region with weight 43.

To run the search for \$n=12\$ to completion I found it necessary to reduce the memory considerably, special-casing binary clauses and not keeping empty watch lists. However, by changing the order in which clauses are considered it changes the results, so I present the change as a patch and leave the list of solutions above untouched.

Distinct solutions

Counting solutions to a SAT problem is straightforward, if sometimes slow: you find a solution, add a new clause which directly rules it out, and run again. Here it's easy to generate the equivalence class of solutions under the symmetries of the rectangle, so the following code suffices to generate all distinct solutions.

\$\begingroup\$Finally managed to get a search for <43 with n=12 to complete without exceeding the memory which can be allocated to a single process; it took 7.5 days and didn't find any improvement, so unless I broke the SAT solver the result for n=12 is also optimal under the bbox assumption.\$\endgroup\$
– Peter TaylorJul 19 '18 at 7:30

In the interest of getting the process started, here's a quick (but not very optimal) answer.

Pattern:

n = 8:
########
######
#####
####
###
##

Take a triangle with length n - 1, stick an extra square onto the corner, and cut off the bottom square.

Proof that all n-ominos fit:

Note that any n-omino can fit in a rectangle with length + width at most n + 1.

If an n-omino fits in a rectangle with length + width at most n, it fits nicely in the triangle (which is the union of all such rectangles). If it happens to use the cut-off square, transposing it will fit in the triangle.

Otherwise, we have a chain with at most one branch. We can always fit one end of the chain into the extra square (prove this with casework), and the rest fits into a rectangle with length + width at most n, reducing to the case above.

The only case where the above doesn't work is the case where we use both the extra square and the cut-off square. There's only one such n-omino (the long L), and that one fits inside the triangle transposed.

\$\begingroup\$I think you can remove the bottom two squares for sufficiently large \$n\$. Mock proof: Aside from the two squares on the ends of the top row the shape has a mirror symmetry. Thus any shape that occupies the one of the bottom two either can be mirrored out of them or occupies the top right square. All the ones that occupy one of the bottom two and the top right, are within a 3x(n-1) footprint. We have a 3x(n-1) rectangle in the top 3 rows minus a single corner. The remaining shapes can only occupy a max of 2 corners in the bounding box, thus they can be rotated to fit in the top 3 rows.\$\endgroup\$
– Sriotchilism O'ZaicJun 26 '18 at 22:59

\$\begingroup\$The character limit kind of got me. If you need more explanation I can clarify.\$\endgroup\$
– Sriotchilism O'ZaicJun 26 '18 at 23:00

\$\begingroup\$@CatWizard I see what you mean. I wouldn't be surprised if you could extend it to removing about half the rows (for large n).\$\endgroup\$
– MnemonicJun 26 '18 at 23:29

This uses a seeded random approach, and I've optimised the seeds. I enforce a bounding box constraint which is both plausible and consistent with the known data for small values of n. If that constraint is indeed valid then

The output is optimal up to n=8 (by brute force validation, not included).

Greedy placement in random order

[1, 2, 4, 6, 9, 12, 17, 21, 27, 32]

The regions found are given below, as well as the rust program that generated them. Call it with a command line parameter equal to the n you'd like to search up to. I've run it up to n=10 so far. Note that it is not optimized for speed yet, I'll do that later and probably speed things up a lot.

The algorithm is straightforward, I shuffle the polyominoes in a (seeded) random order, then place them one at a time in the position with the maximum overlap possible with the region so far. I do this 100 times and output the best resulting region.

Your Answer

If this is an answer to a challenge…

…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.

…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.

…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.

More generally…

…Please make sure to answer the question and provide sufficient detail.

…Avoid asking for help, clarification or responding to other answers (use comments instead).