@@ -282,41 +282,50 @@ def get_subrules(self):
282
282
"[ERROR] obstruction '{}' is neither a MeshPatt "
283
283
"or Perm!" .format (obstruction ))
284
284
285
- subrules = set ()
285
+ subrules = 1
286
+ yield MeshTiling ({}, {}) # always include the empty rule
287
+
286
288
for (dim_col , dim_row ) in itertools .product (
287
289
range (1 , self .columns + self .MAX_COLUMN_DIMENSION ),
288
290
range (1 , self .rows + self .MAX_ROW_DIMENSION )
289
291
):
290
292
291
293
nr_of_cells = dim_col * dim_row
292
-
293
- for how_many_active_cells in range ( self .MAX_ACTIVE_CELLS + 1 ):
294
+ for how_many_active_cells in range ( min ( dim_col , dim_row ),
295
+ self .MAX_ACTIVE_CELLS + 1 ):
294
296
for active_cells in itertools .product (
295
297
cell_choices , repeat = how_many_active_cells ):
296
298
for combination in itertools .combinations (
297
299
range (nr_of_cells ), how_many_active_cells ):
298
300
requirements = {}
299
301
obstructions = {}
302
+ active_cols = set ()
303
+ active_rows = set ()
300
304
for i , cell_index in enumerate (combination ):
301
305
choice = active_cells [i ]
306
+
302
307
c = cell_index % dim_col
308
+ active_cols .add (c )
309
+
303
310
r = cell_index // dim_col
311
+ active_rows .add (r )
304
312
305
313
if choice .obstructions is not frozenset ():
306
314
obstructions [(c , r )] = choice .obstructions
307
315
308
316
if choice .requirements is not frozenset ():
309
317
requirements [(c , r )] = choice .requirements
310
318
311
- mt = MeshTiling (obstructions , requirements )
312
- subrules .add (mt )
319
+ if active_cols == set (range (dim_col )) and \
320
+ active_rows == set (range (dim_row )):
321
+ subrules += 1
322
+ yield MeshTiling (obstructions , requirements )
313
323
314
324
logger .info (
315
325
"Generated {} subrules with up to {} active cells with dimensions "
316
326
"up to {}x{}" .format (
317
- len ( subrules ) , self .MAX_ACTIVE_CELLS ,
327
+ subrules , self .MAX_ACTIVE_CELLS ,
318
328
self .MAX_COLUMN_DIMENSION , self .MAX_ROW_DIMENSION ))
319
- return list (subrules )
320
329
321
330
def get_dimension (self ):
322
331
return (self .columns , self .rows )
0 commit comments