-
Notifications
You must be signed in to change notification settings - Fork 38
Description
For an n-polycube:
All n-polycubes can be generated in a space with dimensions (n, n, n).
Most n-polycubes exist in more compact spaces.
Idea: Partition space into cells of dimension x, y, z.
Constraints:
x, y, z are all greater than or equal to 1.
Cells must be large enough to accomodate the n-polycube: x*y*z >= n
Cells should not be larger than needed: x+y+z = n+2
Permutations of x,y,z yield redundant cells.
Python function for generating unique set of cells:
from itertools import combinations_with_replacement
def find_unique_cells(n):
"""
Finds the smallest set of cells to be populated by a polycube of size n.
Parameters:
n (integer): the size of the polycubes.
Returns:
Ordered list of tuples defining the dimensions for cells.
"""
cells = set()
for combo in combinations_with_replacement(range(1, n + 1), 3):
x, y, z = sorted(combo, reverse=True) # Sort in reverse order
if x * y * z >= n and x + y + z == n + 2:
cells.add((x, y, z))
return sorted(
cells, key=lambda group: group[0], reverse=True
) # Sort by the largest digit
Examples:
n = 1 | Cells: [(1, 1, 1)]
n = 2 | Cells: [(2, 1, 1)]
n = 3 | Cells: [(3, 1, 1), (2, 2, 1)]
n = 4 | Cells: [(4, 1, 1), (3, 2, 1), (2, 2, 2)]
n = 5 | Cells: [(5, 1, 1), (4, 2, 1), (3, 3, 1), (3, 2, 2)]
n = 6 | Cells: [(6, 1, 1), (5, 2, 1), (4, 3, 1), (4, 2, 2), (3, 3, 2)]
n = 7 | Cells: [(7, 1, 1), (6, 2, 1), (5, 2, 2), (5, 3, 1), (4, 3, 2), (4, 4, 1), (3, 3, 3)]
n = 8 | Cells: [(8, 1, 1), (7, 2, 1), (6, 2, 2), (6, 3, 1), (5, 3, 2), (5, 4, 1), (4, 4, 2), (4, 3, 3)]
n = 9 | Cells: [(9, 1, 1), (8, 2, 1), (7, 3, 1), (7, 2, 2), (6, 3, 2), (6, 4, 1), (5, 3, 3), (5, 4, 2), (5, 5, 1), (4, 4, 3)]
n = 10 | Cells: [(10, 1, 1), (9, 2, 1), (8, 2, 2), (8, 3, 1), (7, 3, 2), (7, 4, 1), (6, 3, 3), (6, 4, 2), (6, 5, 1), (5, 5, 2), (5, 4, 3), (4, 4, 4)]
Consider n = 4. Instead of a space of total size 4*4*4 = 64 we reduce it to (4*1*1)+(3*2*1)+(2*2*2) = 18
Cells come in 4 categories: (x=y=z), (x>y=z), (x=y>z), (x>y>z)
The Isometric or Cubic Cell: (x=y=z)
The Tetragonal Cells: (x>y=z) & (x=y>z)
The Orthorhombic Cell: (x>y>z)
Each cell category will only permit some rotations as cell dimension/shape must be preserved.
Effectively you don't want to rotate your n-polycube out of it's cell.
This should reduce the number of calculations of rotations and results to look up.
Things to consider further:
- How to ensure all unique n-polycubes are generated in a cell
- Is there a fixed way to build all?
- Could this make the
crop_cube(cube)function redundant? - Put the (n-1)-polycubes into cells for n-polycubes to generate new ones?
- Which (n-1)-polycubes go into which n-polycube cells and how?
I thought of starting at (1, 1, 1) but that will lead to some issues. with for instance not generating the 7-polycube of octahedral shape.
Should you start in the middle of the x,y-plane? In the middle of a cell?
It's also possible to generate shapes by applying symmetry operations on n-polycubes in cells. The 7-polycube of octahedral shape could be constructed from something like the (2, 2, 1) cell:
[[1 0]
[1 1]]
But I'm not sure how this would work with ensuring all possible shapes get generated.
Any comments as to why any of this shouldn't work or improve runtime and clever ideas to explore further are welcome.