def test_expansion(): """ This cannot be expanded automatically since it requires the positive root that is not in the specification. """ pack = TileScopePack.only_root_placements(3, 1) css = TileScope("132", pack) spec = css.auto_search(smallest=True) spec = spec.expand_verified() assert sum(1 for rule in spec if isinstance(rule, ReverseRule)) == 1 assert [spec.count_objects_of_size(i) for i in range(13)] == [ 1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, ]
def test_parallel_forest(): expected_count = [1, 1, 2, 6, 22, 90, 394, 1806, 8558, 41586] pack = TileScopePack.only_root_placements(2, 1) bases = ["0231_2031", "0132_1032", "0231_0321"] searchers = [TileScope(b, pack, ruledb=RuleDBForest()) for b in bases] specs = [css.auto_search() for css in searchers] for spec in specs: spec = spec.expand_verified() count = [spec.count_objects_of_size(n) for n in range(10)] assert count == expected_count
def test_expansion(): """ For this pack only some basic verification are needed. """ pack = TileScopePack.only_root_placements(3, 1) css = TileScope("132", pack) spec = css.auto_search(smallest=True) for comb_class, rule in spec.rules_dict.items(): if isinstance(rule, VerificationRule): assert isinstance( rule.strategy, ( strat.OneByOneVerificationStrategy, strat.MonotoneTreeVerificationStrategy, strat.BasicVerificationStrategy, EmptyStrategy, ), )
return [ pack(row_only=row_only, col_only=col_only, partial=partial) for row_only, col_only, partial in product((True, False), (True, False), (True, False)) if not row_only or not col_only ] packs = (length(TileScopePack.all_the_strategies) + partial(TileScopePack.insertion_point_placements) + row_col_partial(TileScopePack.insertion_row_and_col_placements) + row_col_partial(TileScopePack.insertion_point_row_and_col_placements) + length_maxnumreq_partial(TileScopePack.only_root_placements) + [ TileScopePack.only_root_placements( length=3, max_num_req=2, max_placement_rules_per_req=100) ] + length_partial(TileScopePack.pattern_placements) + length_partial(TileScopePack.point_placements) + directions(TileScopePack.regular_insertion_encoding) + length_partial(TileScopePack.requirement_placements) + row_col_partial(TileScopePack.row_and_col_placements) + length(TileScopePack.cell_insertions)) packs.extend( [pack.make_database() for pack in packs] + [pack.make_elementary() for pack in packs] + [pack.make_fusion() for pack in packs] + [pack.add_all_symmetry() for pack in packs] + [pack.make_interleaving() for pack in packs] + [pack.make_database().add_all_symmetry() for pack in packs] + [pack.make_fusion().add_all_symmetry()