From 004fc2f9577491a3c884b74120c38bad5e936ca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20Nadeau?= Date: Fri, 31 Jan 2020 15:46:42 +0000 Subject: [PATCH 01/12] migrate verification strategy --- tests/test_tilescope.py | 4 +- .../strategies/verification_strategies.py | 4 + .../verification_strategies/__init__.py | 4 - .../database_verification.py | 5 - .../globally_verified.py | 20 - .../subclass_verified.py | 33 - .../subset_verified.py | 17 - .../verification_strategies/verify_atoms.py | 9 - tilescopethree/strategy_packs.py | 1213 ----------------- tilescopethree/strategy_packs_v2.py | 59 +- tilescopethree/universescope.py | 160 --- 11 files changed, 35 insertions(+), 1493 deletions(-) create mode 100644 tilescopethree/strategies/verification_strategies.py delete mode 100644 tilescopethree/strategies/verification_strategies/__init__.py delete mode 100644 tilescopethree/strategies/verification_strategies/database_verification.py delete mode 100644 tilescopethree/strategies/verification_strategies/globally_verified.py delete mode 100644 tilescopethree/strategies/verification_strategies/subclass_verified.py delete mode 100644 tilescopethree/strategies/verification_strategies/subset_verified.py delete mode 100644 tilescopethree/strategies/verification_strategies/verify_atoms.py delete mode 100644 tilescopethree/strategy_packs.py delete mode 100644 tilescopethree/universescope.py diff --git a/tests/test_tilescope.py b/tests/test_tilescope.py index 32ff13d83..332cce154 100644 --- a/tests/test_tilescope.py +++ b/tests/test_tilescope.py @@ -4,7 +4,7 @@ from comb_spec_searcher import ProofTree from tilescopethree import TileScopeTHREE from tilescopethree.strategy_packs_v2 import ( - all_the_strategies_database_verified, point_placements, + all_the_strategies_verify_database, point_placements, point_placements_fusion, point_placements_fusion_with_interleaving, row_and_col_placements_fusion_with_interleaving_fusion) @@ -28,7 +28,7 @@ def test_132_genf(): @pytest.mark.timeout(20) def test_123(): - searcher = TileScopeTHREE('123', all_the_strategies_database_verified) + searcher = TileScopeTHREE('123', all_the_strategies_verify_database) t = searcher.auto_search(smallest=True) assert isinstance(t, ProofTree) diff --git a/tilescopethree/strategies/verification_strategies.py b/tilescopethree/strategies/verification_strategies.py new file mode 100644 index 000000000..1801990c3 --- /dev/null +++ b/tilescopethree/strategies/verification_strategies.py @@ -0,0 +1,4 @@ +from tilings.strategies.verification import (verify_basic, verify_database, + verify_elementary, verify_local, + verify_locally_factorable, + verify_one_by_one) diff --git a/tilescopethree/strategies/verification_strategies/__init__.py b/tilescopethree/strategies/verification_strategies/__init__.py deleted file mode 100644 index 2e4f49fcb..000000000 --- a/tilescopethree/strategies/verification_strategies/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from .database_verification import database_verified -from .globally_verified import elementary_verified, globally_verified -from .subset_verified import one_by_one_verified, subset_verified -from .verify_atoms import verify_atoms diff --git a/tilescopethree/strategies/verification_strategies/database_verification.py b/tilescopethree/strategies/verification_strategies/database_verification.py deleted file mode 100644 index be1203b7d..000000000 --- a/tilescopethree/strategies/verification_strategies/database_verification.py +++ /dev/null @@ -1,5 +0,0 @@ -from tilings.algorithms.enumeration import DatabaseEnumeration - - -def database_verified(tiling, **kwargs): - return DatabaseEnumeration(tiling).verification_rule() diff --git a/tilescopethree/strategies/verification_strategies/globally_verified.py b/tilescopethree/strategies/verification_strategies/globally_verified.py deleted file mode 100644 index fb6200d35..000000000 --- a/tilescopethree/strategies/verification_strategies/globally_verified.py +++ /dev/null @@ -1,20 +0,0 @@ -from tilings.algorithms.enumeration import (ElementaryEnumeration, - LocallyFactorableEnumeration) - - -def globally_verified(tiling, **kwargs): - """ - The globally verified strategy. - - A tiling is globally verified if every requirement and obstruction is - non-interleaving. - """ - return LocallyFactorableEnumeration(tiling).verification_rule() - - -def elementary_verified(tiling, **kwargs): - """ - A tiling is elementary verified if it is globally verified and has no - interleaving cells. - """ - return ElementaryEnumeration(tiling).verification_rule() diff --git a/tilescopethree/strategies/verification_strategies/subclass_verified.py b/tilescopethree/strategies/verification_strategies/subclass_verified.py deleted file mode 100644 index c78b2383b..000000000 --- a/tilescopethree/strategies/verification_strategies/subclass_verified.py +++ /dev/null @@ -1,33 +0,0 @@ -"""A strategy for checking if a tiling is contained in a subclass.""" - -from itertools import chain - -from comb_spec_searcher import VerificationRule -from permuta import Av -from permuta.descriptors import Basis - - -def subclass_verified(tiling, basis, **kwargs): - """The subclass verified strategy. - - A tiling is subclass verified if it only generates permutations in a - proper subclass of Av(basis). - """ - if tiling.dimensions == (1, 1): - return None - else: - maxlen = kwargs.get('maxpattlen', 4) - patterns = set(perm for perm in chain(*[Av(basis).of_length(i) - for i in range(maxlen + 1)])) - maxlen += tiling.maximum_length_of_minimum_gridded_perm() - for i in range(maxlen + 1): - for g in tiling.objects_of_length(i): - perm = g.patt - patterns = set(pattern for pattern in patterns - if perm.avoids(pattern)) - if not patterns: - return None - return VerificationRule(formal_step=("The tiling belongs to the " - "subclass obtained by adding" - " the patterns {}." - "".format(Basis(patterns)))) diff --git a/tilescopethree/strategies/verification_strategies/subset_verified.py b/tilescopethree/strategies/verification_strategies/subset_verified.py deleted file mode 100644 index b20e521a6..000000000 --- a/tilescopethree/strategies/verification_strategies/subset_verified.py +++ /dev/null @@ -1,17 +0,0 @@ -from tilings.algorithms.enumeration import (LocalEnumeration, - OneByOneEnumeration) - - -def subset_verified(tiling, no_reqs=False, **kwargs): - """ - The subset verified strategy. - - A tiling is subset verified if every obstruction and every requirement is - localized and the tiling is not 1x1. - """ - return LocalEnumeration(tiling, no_reqs).verification_rule() - - -def one_by_one_verified(tiling, basis, **kwargs): - """Return a verification if one-by-one verified.""" - return OneByOneEnumeration(tiling, basis).verification_rule() diff --git a/tilescopethree/strategies/verification_strategies/verify_atoms.py b/tilescopethree/strategies/verification_strategies/verify_atoms.py deleted file mode 100644 index d0b72f4ec..000000000 --- a/tilescopethree/strategies/verification_strategies/verify_atoms.py +++ /dev/null @@ -1,9 +0,0 @@ -"""A strategy for checking if a tiling is a point.""" -from tilings.algorithms.enumeration import BasicEnumeration - - -def verify_atoms(tiling, **kwargs): - """ - Verify the most basics tilings. - """ - return BasicEnumeration(tiling).verification_rule() diff --git a/tilescopethree/strategy_packs.py b/tilescopethree/strategy_packs.py deleted file mode 100644 index d7dbae991..000000000 --- a/tilescopethree/strategy_packs.py +++ /dev/null @@ -1,1213 +0,0 @@ -from functools import partial - -from comb_spec_searcher import StrategyPack as Pack -from tilescopethree.strategies import (all_cell_insertions, all_col_insertions, - all_point_insertions, - all_requirement_extensions, - all_row_insertions, col_placements, - database_verified, deflation, - elementary_verified, - empty_cell_inferral, factor, fusion, - fusion_with_interleaving, - globally_verified, - obstruction_transitivity, - one_by_one_verified, - partial_requirement_placement, - point_placement, - requirement_corroboration, - requirement_list_placement, - requirement_placement, - root_requirement_insertion, - row_and_column_separation, - row_placements, subclass_verified, - subobstruction_inferral, - subset_verified) - -all_the_strategies = Pack( - initial_strats=[partial(factor, unions=True), fusion], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[all_point_insertions, all_row_insertions, - all_col_insertions], - [row_placements, - col_placements, - partial(row_placements, positive=False), - partial(col_placements, positive=False), - partial_requirement_placement, - requirement_placement, - requirement_list_placement], - [requirement_corroboration]], - forward_equivalence=True, - name="all_the_strategies" -) - -single_cell_subob_2 = Pack( - initial_strats=[], - ver_strats=[subset_verified], - inferral_strats=[], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=2, - maxreqnum=2)]], - name="single_cell_subob_2") - -single_cell_subob_3 = Pack( - initial_strats=[], - ver_strats=[subset_verified], - inferral_strats=[], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=3, - maxreqnum=6)]], - name="single_cell_subob_3") - -single_cell_subob_4 = Pack( - initial_strats=[], - ver_strats=[subset_verified], - inferral_strats=[], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=4, - maxreqnum=24)]], - name="single_cell_subob_4") - -single_cell_subob_5 = Pack( - initial_strats=[], - ver_strats=[subset_verified], - inferral_strats=[], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=5, - maxreqnum=120)]], - name="single_cell_subob_5") - -single_cell_subob_2_2 = Pack( - initial_strats=[], - ver_strats=[subset_verified], - inferral_strats=[], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=2, - maxreqnum=2)]], - name="single_cell_subob_2_2") - -single_cell_subob_3_2 = Pack( - initial_strats=[], - ver_strats=[subset_verified], - inferral_strats=[], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=3, - maxreqnum=2)]], - name="single_cell_subob_3_2") - -single_cell_subob_4_2 = Pack( - initial_strats=[], - ver_strats=[subset_verified], - inferral_strats=[], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=4, - maxreqnum=2)]], - name="single_cell_subob_4_2") - -single_cell_subob_5_2 = Pack( - initial_strats=[], - ver_strats=[subset_verified], - inferral_strats=[], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=5, - maxreqnum=2)]], - name="single_cell_subob_5_2") - -super_jay_scv_no_fusion = Pack( - initial_strats=[partial(factor, interleaving=False)], - ver_strats=[subset_verified, globally_verified, - subclass_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[ - [all_row_insertions, all_col_insertions, all_point_insertions, - partial_requirement_placement], - [requirement_list_placement], - [requirement_corroboration]], - forward_equivalence=False, - name="super_jay_scv_no_fusion" -) - -super_jay_scv = Pack( - initial_strats=[partial(factor, interleaving=True), - fusion_with_interleaving], - ver_strats=[subset_verified, globally_verified, subclass_verified, - database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[ - [all_row_insertions, all_col_insertions, all_point_insertions, - partial_requirement_placement], - [requirement_list_placement], - [requirement_corroboration]], - forward_equivalence=True, - name="super_jay_scv" -) - -super_jay_no_fusion_with_interleaving_db = Pack( - initial_strats=[partial(factor, interleaving=True)], - ver_strats=[subset_verified, globally_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[ - [all_row_insertions, all_col_insertions, all_point_insertions, - partial_requirement_placement], - [requirement_list_placement], - [requirement_corroboration]], - forward_equivalence=True, - name="super_jay_no_fusion_with_interleaving_db" -) -super_jay_no_fusion_with_interleaving = Pack( - initial_strats=[partial(factor, interleaving=True)], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[ - [all_row_insertions, all_col_insertions, all_point_insertions, - partial_requirement_placement], - [requirement_list_placement], - [requirement_corroboration]], - forward_equivalence=True, - name="super_jay_no_fusion_with_interleaving" -) - -super_jay_no_fusion = Pack( - initial_strats=[partial(factor, interleaving=False)], - ver_strats=[subset_verified, globally_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[ - [all_row_insertions, all_col_insertions, all_point_insertions, - partial_requirement_placement], - [requirement_list_placement], - [requirement_corroboration]], - forward_equivalence=False, - name="super_jay_no_fusion" -) - -super_jay = Pack( - initial_strats=[partial(factor, interleaving=False), fusion], - ver_strats=[subset_verified, globally_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[ - [all_row_insertions, all_col_insertions, all_point_insertions, - partial_requirement_placement], - [requirement_list_placement], - [requirement_corroboration]], - forward_equivalence=True, - name="super_jay" -) - -super_jay_allow_backward = Pack( - initial_strats=[partial(factor, interleaving=False), fusion], - ver_strats=[subset_verified, globally_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[ - [all_row_insertions, - all_col_insertions, - all_point_insertions, - partial_requirement_placement], - [requirement_list_placement], - [requirement_corroboration]], - # forward_equivalence=True, - name="super_jay_allow_backward" -) - -super_jay_with_interleaving_and_fusion = Pack( - initial_strats=[partial(factor, interleaving=True), fusion], - ver_strats=[subset_verified, globally_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[ - [all_row_insertions, all_col_insertions, all_point_insertions, - partial_requirement_placement], - [requirement_list_placement], - [requirement_corroboration]], - forward_equivalence=True, - name="super_jay" -) - -positive_row_placements = Pack( - initial_strats=[factor, requirement_corroboration, - partial(all_cell_insertions, ignore_parent=True)], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[row_placements]], - name="positive_row_placements" -) - -positive_col_placements = Pack( - initial_strats=[factor, requirement_corroboration, - partial(all_cell_insertions, ignore_parent=True)], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[col_placements]], - name="positive_col_placements" -) - -positive_row_col_placements = Pack( - initial_strats=[factor, requirement_corroboration, - partial(all_cell_insertions, ignore_parent=True)], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[row_placements, col_placements]], - name="positive_row_col_placements" -) - -negative_row_placements = Pack( - initial_strats=[factor, requirement_corroboration], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(row_placements, positive=False)]], - name="negative_row_placements" -) - -negative_row_placements_with_fusion = Pack( - initial_strats=[factor, requirement_corroboration, fusion], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(row_placements, positive=False)]], - forward_equivalence=True, - name="negative_row_placements_with_fusion" -) - -negative_row_placements_db = Pack( - initial_strats=[factor, requirement_corroboration], - ver_strats=[subset_verified, globally_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(row_placements, positive=False)]], - name="negative_row_placements_db" -) - -negative_row_placements_fusion = Pack( - initial_strats=[factor, requirement_corroboration, fusion], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(row_placements, positive=False)]], - forward_equivalence=True, - name="negative_row_placements_fusion" -) - -negative_col_placements = Pack( - initial_strats=[factor, requirement_corroboration], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(col_placements, positive=False)]], - name="negative_col_placements" -) - -negative_col_placements_db = Pack( - initial_strats=[factor, requirement_corroboration], - ver_strats=[subset_verified, globally_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(col_placements, positive=False)]], - name="negative_col_placements_db" -) - -negative_row_col_placements = Pack( - initial_strats=[factor, requirement_corroboration], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(col_placements, positive=False), - partial(row_placements, positive=False)]], - name="negative_row_col_placements" -) - -negative_row_col_placements_db = Pack( - initial_strats=[factor, requirement_corroboration], - ver_strats=[subset_verified, globally_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(col_placements, positive=False), - partial(row_placements, positive=False)]], - name="negative_row_col_placements_db" -) - -super_jay_scv_no_fusion = Pack( - initial_strats=[partial(factor, interleaving=False)], - ver_strats=[subset_verified, globally_verified, subclass_verified, - database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[ - [all_row_insertions, all_col_insertions, all_point_insertions, - partial_requirement_placement], - [requirement_list_placement], - [requirement_corroboration]], - forward_equivalence=False, - name="super_jay_scv_no_fusion" -) - -super_jay_scv = Pack( - initial_strats=[partial(factor, interleaving=True), - fusion_with_interleaving], - ver_strats=[subset_verified, globally_verified, subclass_verified, - database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[ - [all_row_insertions, all_col_insertions, all_point_insertions, - partial_requirement_placement], - [requirement_list_placement], - [requirement_corroboration]], - forward_equivalence=True, - name="super_jay_scv" -) - -super_jay_no_fusion_with_interleaving_db = Pack( - initial_strats=[partial(factor, interleaving=True)], - ver_strats=[subset_verified, globally_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[ - [all_row_insertions, all_col_insertions, all_point_insertions, - partial_requirement_placement], - [requirement_list_placement], - [requirement_corroboration]], - forward_equivalence=True, - name="super_jay_no_fusion_with_interleaving_db" -) -super_jay_no_fusion_with_interleaving = Pack( - initial_strats=[partial(factor, interleaving=True)], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[ - [all_row_insertions, all_col_insertions, all_point_insertions, - partial_requirement_placement], - [requirement_list_placement], - [requirement_corroboration]], - forward_equivalence=True, - name="super_jay_no_fusion_with_interleaving" -) - -super_jay_no_fusion = Pack( - initial_strats=[partial(factor, interleaving=False)], - ver_strats=[subset_verified, globally_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[ - [all_row_insertions, all_col_insertions, all_point_insertions, - partial_requirement_placement], - [requirement_list_placement], - [requirement_corroboration]], - forward_equivalence=False, - name="super_jay_no_fusion" -) - -super_jay = Pack( - initial_strats=[partial(factor, interleaving=False), fusion], - ver_strats=[subset_verified, globally_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[ - [all_row_insertions, all_col_insertions, all_point_insertions, - partial_requirement_placement], - [requirement_list_placement], - [requirement_corroboration]], - forward_equivalence=True, - name="super_jay" -) - -super_jay_allow_backward = Pack( - initial_strats=[partial(factor, interleaving=False), fusion], - ver_strats=[subset_verified, globally_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[ - [all_row_insertions, - all_col_insertions, - all_point_insertions, - partial_requirement_placement], - [requirement_list_placement], - [requirement_corroboration]], - # forward_equivalence=True, - name="super_jay_allow_backward" -) - -super_jay_with_interleaving_and_fusion = Pack( - initial_strats=[partial(factor, interleaving=True), fusion], - ver_strats=[subset_verified, globally_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[ - [all_row_insertions, all_col_insertions, all_point_insertions, - partial_requirement_placement], - [requirement_list_placement], - [requirement_corroboration]], - forward_equivalence=True, - name="super_jay" -) - -positive_row_placements = Pack( - initial_strats=[factor, requirement_corroboration, - partial(all_cell_insertions, ignore_parent=True)], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[row_placements]], - name="positive_row_placements" -) - -positive_col_placements = Pack( - initial_strats=[factor, requirement_corroboration, - partial(all_cell_insertions, ignore_parent=True)], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[col_placements]], - name="positive_col_placements" -) - -positive_row_col_placements = Pack( - initial_strats=[factor, requirement_corroboration, - partial(all_cell_insertions, ignore_parent=True)], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[row_placements, col_placements]], - name="positive_row_col_placements" -) - -negative_row_placements = Pack( - initial_strats=[factor, requirement_corroboration], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(row_placements, positive=False)]], - name="negative_row_placements" -) - -negative_row_placements_with_fusion = Pack( - initial_strats=[factor, requirement_corroboration, fusion], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(row_placements, positive=False)]], - forward_equivalence=True, - name="negative_row_placements_with_fusion" -) - -negative_row_placements_db = Pack( - initial_strats=[factor, requirement_corroboration], - ver_strats=[subset_verified, globally_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(row_placements, positive=False)]], - name="negative_row_placements_db" -) - -negative_row_placements_fusion = Pack( - initial_strats=[factor, requirement_corroboration, fusion], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(row_placements, positive=False)]], - forward_equivalence=True, - name="negative_row_placements_fusion" -) - -negative_col_placements = Pack( - initial_strats=[factor, requirement_corroboration], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(col_placements, positive=False)]], - name="negative_col_placements" -) - -negative_col_placements_db = Pack( - initial_strats=[factor, requirement_corroboration], - ver_strats=[subset_verified, globally_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(col_placements, positive=False)]], - name="negative_col_placements_db" -) - -negative_row_col_placements = Pack( - initial_strats=[factor, requirement_corroboration], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(col_placements, positive=False), - partial(row_placements, positive=False)]], - name="negative_row_col_placements" -) - -negative_row_col_placements_db = Pack( - initial_strats=[factor, requirement_corroboration], - ver_strats=[subset_verified, globally_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(col_placements, positive=False), - partial(row_placements, positive=False)]], - name="negative_row_col_placements_db" -) - -row_col_placements = Pack( - initial_strats=[factor], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[all_row_insertions, all_col_insertions], - [requirement_list_placement], - [requirement_corroboration]], - name="row_col_placements" -) - -row_col_placements_db = Pack( - initial_strats=[factor], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[all_row_insertions, all_col_insertions], - [requirement_list_placement], - [requirement_corroboration]], - name="row_col_placements_db" -) - -partial_point_placements_with_subobstruction_inferral = Pack( - initial_strats=[partial_requirement_placement], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity, - subobstruction_inferral], - expansion_strats=[[factor], [all_point_insertions], - [requirement_corroboration]], - name="partial_point_placements_with_subobstruction_inferral") - -partial_point_placements_with_subobstruction_inferral_db = Pack( - initial_strats=[partial_requirement_placement], - ver_strats=[subset_verified, globally_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity, - subobstruction_inferral], - expansion_strats=[[factor], [all_point_insertions], - [requirement_corroboration]], - name="partial_point_placements_with_subobstruction_inferral_db") - -partial_point_placements = Pack( - initial_strats=[partial_requirement_placement], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[factor], [all_point_insertions], - [requirement_corroboration]], - name="partial_point_placements") - -partial_point_placements_db = Pack( - initial_strats=[partial_requirement_placement], - ver_strats=[subset_verified, globally_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[factor], [all_point_insertions], - [requirement_corroboration]], - name="partial_point_placements_db") - -point_placements = Pack( - initial_strats=[requirement_placement], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[factor], [all_point_insertions], - [requirement_corroboration]], - name="point_placements") - - -point_placements_subset_verified = Pack( - initial_strats=[requirement_placement], - ver_strats=[subset_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[factor], [all_point_insertions], - [requirement_corroboration]], - name="point_placements_subset_verified") - -point_placements_one_by_one = Pack( - initial_strats=[requirement_placement], - ver_strats=[one_by_one_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[factor], [all_point_insertions], - [requirement_corroboration]], - name="point_placements_one_by_one") - - -insertion_point_placements = Pack( - initial_strats=[factor, requirement_corroboration, - partial(all_point_insertions, ignore_parent=True)], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[requirement_placement]], - name="insertion_point_placements") - -point_placements_with_deflation = Pack( - initial_strats=[factor, requirement_placement, deflation], - ver_strats=[subset_verified], - inferral_strats=[row_and_column_separation], - expansion_strats=[[all_point_insertions], - [requirement_corroboration]], - forward_equivalence=True, - name="point_placements_with_deflation") - -length_2_requirement_with_point_placements_and_deflation = Pack( - initial_strats=[factor, deflation], - ver_strats=[subset_verified], - inferral_strats=[row_and_column_separation], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=2)], - [requirement_placement]], - forward_equivalence=True, - name="length_2_requirement_with_point_placements_and_deflation") - -length_3_requirement_with_point_placements_and_deflation = Pack( - initial_strats=[factor, deflation], - ver_strats=[subset_verified], - inferral_strats=[row_and_column_separation], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=3)], - [requirement_placement]], - forward_equivalence=True, - name="length_3_requirement_with_point_placements_and_deflation") - -point_placements_with_deflation_and_fusion = Pack( - initial_strats=[factor, requirement_placement, deflation, fusion], - ver_strats=[subset_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[all_point_insertions], - [requirement_corroboration]], - forward_equivalence=True, - name="point_placement_with_deflation_and_fusion") - -length_2_requirement_with_point_placements_and_deflation_and_fusion = Pack( - initial_strats=[factor, deflation, fusion], - ver_strats=[subset_verified], - inferral_strats=[row_and_column_separation], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=2)], - [requirement_placement]], - forward_equivalence=True, - name="length_2_requirement_with_point_placements_and_deflation_and_fusion") - -length_3_requirement_with_point_placements_and_deflation_and_fusion = Pack( - initial_strats=[factor, deflation, fusion], - ver_strats=[subset_verified], - inferral_strats=[row_and_column_separation], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=3)], - [requirement_placement]], - forward_equivalence=True, - name="length_3_requirement_with_point_placements_and_deflation_and_fusion") - -point_placements_scv = Pack( - initial_strats=[requirement_placement], - ver_strats=[subset_verified, globally_verified, subclass_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[factor], [all_point_insertions], - [requirement_corroboration]], - name="point_placements_scv") - -point_placements_db = Pack( - initial_strats=[requirement_placement], - ver_strats=[subset_verified, globally_verified, - database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[factor], [all_point_insertions], - [requirement_corroboration]], - name="point_placements_db") - -insertion_point_placements_scv = Pack( - initial_strats=[factor, requirement_corroboration, - partial(all_point_insertions, ignore_parent=True)], - ver_strats=[subset_verified, globally_verified, - subclass_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[requirement_placement]], - name="insertion_point_placements_scv") - -insertion_point_placements_db = Pack( - initial_strats=[factor, requirement_corroboration, - partial(all_point_insertions, ignore_parent=True)], - ver_strats=[subset_verified, globally_verified, - database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[requirement_placement]], - name="insertion_point_placements_db") - -length_2_requirement_with_point_placements = Pack( - initial_strats=[], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[factor], - [partial(all_cell_insertions, maxreqlen=2)], - [requirement_placement], - [requirement_corroboration]], - name="length_2_requirement_with_point_placements") - -length_2_requirement_with_point_placements_scv = Pack( - initial_strats=[], - ver_strats=[subset_verified, globally_verified, - subclass_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[factor], - [partial(all_cell_insertions, maxreqlen=2)], - [requirement_placement], - [requirement_corroboration]], - name="length_2_requirement_with_point_placements_scv") - -length_2_requirement_with_point_placements_db = Pack( - initial_strats=[factor, requirement_corroboration], - ver_strats=[subset_verified, globally_verified, - database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=2)], - [requirement_placement]], - name="length_2_requirement_with_point_placements_db") - -insertion_length_2_requirement_with_point_placements_scv = Pack( - initial_strats=[factor, requirement_corroboration, - partial(all_cell_insertions, maxreqlen=2, - ignore_parent=True)], - ver_strats=[subset_verified, globally_verified, - subclass_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[requirement_placement]], - name="insertion_length_2_requirement_with_point_placements_scv") - -insertion_length_2_requirement_with_point_placements_db = Pack( - initial_strats=[factor, requirement_corroboration, - partial(all_cell_insertions, maxreqlen=2, - ignore_parent=True)], - ver_strats=[subset_verified, globally_verified, - database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[requirement_placement]], - name="insertion_length_2_requirement_with_point_placements_db") - -length_2_requirement_with_pattern_placements = Pack( - initial_strats=[requirement_placement], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(factor, unions=True)], - [partial(all_cell_insertions, maxreqlen=2), - partial(all_requirement_extensions, maxreqlen=2)], - [requirement_corroboration]], - name="length_2_requirement_with_pattern_placements") - -length_2_requirement_with_pattern_placements_scv = Pack( - initial_strats=[requirement_placement], - ver_strats=[subset_verified, globally_verified, - subclass_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(factor, unions=True)], - [partial(all_cell_insertions, maxreqlen=2), - partial(all_requirement_extensions, maxreqlen=2)], - [requirement_corroboration]], - name="length_2_requirement_with_pattern_placements_scv") - -length_2_requirement_with_pattern_placements_db = Pack( - initial_strats=[requirement_placement], - ver_strats=[subset_verified, globally_verified, - database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(factor, unions=True)], - [partial(all_cell_insertions, maxreqlen=2), - partial(all_requirement_extensions, maxreqlen=2)], - [requirement_corroboration]], - name="length_2_requirement_with_pattern_placements_db") - -length_3_requirement_with_point_placements = Pack( - initial_strats=[], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[factor], - [partial(all_cell_insertions, maxreqlen=3)], - [requirement_placement], - [requirement_corroboration]], - name="length_3_requirement_with_point_placements") - -length_3_requirement_with_point_placements_scv = Pack( - initial_strats=[], - ver_strats=[subset_verified, globally_verified, - subclass_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[factor], - [partial(all_cell_insertions, maxreqlen=3)], - [requirement_placement], - [requirement_corroboration]], - name="length_3_requirement_with_point_placements_scv") - -length_3_requirement_with_point_placements_db = Pack( - initial_strats=[factor, requirement_corroboration], - ver_strats=[subset_verified, globally_verified, - database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=3)], - [requirement_placement]], - name="length_3_requirement_with_point_placements_db") - -insertion_length_3_requirement_with_point_placements_db = Pack( - initial_strats=[factor, requirement_corroboration, - partial(all_cell_insertions, maxreqlen=3, - ignore_parent=True)], - ver_strats=[subset_verified, globally_verified, - database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[requirement_placement]], - name="insertion_length_3_requirement_with_point_placements_db") - -insertion_length_3_requirement_with_point_placements_scv = Pack( - initial_strats=[factor, requirement_corroboration, - partial(all_cell_insertions, maxreqlen=3, - ignore_parent=True)], - ver_strats=[subset_verified, globally_verified, - subclass_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[requirement_placement]], - name="insertion_length_3_requirement_with_point_placements_scv") - -length_3_requirement_with_pattern_placements = Pack( - initial_strats=[requirement_placement], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(factor, unions=True)], - [partial(all_cell_insertions, maxreqlen=3), - partial(all_requirement_extensions, maxreqlen=3)], - [requirement_corroboration]], - name="length_3_requirement_with_pattern_placements") - -length_3_requirement_with_pattern_placements_db = Pack( - initial_strats=[requirement_placement], - ver_strats=[subset_verified, globally_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(factor, unions=True)], - [partial(all_cell_insertions, maxreqlen=3), - partial(all_requirement_extensions, maxreqlen=3)], - [requirement_corroboration]], - name="length_3_requirement_with_pattern_placements_db") - -length_3_requirement_with_pattern_placements_scv = Pack( - initial_strats=[requirement_placement], - ver_strats=[subset_verified, globally_verified, subclass_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(factor, unions=True)], - [partial(all_cell_insertions, maxreqlen=3), - partial(all_requirement_extensions, maxreqlen=3)], - [requirement_corroboration]], - name="length_3_requirement_with_pattern_placements_scv") - -length_4_requirement_with_point_placements = Pack( - initial_strats=[], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[factor], - [partial(all_cell_insertions, maxreqlen=4)], - [requirement_placement], - [requirement_corroboration]], - name="length_4_requirement_with_point_placements") - -length_4_requirement_with_point_placements_scv = Pack( - initial_strats=[], - ver_strats=[subset_verified, globally_verified, - subclass_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[factor], - [partial(all_cell_insertions, maxreqlen=4)], - [requirement_placement], - [requirement_corroboration]], - name="length_4_requirement_with_point_placements_scv") - -length_4_requirement_with_point_placements_db = Pack( - initial_strats=[factor, requirement_corroboration], - ver_strats=[subset_verified, globally_verified, - database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=4)], - [requirement_placement]], - name="length_4_requirement_with_point_placements_db") - -insertion_length_4_requirement_with_point_placements_db = Pack( - initial_strats=[factor, requirement_corroboration, - partial(all_cell_insertions, maxreqlen=4, - ignore_parent=True)], - ver_strats=[subset_verified, globally_verified, - database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[requirement_placement]], - name="insertion_length_4_requirement_with_point_placements_db") - -insertion_length_4_requirement_with_point_placements_scv = Pack( - initial_strats=[factor, requirement_corroboration, - partial(all_cell_insertions, maxreqlen=4, - ignore_parent=True)], - ver_strats=[subset_verified, globally_verified, - subclass_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[requirement_placement]], - name="insertion_length_4_requirement_with_point_placements_scv") - -length_4_requirement_with_pattern_placements = Pack( - initial_strats=[requirement_placement], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(factor, unions=True)], - [partial(all_cell_insertions, maxreqlen=4), - partial(all_requirement_extensions, maxreqlen=4)], - [requirement_corroboration]], - name="length_4_requirement_with_pattern_placements") - -length_4_requirement_with_pattern_placements_db = Pack( - initial_strats=[requirement_placement], - ver_strats=[subset_verified, globally_verified, database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(factor, unions=True)], - [partial(all_cell_insertions, maxreqlen=4), - partial(all_requirement_extensions, maxreqlen=4)], - [requirement_corroboration]], - name="length_4_requirement_with_pattern_placements_db") - -length_4_requirement_with_pattern_placements_scv = Pack( - initial_strats=[requirement_placement], - ver_strats=[subset_verified, globally_verified, subclass_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(factor, unions=True)], - [partial(all_cell_insertions, maxreqlen=4), - partial(all_requirement_extensions, maxreqlen=4)], - [requirement_corroboration]], - name="length_4_requirement_with_pattern_placements_scv") - -length_3_root_requirement_with_point_placements_db = Pack( - initial_strats=[requirement_placement, factor, - requirement_corroboration], - ver_strats=[subset_verified, globally_verified, - database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[all_point_insertions, - partial(root_requirement_insertion, maxreqlen=3)]], - name="length_3_root_requirement_with_point_placements_db") - -length_4_root_requirement_with_point_placements_db = Pack( - initial_strats=[factor, requirement_corroboration, - requirement_placement], - ver_strats=[subset_verified, globally_verified, - database_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[all_point_insertions, - partial(root_requirement_insertion, maxreqlen=4)]], - name="length_4_root_requirement_with_point_placements_db") - -elementary_point_placement = Pack( - initial_strats=[point_placement], - ver_strats=[elementary_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[factor], [all_point_insertions], - [requirement_corroboration]], - iterative=True, - forward_equivalence=True, - name="elementary_point_placement") - -elementary_length_2_requirement_with_point_placement = Pack( - initial_strats=[], - ver_strats=[elementary_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[factor], - [partial(all_cell_insertions, maxreqlen=2)], - [requirement_placement], - [requirement_corroboration]], - iterative=True, - forward_equivalence=True, - name="elementary_length_2_requirement_with_point_placement") - -elementary_length_2_requirement_with_pattern_placement = Pack( - initial_strats=[requirement_placement], - ver_strats=[elementary_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[factor], - [partial(all_cell_insertions, maxreqlen=2), - partial(all_requirement_extensions, maxreqlen=2)], - [requirement_corroboration]], - iterative=True, - forward_equivalence=True, - name="elementary_length_2_requirement_with_pattern_placement") - -elementary_length_3_requirement_with_point_placement = Pack( - initial_strats=[], - ver_strats=[elementary_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[factor], - [partial(all_cell_insertions, maxreqlen=3)], - [requirement_placement], - [requirement_corroboration]], - iterative=True, - forward_equivalence=True, - name="elementary_length_3_requirement_with_point_placement") - -elementary_length_3_requirement_with_pattern_placement = Pack( - initial_strats=[requirement_placement], - ver_strats=[elementary_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[factor], - [partial(all_cell_insertions, maxreqlen=3), - partial(all_requirement_extensions, maxreqlen=3)], - [requirement_corroboration]], - iterative=True, - forward_equivalence=True, - name="elementary_length_3_requirement_with_pattern_placement") - -elementary_point_placement_no_factors = Pack( - initial_strats=[point_placement], - ver_strats=[elementary_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[all_point_insertions], - [requirement_corroboration]], - iterative=True, - name="elementary_point_placement_no_factors") - -elementary_length_2_requirement_with_point_placement_no_factors = Pack( - initial_strats=[], - ver_strats=[elementary_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=2)], - [requirement_placement], - [requirement_corroboration]], - iterative=True, - name=("elementary_length_2_requirement_with_point_placement_" - "no_factors")) - -elementary_length_2_requirement_with_pattern_placement_no_factors = Pack( - initial_strats=[requirement_placement], - ver_strats=[elementary_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=2), - partial(all_requirement_extensions, maxreqlen=2)], - [requirement_corroboration]], - iterative=True, - name=("elementary_length_2_requirement_with_pattern_placement_" - "no_factors")) - -elementary_length_3_requirement_with_point_placement_no_factors = Pack( - initial_strats=[], - ver_strats=[elementary_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=3)], - [requirement_placement], - [requirement_corroboration]], - iterative=True, - name=("elementary_length_3_requirement_with_point_placement_" - "no_factors")) - -elementary_length_3_requirement_with_pattern_placement_no_factors = Pack( - initial_strats=[requirement_placement], - ver_strats=[elementary_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=3), - partial(all_requirement_extensions, maxreqlen=3)], - [requirement_corroboration]], - iterative=True, - name=("elementary_length_3_requirement_with_pattern_placement_" - "no_factors")) - -natural_point_placement_no_database_only = Pack( - initial_strats=[requirement_placement], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(factor, workable=False, unions=True)], - [all_point_insertions], - [requirement_corroboration]], - name="natural_point_placement_no_database") - -natural_length_2_requirement_with_point_placement_no_database = Pack( - initial_strats=[], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(factor, workable=False, unions=True)], - [partial(all_cell_insertions, maxreqlen=2)], - [requirement_placement], - [requirement_corroboration]], - name="natural_length_2_requirement_point_placement_no_database") - -natural_length_2_requirement_with_pattern_placement_no_database = Pack( - initial_strats=[requirement_placement], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(factor, workable=False, unions=True)], - [partial(all_cell_insertions, maxreqlen=2), - partial(all_requirement_extensions, maxreqlen=2)], - [requirement_corroboration]], - name="natural_length_2_requirement_pattern_placement_no_database") - -natural_length_3_requirement_with_point_placement_no_database = Pack( - initial_strats=[], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(factor, workable=False, unions=True)], - [partial(all_cell_insertions, maxreqlen=3)], - [requirement_placement], - [requirement_corroboration]], - name="natural_length_3_requirement_point_placement_no_database") - -natural_length_3_requirement_with_pattern_placement_no_database = Pack( - initial_strats=[requirement_placement], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(factor, workable=False, unions=True)], - [partial(all_cell_insertions, maxreqlen=3), - partial(all_requirement_extensions, maxreqlen=3)], - [requirement_corroboration]], - name="natural_length_3_requirement_pattern_placement_no_database") - -point_placement_no_database_interleaving = Pack( - initial_strats=[requirement_placement], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(factor, interleaving=True)], - [all_point_insertions], - [requirement_corroboration]], - forward_equivalence=True, - name="point_placement_no_database_interleaving") - -length_2_requirement_with_point_placement_no_database_interleaving = Pack( - initial_strats=[], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(factor, interleaving=True)], - [partial(all_cell_insertions, maxreqlen=2)], - [requirement_placement], - [requirement_corroboration]], - forward_equivalence=True, - name=("length_2_requirement_with_point_placement_" - "no_database_interleaving")) - -length_2_requirement_with_pattern_placement_no_database_interleaving = Pack( - initial_strats=[requirement_placement], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(factor, unions=True, interleaving=True)], - [partial(all_cell_insertions, maxreqlen=2), - partial(all_requirement_extensions, maxreqlen=2)], - [requirement_corroboration]], - forward_equivalence=True, - name=("length_2_requirement_with_pattern_placement_" - "no_database_interleaving")) - -length_3_requirement_with_point_placement_no_database_interleaving = Pack( - initial_strats=[], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(factor, interleaving=True)], - [partial(all_cell_insertions, maxreqlen=3)], - [requirement_placement], - [requirement_corroboration]], - forward_equivalence=True, - name=("length_3_requirement_with_point_placement_" - "no_database_interleaving")) - -length_3_requirement_with_pattern_placement_no_database_interleaving = Pack( - initial_strats=[requirement_placement], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[partial(factor, unions=True, interleaving=True)], - [partial(all_cell_insertions, maxreqlen=3), - partial(all_requirement_extensions, maxreqlen=3)], - [requirement_corroboration]], - forward_equivalence=True, - name=("length_3_requirement_with_pattern_placement_no" - "_database_interleaving")) - -point_placements_with_fusion = Pack( - initial_strats=[factor, requirement_placement, fusion], - ver_strats=[subset_verified], - inferral_strats=[row_and_column_separation], - expansion_strats=[[all_point_insertions]], - forward_equivalence=True, - name="point_placements_with_fusion") - -point_placements_with_int_fusion = Pack( - initial_strats=[factor, requirement_placement, - fusion_with_interleaving], - ver_strats=[subset_verified], - inferral_strats=[row_and_column_separation], - expansion_strats=[[all_point_insertions]], - forward_equivalence=True, - name="point_placements_with_int_fusion") - -length_2_requirement_with_point_placements_and_fusion = Pack( - initial_strats=[factor, fusion], - ver_strats=[subset_verified], - inferral_strats=[row_and_column_separation], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=2)], - [requirement_placement]], - forward_equivalence=True, - name="length_2_requirement_with_point_placements_and_fusion") - -length_3_requirement_with_point_placements_and_fusion = Pack( - initial_strats=[factor, fusion], - ver_strats=[subset_verified], - inferral_strats=[row_and_column_separation], - expansion_strats=[[partial(all_cell_insertions, maxreqlen=3)], - [requirement_placement]], - forward_equivalence=True, - name="length_3_requirement_with_point_placements_and_fusion") - -insertion_point_placements_with_fusion = Pack( - initial_strats=[factor, fusion, requirement_corroboration, - partial(all_point_insertions, ignore_parent=True)], - ver_strats=[subset_verified, globally_verified], - inferral_strats=[row_and_column_separation, obstruction_transitivity], - expansion_strats=[[requirement_placement]], - forward_equivalence=True, - name="insertion_point_placements_db") diff --git a/tilescopethree/strategy_packs_v2.py b/tilescopethree/strategy_packs_v2.py index b59c4f4ca..9c74b3791 100644 --- a/tilescopethree/strategy_packs_v2.py +++ b/tilescopethree/strategy_packs_v2.py @@ -8,12 +8,9 @@ all_requirement_insertions, all_row_insertions) from tilescopethree.strategies import col_placements as col_placements_strat -from tilescopethree.strategies import (database_verified, elementary_verified, - factor, fusion, +from tilescopethree.strategies import (factor, fusion, fusion_with_interleaving, - globally_verified, obstruction_transitivity, - one_by_one_verified, partial_requirement_placement, requirement_corroboration, requirement_list_placement, @@ -21,8 +18,10 @@ root_requirement_insertion, row_and_column_separation) from tilescopethree.strategies import row_placements as row_placements_strat -from tilescopethree.strategies import (subobstruction_inferral, - subset_verified, verify_atoms) +from tilescopethree.strategies import (subobstruction_inferral, verify_basic, + verify_database, verify_elementary, + verify_local, verify_locally_factorable, + verify_one_by_one) from tilings import Tiling @@ -90,14 +89,14 @@ def add_symmetry(self): iterative=self.iterative) def make_elementary(self): - if ([elementary_verified] == self.ver_strats and + if ([verify_elementary] == self.ver_strats and self.forward_equivalence and self.iterative): raise ValueError("The pack is already elementary.") name = "elementary_" + self.name return self.__class__(self.initial_strats, self.inferral_strats, self.expansion_strats, - [elementary_verified], name, + [verify_elementary], name, symmetries=self.symmetries, forward_equivalence=True, iterative=True) @@ -120,8 +119,8 @@ def all_the_strategies(cls, length=1): return TileScopePack( initial_strats=[partial(factor, unions=True), requirement_corroboration], - ver_strats=[subset_verified, - globally_verified, one_by_one_verified], + ver_strats=[verify_local, + verify_locally_factorable, verify_one_by_one], inferral_strats=[row_and_column_separation, obstruction_transitivity], expansion_strats=[[partial(all_cell_insertions, @@ -138,8 +137,8 @@ def pattern_placements(cls, length=1, partial_placements=False): if partial_placements else requirement_placement) return TileScopePack( initial_strats=[placement], - ver_strats=[subset_verified, - globally_verified, one_by_one_verified], + ver_strats=[verify_local, + verify_locally_factorable, verify_one_by_one], inferral_strats=[row_and_column_separation, obstruction_transitivity], expansion_strats=[[partial(factor, unions=True)], @@ -159,8 +158,8 @@ def point_placements(cls, length=1, partial_placements=False): if partial_placements else requirement_placement) return TileScopePack( initial_strats=[factor, requirement_corroboration], - ver_strats=[subset_verified, - globally_verified, one_by_one_verified], + ver_strats=[verify_local, + verify_locally_factorable, verify_one_by_one], inferral_strats=[row_and_column_separation, obstruction_transitivity], expansion_strats=[[partial(all_cell_insertions, @@ -178,8 +177,8 @@ def insertion_point_placements(cls, length=1): initial_strats=[factor, requirement_corroboration, partial(all_cell_insertions, maxreqlen=length, ignore_parent=True)], - ver_strats=[subset_verified, - globally_verified, one_by_one_verified], + ver_strats=[verify_local, + verify_locally_factorable, verify_one_by_one], inferral_strats=[row_and_column_separation, obstruction_transitivity], expansion_strats=[[requirement_placement]], @@ -204,7 +203,7 @@ def regular_insertion_encoding(cls, direction=None): initial_strats=[factor, requirement_corroboration, partial(all_cell_insertions, ignore_parent=True)], - ver_strats=[verify_atoms], + ver_strats=[verify_basic], inferral_strats=[], expansion_strats=[expansion_strats], name="regular_insertion_encoding_{}".format( @@ -227,8 +226,8 @@ def row_and_col_placements(cls, row_only=False, col_only=False): positive=False)) return TileScopePack( initial_strats=[factor, requirement_corroboration], - ver_strats=[subset_verified, - globally_verified, one_by_one_verified], + ver_strats=[verify_local, + verify_locally_factorable, verify_one_by_one], inferral_strats=[row_and_column_separation, obstruction_transitivity], expansion_strats=[expansion_strats], @@ -252,8 +251,8 @@ def insertion_row_and_col_placements(cls, row_only=False, col_only=False): initial_strats=[factor, requirement_corroboration, partial(all_cell_insertions, ignore_parent=True)], - ver_strats=[subset_verified, - globally_verified, one_by_one_verified], + ver_strats=[verify_local, + verify_locally_factorable, verify_one_by_one], inferral_strats=[row_and_column_separation, obstruction_transitivity], expansion_strats=[expansion_strats], @@ -268,10 +267,10 @@ def only_root_placements(cls, length=1): initial_strats=[partial(requirement_placement, ignore_parent=True), factor], - ver_strats=[verify_atoms, - partial(subset_verified, + ver_strats=[verify_basic, + partial(verify_local, no_factors=True, no_reqs=True), - one_by_one_verified], + verify_one_by_one], inferral_strats=[row_and_column_separation, obstruction_transitivity], expansion_strats=[[partial(root_requirement_insertion, @@ -287,8 +286,8 @@ def requirement_placements(cls, length=2, partial_placements=False): if partial_placements else requirement_placement) return TileScopePack( initial_strats=[factor, requirement_corroboration], - ver_strats=[subset_verified, - globally_verified, one_by_one_verified], + ver_strats=[verify_local, + verify_locally_factorable, verify_one_by_one], inferral_strats=[row_and_column_separation, obstruction_transitivity], expansion_strats=[[partial(all_requirement_insertions, @@ -361,9 +360,9 @@ def requirement_placements(cls, length=2, partial_placements=False): for pack in basepacks: fusion_pack = pack.make_fusion() - fusion_datab = fusion_pack.add_verification(database_verified) + fusion_datab = fusion_pack.add_verification(verify_database) other_fusion = pack.make_fusion(interleaving=True) - other_fusion_datab = other_fusion.add_verification(database_verified) + other_fusion_datab = other_fusion.add_verification(verify_database) unreasonable_fusion = other_fusion.make_fusion() setattr(module, fusion_pack.name, fusion_pack) setattr(module, fusion_datab.name, fusion_datab) @@ -379,7 +378,7 @@ def requirement_placements(cls, length=2, partial_placements=False): for pack in basepacks: new_packs = [pack] for new_pack in tuple(new_packs): - new_packs.append(new_pack.add_verification(database_verified)) + new_packs.append(new_pack.add_verification(verify_database)) for new_pack in tuple(new_packs): new_packs.append(new_pack.add_symmetry()) for new_pack in tuple(new_packs): @@ -396,6 +395,6 @@ def requirement_placements(cls, length=2, partial_placements=False): expansion_strats=[[all_cell_insertions, partial(row_placements_strat, positive=False), partial(col_placements_strat, positive=False)]], - ver_strats=[one_by_one_verified], + ver_strats=[verify_one_by_one], forward_equivalence=True, name="restricted_fusion") diff --git a/tilescopethree/universescope.py b/tilescopethree/universescope.py deleted file mode 100644 index 9ed935c43..000000000 --- a/tilescopethree/universescope.py +++ /dev/null @@ -1,160 +0,0 @@ -import json -import time -from itertools import combinations - -from comb_spec_searcher import CombinatorialSpecificationSearcher, ProofTree -from comb_spec_searcher.tree_searcher import (iterative_proof_tree_finder, - iterative_prune, - proof_tree_generator_bfs, - proof_tree_generator_dfs, prune, - random_proof_tree) -from permuta import PermSet -from tilescopethree.strategies import verify_atoms -from tilescopethree.strategy_packs_v2 import (row_and_col_placements, - row_placements) -from tilings import Obstruction, Tiling - - -class UniveralScope(CombinatorialSpecificationSearcher): - def __init__( - self, - n=None, - k=None, - strategy_pack=None, - flogger_kwargs={ - 'processname': 'runner'}, - **kwargs): - self.start_tilings = [] - if filename is not None: - assert n is None and k is None - f = open(filename, 'r') - for line in f: - line = line.strip() - self.start_tilings.append(Tiling.from_string(line)) - f.close() - else: - for basis in combinations(PermSet(n), k): - self.start_tilings.append( - Tiling([Obstruction.single_cell(patt, (0, 0)) - for patt in basis])) - - strategy_pack.ver_strats = [verify_atoms] - - function_kwargs = {"basis": []} - function_kwargs.update(kwargs.get('kwargs', dict())) - - CombinatorialSpecificationSearcher.__init__( - self, - self.start_tilings[0], - strategy_pack, - function_kwargs=function_kwargs, - **kwargs) - - self.start_labels = [] - for start_tiling in self.start_tilings: - self.classdb.add(start_tiling, expandable=True) - self.start_labels.append(self.classdb.get_label(start_tiling)) - for label in self.start_labels: - self.classqueue.add_to_working(label) - - def has_proof_tree(self): - return all(self.equivdb.is_verified(label) - for label in self.start_labels) - - def find_trees(self): - """Search for a random tree based on current data found.""" - start = time.time() - - rules_dict = self.tree_search_prep() - # Prune all unverified labels (recursively) - if self.iterative: - rules_dict = iterative_prune(rules_dict, - root=self.equivdb[self.start_label]) - else: - rules_dict = prune(rules_dict) - - # only verified labels in rules_dict, in particular, there is a proof - # tree if the start label is in the rules_dict - for label in rules_dict.keys(): - self.equivdb.update_verified(label) - trees = [] - for label in self.start_labels: - if label in rules_dict: - if self.iterative: - proof_tree = iterative_proof_tree_finder( - rules_dict, - root=self.equivdb[label]) - else: - proof_tree = random_proof_tree( - rules_dict, - root=self.equivdb[label]) - else: - proof_tree = None - - trees.append(proof_tree) - - self.tree_search_time += time.time() - start - self._time_taken += time.time() - start - return trees - - def auto_search(self, **kwargs): - verbose = kwargs.get('verbose', False) - kwargs['verbose'] = False - - if verbose: - max_time = kwargs.get('max_time', None) - kwargs['max_time'] = kwargs.get('status_update', None) - status_update = kwargs.get('status_update', None) - kwargs['status_update'] = None - print("Starting universe scope with the tilings:") - for t in self.start_tilings: - print(t) - else: - max_time = kwargs.get('max_time', None) - status_update = None - - trees = None - time = 0 - while trees is None: - trees = CombinatorialSpecificationSearcher.auto_search( - self, **kwargs) - time += self._time_taken - if max_time is not None and max_time > time: - break - if status_update is not None: - kwargs['max_time'] = self._time_taken + status_update - if verbose: - print(scope.status()) - - if verbose: - print("PROOF TREES FOUND") - for start_tiling, tree in zip(self.start_tilings, trees): - print(start_tiling) - print(json.dumps(tree.to_jsonable())) - - def get_proof_tree(self): - proof_tree_nodes = self.find_trees() - if all(node is not None for node in proof_tree_nodes): - proof_trees = [] - for proof_tree_node in proof_tree_nodes: - proof_tree = ProofTree.from_comb_spec_searcher(proof_tree_node, - self) - proof_trees.append(proof_tree) - assert proof_tree is not None - return proof_trees - - @classmethod - def from_file(self, filename): - return UniveralScope(filename=filename) - - -if __name__ == '__main__': - import sys - filename = sys.argv[1] - - scope = UniveralScope( - filename=filename, - strategy_pack=row_and_col_placements) - trees = scope.auto_search(verbose=True, status_update=30) - trees = scope.auto_search() - print(scope.status()) From 86483e6e6e263bed9665394197dc44f8e52af7b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20Nadeau?= Date: Mon, 3 Feb 2020 11:50:35 +0000 Subject: [PATCH 02/12] migrate inferral strategies --- .../strategies/inferral_strategies.py | 4 ++++ .../inferral_strategies/__init__.py | 4 ---- .../obstruction_transitivity.py | 14 ------------- .../row_and_column_separation.py | 8 ------- .../subobstruction_inferral.py | 21 ------------------- 5 files changed, 4 insertions(+), 47 deletions(-) create mode 100644 tilescopethree/strategies/inferral_strategies.py delete mode 100644 tilescopethree/strategies/inferral_strategies/__init__.py delete mode 100644 tilescopethree/strategies/inferral_strategies/obstruction_transitivity.py delete mode 100644 tilescopethree/strategies/inferral_strategies/row_and_column_separation.py delete mode 100644 tilescopethree/strategies/inferral_strategies/subobstruction_inferral.py diff --git a/tilescopethree/strategies/inferral_strategies.py b/tilescopethree/strategies/inferral_strategies.py new file mode 100644 index 000000000..26f9034a9 --- /dev/null +++ b/tilescopethree/strategies/inferral_strategies.py @@ -0,0 +1,4 @@ +from tilings.strategies.inferral import (empty_cell_inferral, + obstruction_transitivity, + row_and_column_separation, + subobstruction_inferral) diff --git a/tilescopethree/strategies/inferral_strategies/__init__.py b/tilescopethree/strategies/inferral_strategies/__init__.py deleted file mode 100644 index fe8ec69e5..000000000 --- a/tilescopethree/strategies/inferral_strategies/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from .obstruction_transitivity import obstruction_transitivity -from .row_and_column_separation import row_and_column_separation -from .subobstruction_inferral import (empty_cell_inferral, - subobstruction_inferral) diff --git a/tilescopethree/strategies/inferral_strategies/obstruction_transitivity.py b/tilescopethree/strategies/inferral_strategies/obstruction_transitivity.py deleted file mode 100644 index 0af760d8d..000000000 --- a/tilescopethree/strategies/inferral_strategies/obstruction_transitivity.py +++ /dev/null @@ -1,14 +0,0 @@ -from tilings.algorithms import ObstructionTransitivity - - -def obstruction_transitivity(tiling, **kwargs): - """The obstruction transitivity strategy. - - The obstruction transitivity considers all length 2 obstructions with both - points in the same row or some column. By considering these length 2 - obstructions in similar manner as the row and column separation, as - inequality relations. When the the obstructions use a positive cell, - transitivity applies, i.e. if a < b < c and b is positive, then a < c. - """ - obs_trans = ObstructionTransitivity(tiling) - return obs_trans.rule() diff --git a/tilescopethree/strategies/inferral_strategies/row_and_column_separation.py b/tilescopethree/strategies/inferral_strategies/row_and_column_separation.py deleted file mode 100644 index 6805e3501..000000000 --- a/tilescopethree/strategies/inferral_strategies/row_and_column_separation.py +++ /dev/null @@ -1,8 +0,0 @@ -"""An inferral function that tries to separate cells in rows and columns.""" - -from tilings.algorithms import RowColSeparation - - -def row_and_column_separation(tiling, **kwargs): - rcs = RowColSeparation(tiling) - return rcs.rule() diff --git a/tilescopethree/strategies/inferral_strategies/subobstruction_inferral.py b/tilescopethree/strategies/inferral_strategies/subobstruction_inferral.py deleted file mode 100644 index 82f029d76..000000000 --- a/tilescopethree/strategies/inferral_strategies/subobstruction_inferral.py +++ /dev/null @@ -1,21 +0,0 @@ -from comb_spec_searcher import InferralRule -from permuta import Perm -from tilings import Obstruction, Tiling -from tilings.algorithms import EmptyCellInferral, SubobstructionInferral - - -def empty_cell_inferral(tiling, **kwargs): - """The empty cell inferral strategy. - - The strategy considers each active but non-positive cell and inserts a - point requirement. If the resulting tiling is empty, then a point - obstruction can be added into the cell, i.e. the cell is empty.""" - eci = EmptyCellInferral(tiling) - return eci.rule() - - -def subobstruction_inferral(tiling, **kwargs): - """Return tiling created by adding all subobstructions which can be - added.""" - soi = SubobstructionInferral(tiling) - return soi.rule() From 39ef04ce4a4383855bd962000e6e57ca097958ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20Nadeau?= Date: Mon, 3 Feb 2020 12:28:45 +0000 Subject: [PATCH 03/12] migrate decomposition strategies --- .../decomposition_strategies/test_factor.py | 3 +- .../strategies/decomposition_strategies.py | 4 ++ .../decomposition_strategies/__init__.py | 4 -- .../decomposition_strategies/factor.py | 44 ------------------- 4 files changed, 5 insertions(+), 50 deletions(-) create mode 100644 tilescopethree/strategies/decomposition_strategies.py delete mode 100644 tilescopethree/strategies/decomposition_strategies/__init__.py delete mode 100644 tilescopethree/strategies/decomposition_strategies/factor.py diff --git a/tests/strategies/decomposition_strategies/test_factor.py b/tests/strategies/decomposition_strategies/test_factor.py index c66b27515..66a39e6b3 100644 --- a/tests/strategies/decomposition_strategies/test_factor.py +++ b/tests/strategies/decomposition_strategies/test_factor.py @@ -3,11 +3,10 @@ factor, factor_with_interleaving, factor_with_monotone_interleaving, unions_of_factor, unions_of_factor_with_interleaving, unions_of_factor_with_monotone_interleaving) -from tilescopethree.strategies.decomposition_strategies.factor import \ - general_factor from tilings import Obstruction, Requirement, Tiling from tilings.algorithms import (Factor, FactorWithInterleaving, FactorWithMonotoneInterleaving) +from tilings.strategies.decomposition import general_factor pytest_plugins = [ 'tests.fixtures.simple_tiling', diff --git a/tilescopethree/strategies/decomposition_strategies.py b/tilescopethree/strategies/decomposition_strategies.py new file mode 100644 index 000000000..48640313e --- /dev/null +++ b/tilescopethree/strategies/decomposition_strategies.py @@ -0,0 +1,4 @@ +from tilings.strategies.decomposition import ( + factor, factor_with_interleaving, factor_with_monotone_interleaving, + unions_of_factor, unions_of_factor_with_interleaving, + unions_of_factor_with_monotone_interleaving) diff --git a/tilescopethree/strategies/decomposition_strategies/__init__.py b/tilescopethree/strategies/decomposition_strategies/__init__.py deleted file mode 100644 index 761ae5f5a..000000000 --- a/tilescopethree/strategies/decomposition_strategies/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from .factor import (factor, factor_with_interleaving, - factor_with_monotone_interleaving, unions_of_factor, - unions_of_factor_with_interleaving, - unions_of_factor_with_monotone_interleaving) diff --git a/tilescopethree/strategies/decomposition_strategies/factor.py b/tilescopethree/strategies/decomposition_strategies/factor.py deleted file mode 100644 index fb400bcf8..000000000 --- a/tilescopethree/strategies/decomposition_strategies/factor.py +++ /dev/null @@ -1,44 +0,0 @@ -from itertools import chain - -from comb_spec_searcher import Rule -from tilings.algorithms import (Factor, FactorWithInterleaving, - FactorWithMonotoneInterleaving) - - -def general_factor(tiling, factor_class, union=False, **kwargs): - """ - Iterator of factor strategy. - """ - assert factor_class in [Factor, FactorWithMonotoneInterleaving, - FactorWithInterleaving] - workable = kwargs.get('workable', True) - factor = factor_class(tiling) - if factor.factorable(): - yield factor.rule(workable=workable) - if union: - yield from factor.all_union_rules() - - -def factor(tiling, **kwargs): - return general_factor(tiling, Factor, **kwargs) - - -def factor_with_monotone_interleaving(tiling, **kwargs): - return general_factor(tiling, FactorWithMonotoneInterleaving, **kwargs) - - -def factor_with_interleaving(tiling, **kwargs): - return general_factor(tiling, FactorWithInterleaving, **kwargs) - - -def unions_of_factor(tiling, **kwargs): - return general_factor(tiling, Factor, union=True, **kwargs) - - -def unions_of_factor_with_monotone_interleaving(tiling, **kwargs): - return general_factor(tiling, FactorWithMonotoneInterleaving, union=True, - **kwargs) - - -def unions_of_factor_with_interleaving(tiling, **kwargs): - return general_factor(tiling, FactorWithInterleaving, union=True, **kwargs) From 58dc6df6028786c9ff48fdb2d0b2f2521f1ab8c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20Nadeau?= Date: Mon, 3 Feb 2020 14:29:42 +0000 Subject: [PATCH 04/12] migrate equivalence strategies --- ...terleaving.py => test_component_fusion.py} | 6 +- .../equivalence_strategies/test_fusion.py | 2 +- tests/test_tilescope.py | 8 +- .../strategies/equivalence_strategies.py | 5 + .../equivalence_strategies/__init__.py | 7 - .../equivalence_strategies/deflation.py | 151 ------------------ .../equivalence_strategies/fusion.py | 25 --- .../fusion_with_interleaving.py | 17 -- .../equivalence_strategies/isolate_points.py | 12 -- .../partial_point_placements.py | 28 ---- .../point_placements.py | 35 ---- tilescopethree/strategy_packs_v2.py | 5 +- 12 files changed, 15 insertions(+), 286 deletions(-) rename tests/strategies/equivalence_strategies/{test_fusion_with_interleaving.py => test_component_fusion.py} (87%) create mode 100644 tilescopethree/strategies/equivalence_strategies.py delete mode 100644 tilescopethree/strategies/equivalence_strategies/__init__.py delete mode 100644 tilescopethree/strategies/equivalence_strategies/deflation.py delete mode 100644 tilescopethree/strategies/equivalence_strategies/fusion.py delete mode 100644 tilescopethree/strategies/equivalence_strategies/fusion_with_interleaving.py delete mode 100644 tilescopethree/strategies/equivalence_strategies/isolate_points.py delete mode 100644 tilescopethree/strategies/equivalence_strategies/partial_point_placements.py delete mode 100644 tilescopethree/strategies/equivalence_strategies/point_placements.py diff --git a/tests/strategies/equivalence_strategies/test_fusion_with_interleaving.py b/tests/strategies/equivalence_strategies/test_component_fusion.py similarity index 87% rename from tests/strategies/equivalence_strategies/test_fusion_with_interleaving.py rename to tests/strategies/equivalence_strategies/test_component_fusion.py index 28b76a7f3..27bfebaaa 100644 --- a/tests/strategies/equivalence_strategies/test_fusion_with_interleaving.py +++ b/tests/strategies/equivalence_strategies/test_component_fusion.py @@ -1,7 +1,7 @@ import pytest from permuta import Perm -from tilescopethree.strategies import fusion_with_interleaving +from tilescopethree.strategies import component_fusion from tilings import Obstruction, Tiling @@ -37,5 +37,5 @@ def tiling2(): def test_fusion_with_interleaving(tiling1, tiling2): - assert len(list(fusion_with_interleaving(tiling1))) == 0 - assert len(list(fusion_with_interleaving(tiling2))) == 1 + assert len(list(component_fusion(tiling1))) == 0 + assert len(list(component_fusion(tiling2))) == 1 diff --git a/tests/strategies/equivalence_strategies/test_fusion.py b/tests/strategies/equivalence_strategies/test_fusion.py index 052087c8e..dbed429b5 100644 --- a/tests/strategies/equivalence_strategies/test_fusion.py +++ b/tests/strategies/equivalence_strategies/test_fusion.py @@ -2,7 +2,7 @@ from comb_spec_searcher import Rule from permuta import Perm -from tilescopethree.strategies.equivalence_strategies.fusion import fusion +from tilescopethree.strategies.equivalence_strategies import fusion from tilings import Obstruction, Tiling diff --git a/tests/test_tilescope.py b/tests/test_tilescope.py index 332cce154..3b2112a41 100644 --- a/tests/test_tilescope.py +++ b/tests/test_tilescope.py @@ -5,8 +5,8 @@ from tilescopethree import TileScopeTHREE from tilescopethree.strategy_packs_v2 import ( all_the_strategies_verify_database, point_placements, - point_placements_fusion, point_placements_fusion_with_interleaving, - row_and_col_placements_fusion_with_interleaving_fusion) + point_placements_component_fusion, point_placements_fusion, + row_and_col_placements_component_fusion_fusion) @pytest.mark.timeout(20) @@ -43,7 +43,7 @@ def test_123_with_db(): @pytest.mark.timeout(20) def test_1342_1423(): searcher = TileScopeTHREE('1342_1423', - point_placements_fusion_with_interleaving) + point_placements_component_fusion) t = searcher.auto_search(smallest=True) t.number_of_nodes() == 14 assert isinstance(t, ProofTree) @@ -53,7 +53,7 @@ def test_1342_1423(): def test_1324(): searcher = TileScopeTHREE( '1324', - row_and_col_placements_fusion_with_interleaving_fusion + row_and_col_placements_component_fusion_fusion ) t = searcher.auto_search(smallest=True) t.number_of_nodes() == 14 diff --git a/tilescopethree/strategies/equivalence_strategies.py b/tilescopethree/strategies/equivalence_strategies.py new file mode 100644 index 000000000..fff24ec43 --- /dev/null +++ b/tilescopethree/strategies/equivalence_strategies.py @@ -0,0 +1,5 @@ +from tilings.strategies.equivalence import (all_placements, component_fusion, + fusion, partial_point_placement, + partial_requirement_placement, + point_placement, + requirement_placement) diff --git a/tilescopethree/strategies/equivalence_strategies/__init__.py b/tilescopethree/strategies/equivalence_strategies/__init__.py deleted file mode 100644 index 8bf92279f..000000000 --- a/tilescopethree/strategies/equivalence_strategies/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -from .deflation import deflation -from .fusion import fusion -from .fusion_with_interleaving import fusion_with_interleaving -from .partial_point_placements import (partial_point_placement, - partial_requirement_placement) -from .point_placements import (all_placements, point_placement, - requirement_placement) diff --git a/tilescopethree/strategies/equivalence_strategies/deflation.py b/tilescopethree/strategies/equivalence_strategies/deflation.py deleted file mode 100644 index 6ddf09483..000000000 --- a/tilescopethree/strategies/equivalence_strategies/deflation.py +++ /dev/null @@ -1,151 +0,0 @@ -"""The deflation strategy.""" -from comb_spec_searcher import Rule -from permuta import Perm -from tilings import Obstruction, Tiling - - -def deflation(tiling, **kwargs): - """Yield all deflation strategies. - TODO: Think about how this works with requirements.""" - if tiling.requirements: - return - bases = tiling.cell_basis() - for cell in tiling.possibly_empty: - cell_basis = bases[cell][0] - if sum_closed(cell_basis): - if can_deflate(tiling, cell, True): - yield Rule("Sum deflate cell {}.".format(cell), - [deflated_tiling(tiling, cell, sum_decomp=True)], - inferable=[True], workable=[True], - possibly_empty=[False], ignore_parent=False, - constructor="other") - if skew_closed(cell_basis): - if can_deflate(tiling, cell, False): - yield Rule("Skew deflate cell {}.".format(cell), - [deflated_tiling(tiling, cell, sum_decomp=False)], - inferable=[True], workable=[True], - possibly_empty=[False], ignore_parent=False, - constructor="other") - - -def sum_closed(basis): - return all(not p.is_sum_decomposable() for p in basis) - - -def skew_closed(basis): - return all(not p.is_skew_decomposable() for p in basis) - - -def can_deflate(tiling, cell, sum_decomp): - alone_in_row = tiling.only_cell_in_row(cell) - alone_in_col = tiling.only_cell_in_col(cell) - - if alone_in_row and alone_in_col: - return False - - deflate_patt = Obstruction.single_cell(Perm((1, 0)) if sum_decomp - else Perm((0, 1)), cell) - - # we must be sure that no cell in a row or column can interleave - # with any reinflated components, so collect cells that do not. - cells_not_interleaving = set([cell]) - - for ob in tiling.obstructions: - if ob == deflate_patt: - return False - if ob.is_single_cell() or not ob.occupies(cell): - continue - number_points_in_cell = sum(1 for c in ob.pos if c == cell) - if number_points_in_cell == 1: - if len(ob) == 2: - # not interleaving with cell as separating if - # in same row or column - other_cell = [c for c in ob.pos if c != cell][0] - cells_not_interleaving.add(other_cell) - elif number_points_in_cell == 2: - if len(ob) != 3: - return False - patt_in_cell = ob.get_gridded_perm_in_cells((cell, )) - if patt_in_cell != deflate_patt: - # you can interleave with components - return False - # we need the other cell to be in between the intended deflate - # patt in either the row or column - other_cell = [c for c in ob.pos if c != cell][0] - if (point_in_between(ob, True, cell, other_cell) or - point_in_between(ob, False, cell, other_cell)): - # this cell does not interleave with inflated components - cells_not_interleaving.add(other_cell) - else: - return False - elif number_points_in_cell >= 3: - # you can interleave with components - return False - # check that do not interleave with any cells in row or column. - return (cells_not_interleaving >= tiling.cells_in_row(cell[1]) and - cells_not_interleaving >= tiling.cells_in_col(cell[0])) - - -# def can_deflate(tiling, cell, sum_decomp): -# """Return True if can deflate cell, else False.""" -# row = tiling.only_cell_in_col(cell) -# col = tiling.only_cell_in_row(cell) -# if not row and not col: -# return False -# deflating = set() -# sumpatt = Obstruction.single_cell(Perm((1, 0)) if sum_decomp -# else Perm((0, 1)), cell) -# for ob in tiling.obstructions: -# if ob == sumpatt: -# return False -# if ob.is_single_cell() or not ob.occupies(cell): -# continue -# if len(ob) == 2: -# other_cell = [c for c in ob.pos if c != cell][0] -# deflating.add(other_cell) -# continue -# n = sum(1 for c in ob.pos if c == cell) -# if n == 1: -# continue -# if n > 2 or len(ob) > 3: -# if sum(1 for c in ob.pos if c != cell) != 1: -# return False -# other_cell = [c for c in ob.pos if c != cell][0] -# if ((row and other_cell[1] != cell[1]) or -# (col and other_cell[0] != cell[0])): -# return False -# if ob.patt.is_decreasing() or ob.patt.is_increasing(): -# continue -# patt_in_cell = Perm.to_standard([x for x, y in zip(ob.patt, ob.pos) -# if y == cell]) -# if ((sum_decomp and patt_in_cell == Perm((1, 0))) or -# (not sum_decomp and patt_in_cell == Perm((0, 1)))): -# if point_in_between(ob, row, cell, other_cell): -# deflating.add(other_cell) -# return ((not col or deflating >= set(tiling.cells_in_col(cell[0]))) -# and (not row or deflating >= set(tiling.cells_in_row(cell[1])))) - -def point_in_between(ob, row, cell, other_cell): - """Return true if point in other cell is in between point in cell. - Assumes a length 3 pattern, and to be told if row or column.""" - if row: - left = other_cell[0] < cell[0] - if left: - return ob.patt[0] == 1 - else: - return ob.patt[2] == 1 - below = other_cell[1] < cell[1] - if below: - return ob.patt[1] == 0 - else: - return ob.patt[1] == 2 - - -def deflated_tiling(tiling, cell, sum_decomp=True): - """Return tiling where cell is deflated.""" - if sum_decomp: - extra = Obstruction.single_cell(Perm((1, 0)), cell) - else: - extra = Obstruction.single_cell(Perm((0, 1)), cell) - return Tiling(requirements=tiling.requirements, - obstructions=tiling.obstructions + (extra, )) diff --git a/tilescopethree/strategies/equivalence_strategies/fusion.py b/tilescopethree/strategies/equivalence_strategies/fusion.py deleted file mode 100644 index 346abc27f..000000000 --- a/tilescopethree/strategies/equivalence_strategies/fusion.py +++ /dev/null @@ -1,25 +0,0 @@ -"""The fusion strategy.""" -from itertools import chain - -from comb_spec_searcher import Rule -from tilings.algorithms import Fusion - - -def general_fusion_iterator(tiling, fusion_class): - """ - Generator over rules found by fusing rows or columns of `tiling` using - the fusion defined by `fusion_class`. - """ - assert issubclass(fusion_class, Fusion) - ncol = tiling.dimensions[0] - nrow = tiling.dimensions[1] - possible_fusion = chain( - (fusion_class(tiling, row_idx=r) for r in range(nrow-1)), - (fusion_class(tiling, col_idx=c) for c in range(ncol-1)) - ) - return (fusion.rule() for fusion in possible_fusion if fusion.fusable()) - - -def fusion(tiling, **kwargs): - """Generator over rules found by fusing rows or columns of `tiling`.""" - return general_fusion_iterator(tiling, fusion_class=Fusion) diff --git a/tilescopethree/strategies/equivalence_strategies/fusion_with_interleaving.py b/tilescopethree/strategies/equivalence_strategies/fusion_with_interleaving.py deleted file mode 100644 index e707d45ff..000000000 --- a/tilescopethree/strategies/equivalence_strategies/fusion_with_interleaving.py +++ /dev/null @@ -1,17 +0,0 @@ -"""The more general fusion strategy. Fuse two rows if actually one row where -you can draw a line somewhere.""" -from comb_spec_searcher import Rule -from tilings.algorithms import ComponentFusion - -from .fusion import general_fusion_iterator - - -def fusion_with_interleaving(tiling, **kwargs): - """ - Yield rules found by fusing rows and columns of a tiling, where the - unfused tiling obtained by drawing a line through certain heights/indices - of the row/column. - """ - if tiling.requirements: - return - yield from general_fusion_iterator(tiling, ComponentFusion) diff --git a/tilescopethree/strategies/equivalence_strategies/isolate_points.py b/tilescopethree/strategies/equivalence_strategies/isolate_points.py deleted file mode 100644 index 7d8549321..000000000 --- a/tilescopethree/strategies/equivalence_strategies/isolate_points.py +++ /dev/null @@ -1,12 +0,0 @@ -from comb_spec_searcher import EquivalenceRule -from permuta.misc import DIR_WEST -from tilings.algorithms import RequirementPlacement - - -def point_isolations(tiling, **kwargs): - req_placement = RequirementPlacement(tiling) - for cell in tiling.point_cells: - if not tiling.only_cell_in_row_and_col(): - isolated_tiling = req_placement.place_point_in_cell(cell, DIR_WEST) - yield EquivalenceRule("Isolate point at cell {}.".format(cell), - isolated_tiling) diff --git a/tilescopethree/strategies/equivalence_strategies/partial_point_placements.py b/tilescopethree/strategies/equivalence_strategies/partial_point_placements.py deleted file mode 100644 index 57839f3db..000000000 --- a/tilescopethree/strategies/equivalence_strategies/partial_point_placements.py +++ /dev/null @@ -1,28 +0,0 @@ -from tilings.algorithms import RequirementPlacement - - -def partial_requirement_placement(tiling, **kwargs): - """ - Strategy that places a single forced point of a requirement onto it own row - or onto its own column. - - The partial_requirement_placement strategy considers every requirement list - of length exactly 1. For each of these requirements, it considers all the - points of the requirement. The strategy then returns all tilings where the - point has been partially placed with a force. - """ - req_placements = (RequirementPlacement(tiling, own_row=False), - RequirementPlacement(tiling, own_col=False)) - for req_placement in req_placements: - yield from req_placement.all_requirement_placement_rules() - - -def partial_point_placement(tiling, **kwargs): - """ - Strategy that place a single forced point of a point requirement. - - The point placement strategy considers all point requirements in their own - requirement lists. For each of them, it returns a new tiling where the - point has been placed with a force. - """ - yield from partial_requirement_placement(tiling, point_only=True) diff --git a/tilescopethree/strategies/equivalence_strategies/point_placements.py b/tilescopethree/strategies/equivalence_strategies/point_placements.py deleted file mode 100644 index 361f74aeb..000000000 --- a/tilescopethree/strategies/equivalence_strategies/point_placements.py +++ /dev/null @@ -1,35 +0,0 @@ -from tilings.algorithms import RequirementPlacement - - -def requirement_placement(tiling, **kwargs): - """ - Strategy that places a single forced point of a requirement. - - The requirement_placement strategy considers every requirement list of - length exactly 1. For each of these requirements, it considers all the - points of the requirement. The strategy then returns all tilings where the - point has been placed with a force. - """ - yield from RequirementPlacement(tiling).all_requirement_placement_rules() - - -def point_placement(tiling, **kwargs): - """ - Strategy that place a single forced point of a point requirement. - - The point placement strategy considers all point requirements in their own - requirement lists. For each of them, it returns a new tiling where the - point has been placed with a force. - """ - yield from RequirementPlacement(tiling).all_point_placement_rules() - - -def all_placements(tiling, **kwargs): - req_placements = (RequirementPlacement(tiling), - RequirementPlacement(tiling, own_row=False), - RequirementPlacement(tiling, own_col=False)) - for req_placement in req_placements: - yield from req_placement.all_point_placement_rules() - yield from req_placement.all_requirement_placement_rules() - yield from req_placement.all_col_placement_rules() - yield from req_placement.all_row_placement_rules() diff --git a/tilescopethree/strategy_packs_v2.py b/tilescopethree/strategy_packs_v2.py index 9c74b3791..94a70d058 100644 --- a/tilescopethree/strategy_packs_v2.py +++ b/tilescopethree/strategy_packs_v2.py @@ -8,8 +8,7 @@ all_requirement_insertions, all_row_insertions) from tilescopethree.strategies import col_placements as col_placements_strat -from tilescopethree.strategies import (factor, fusion, - fusion_with_interleaving, +from tilescopethree.strategies import (component_fusion, factor, fusion, obstruction_transitivity, partial_requirement_placement, requirement_corroboration, @@ -104,7 +103,7 @@ def make_elementary(self): def make_fusion(self, interleaving=False): try: if interleaving: - with_fuse = self.add_initial(fusion_with_interleaving) + with_fuse = self.add_initial(component_fusion) else: with_fuse = self.add_initial(fusion) except ValueError as e: From f9b6df333ef0ccbdabfb8c8c97e739f0bf617817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20Nadeau?= Date: Wed, 5 Feb 2020 21:14:44 +0000 Subject: [PATCH 05/12] refactor cell_insertion --- .../batch_strategies/test_cell_insertion.py | 103 ++++++- .../batch_strategies/cell_insertion.py | 272 +++--------------- 2 files changed, 145 insertions(+), 230 deletions(-) diff --git a/tests/strategies/batch_strategies/test_cell_insertion.py b/tests/strategies/batch_strategies/test_cell_insertion.py index b4900fca9..8bb15ba48 100644 --- a/tests/strategies/batch_strategies/test_cell_insertion.py +++ b/tests/strategies/batch_strategies/test_cell_insertion.py @@ -1,5 +1,9 @@ from permuta import Perm -from tilescopethree.strategies import all_cell_insertions +from tilescopethree.strategies import (all_cell_insertions, all_col_insertions, + all_factor_insertions, + all_requirement_extensions, + all_requirement_insertions, + all_row_insertions) from tilings import Obstruction, Requirement, Tiling pytest_plugins = [ @@ -26,7 +30,7 @@ def test_all_cell_insertions_points(simple_tiling): obstructions=[Obstruction(Perm((0,)), ((0, 1),)), Obstruction(Perm((0,)), ((1, 0),))], requirements=[[Requirement(Perm((0, 1)), ((0, 0), (1, 1)))]]), - Tiling( + Tiling( obstructions=[Obstruction(Perm((0,)), ((0, 1),))], requirements=[[Requirement(Perm((0,)), ((1, 0),))], [Requirement(Perm((0, 1)), ((0, 0), (1, 0))), @@ -41,11 +45,12 @@ def test_all_cell_insertions_points(simple_tiling): actual.add((Tiling( requirements=[[Requirement(Perm((0, 1)), ((0, 0), (1, 0)))]]), - Tiling( + Tiling( obstructions=[Obstruction(Perm((1, 0)), ((0, 1), (1, 0)))], requirements=[[Requirement(Perm((0,)), ((1, 1),))], [Requirement(Perm((0, 1)), ((0, 0), (1, 0))), Requirement(Perm((0, 1)), ((0, 0), (1, 1)))]]))) + print(simple_tiling) assert strats == actual @@ -60,8 +65,96 @@ def test_all_cell_insertions(typical_redundant_requirements, obstructions=typical_redundant_obstructions + [ Obstruction(Perm((0, 1, 2)), [(0, 1), (0, 1), (0, 1)])], requirements=typical_redundant_requirements), - Tiling( + Tiling( obstructions=typical_redundant_obstructions, requirements=typical_redundant_requirements + [ [Requirement(Perm((0, 1, 2)), [(0, 1), (0, 1), (0, 1)])]]) - ) in strats) + ) in strats) + + +def test_all_requirement_extension(): + t = Tiling.from_string('123_132').add_single_cell_requirement( + Perm((0, 1)), (0, 0)) + strats = set([tuple(s.comb_classes) + for s in all_requirement_extensions(t, maxreqlen=3)]) + actual = set([ + (t.add_single_cell_obstruction(Perm((2, 0, 1)), (0, 0)), + t.add_single_cell_requirement(Perm((2, 0, 1)), (0, 0))), + (t.add_single_cell_obstruction(Perm((1, 0, 2)), (0, 0)), + t.add_single_cell_requirement(Perm((1, 0, 2)), (0, 0))), + (t.add_single_cell_obstruction(Perm((1, 2, 0)), (0, 0)), + t.add_single_cell_requirement(Perm((1, 2, 0)), (0, 0))), + ]) + assert actual == strats + + +def test_all_row_insertion(): + t = Tiling(obstructions=[ + Obstruction(Perm((0, 1)), ((0, 0),)*2), + Obstruction(Perm((0, 1)), ((1, 0),)*2), + Obstruction(Perm((0, 1, 2)), ((0, 1),)*3), + ], requirements=[ + [Requirement(Perm((0, 1)), ((0, 1),)*2)] + ]) + strats = set([tuple(s.comb_classes) + for s in all_row_insertions(t)]) + actual = set([ + (Tiling(obstructions=[Obstruction(Perm((0, 1, 2)), ((0, 0),)*3)], + requirements=[[Requirement(Perm((0, 1)), ((0, 0),)*2)]]), + t.add_list_requirement([Requirement(Perm((0,)), ((0, 0),)), + Requirement(Perm((0,)), ((1, 0),)), ])), ]) + assert actual == strats + assert (next(all_row_insertions(t)).formal_step == + 'Either row 0 is empty or not.') + + +def test_all_col_insertion(): + t = Tiling(obstructions=[ + Obstruction(Perm((0, 1)), ((0, 0),)*2), + Obstruction(Perm((0, 1)), ((1, 0),)*2), + Obstruction(Perm((0, 1, 2)), ((0, 1),)*3), + ], requirements=[ + [Requirement(Perm((0, 1)), ((0, 1),)*2)] + ]) + strats = set([tuple(s.comb_classes) + for s in all_col_insertions(t)]) + actual = set([ + (t.add_single_cell_obstruction(Perm((0,)), (1, 0)), + t.add_single_cell_requirement(Perm((0,)), (1, 0)),) + ]) + assert actual == strats + assert (next(all_col_insertions(t)).formal_step == + 'Either column 1 is empty or not.') + + +def test_all_requirement_insertion(): + t = Tiling(obstructions=[ + Obstruction(Perm((0, 1)), ((0, 0), (0, 0))), + Obstruction(Perm((0, 1)), ((1, 0), (1, 0))), + Obstruction(Perm((0, 1)), ((0, 0), (1, 0))), + ]) + strats = set(tuple(s.comb_classes) + for s in all_requirement_insertions(t, 2)) + assert len(strats) == 5 + strat_formal_steps = ( + set(s.formal_step for s in all_requirement_insertions(t, 2))) + assert 'Insert 0 in cell (1, 0).' in strat_formal_steps + assert 'Insert 10: (0, 0), (1, 0).' in strat_formal_steps + + +def test_all_factor_insertions(): + t = Tiling(obstructions=[ + Obstruction(Perm((0, 1)), ((0, 0), (0, 0))), + Obstruction(Perm((0, 1)), ((1, 0), (1, 0))), + Obstruction(Perm((1, 0)), ((1, 1), (1, 1))), + Obstruction(Perm((1, 0)), ((1, 2), (1, 2))), + Obstruction(Perm((0, 1, 2)), ((0, 0), (1, 1), (1, 2))), + Obstruction(Perm((0, 1)), ((0, 0), (1, 0))), + ]) + strats = set(tuple(s.comb_classes) + for s in all_factor_insertions(t)) + assert len(strats) == 2 + strat_formal_steps = ( + set(s.formal_step for s in all_factor_insertions(t))) + assert 'Insert 0 in cell (0, 0).' in strat_formal_steps + assert 'Insert 01: (1, 1), (1, 2).' in strat_formal_steps diff --git a/tilescopethree/strategies/batch_strategies/cell_insertion.py b/tilescopethree/strategies/batch_strategies/cell_insertion.py index a76e21ccc..124d89d9b 100644 --- a/tilescopethree/strategies/batch_strategies/cell_insertion.py +++ b/tilescopethree/strategies/batch_strategies/cell_insertion.py @@ -1,14 +1,17 @@ -"""The cell insertion strategy checks whether a cell is empty or contains a -point""" - from itertools import chain +from typing import List, Optional -from comb_spec_searcher import Rule -from permuta import Av, Perm -from tilings import Obstruction, Requirement, Tiling +from permuta import Perm +from tilings import Tiling +from tilings.algorithms import (CellInsertion, ColInsertion, CrossingInsertion, + FactorInsertion, RequirementExtension, + RowInsertion) -def all_cell_insertions(tiling, **kwargs): +def all_cell_insertions(tiling: Tiling, maxreqlen: int = 1, extra_basis: + Optional[List[Perm]] = None, + ignore_parent: bool = False, + **kwargs): """ The cell insertion strategy. @@ -17,245 +20,64 @@ def all_cell_insertions(tiling, **kwargs): considers all patterns (up to some maximum length given by maxreqlen, and some maximum number given by maxreqnum) and returns two tilings; one which requires the pattern in the cell and one where the pattern is obstructed. - - TODO: - - Have a flag to insert into positive cells that contain the maximal - intersections """ - maxreqlen = kwargs.get('maxreqlen') - if not maxreqlen: - maxreqlen = 1 - ignore_parent = kwargs.get('ignore_parent', False) - extra_basis = kwargs.get('extra_basis') - if extra_basis is None: - extra_basis = [] - if (not isinstance(extra_basis, list) or - not all(isinstance(p, Perm) for p in extra_basis)): - raise TypeError("'extra_basis' flag should be a list of Perm to avoid") - maxreqnum = kwargs.get('maxreqnum') - if not maxreqnum: - maxreqnum = 1 - - active = tiling.active_cells - bdict = tiling.cell_basis() - for cell in active: - if len(bdict[cell][1]) >= maxreqnum: - continue - for length in range(1, maxreqlen + 1): - for patt in Av(bdict[cell][0] + extra_basis).of_length(length): - if not any(patt in perm for perm in bdict[cell][1]): - if (tiling.dimensions != (1, 1) or - all(patt > perm for perm in bdict[cell][1])): - yield Rule( - formal_step=("Insert {} into cell {}.|{}|{}|{}|" - "".format(patt, cell, cell[0], - cell[1], - "".join(str(i) - for i in patt))), - comb_classes=cell_insertion(tiling, patt, cell), - ignore_parent=ignore_parent, - inferable=[True for _ in range(2)], - possibly_empty=[True for _ in range(2)], - workable=[True for _ in range(2)], - constructor='disjoint') - - -def cell_insertion(tiling, patt, cell, regions=False): - """Return a tuple, the first avoids pattern in the cell, and the second - contains it.""" - if regions: - return ([tiling.add_single_cell_obstruction(patt, cell), - tiling.add_single_cell_requirement(patt, cell)], - [{c: frozenset([c]) for c in tiling.active_cells}, - {c: frozenset([c]) for c in tiling.active_cells}]) - else: - return [tiling.add_single_cell_obstruction(patt, cell), - tiling.add_single_cell_requirement(patt, cell)] - - -def cell_insertion(tiling, patt, cell, regions=False): - """Return a tuple, the first avoids pattern in the cell, and the second - contains it.""" - if regions: - return ([tiling.add_single_cell_obstruction(patt, cell), - tiling.add_single_cell_requirement(patt, cell)], - [{c: frozenset([c]) for c in tiling.active_cells}, - {c: frozenset([c]) for c in tiling.active_cells}]) - else: - return [tiling.add_single_cell_obstruction(patt, cell), - tiling.add_single_cell_requirement(patt, cell)] + yield from CellInsertion(tiling, maxreqlen, + extra_basis).rules(ignore_parent) def root_requirement_insertion(tiling, **kwargs): - """The cell insertion strategy performed only on 1 by 1 tilings.""" + """ + The cell insertion strategy performed only on 1 by 1 tilings. + """ if tiling.dimensions != (1, 1) or tiling.requirements: return yield from all_cell_insertions(tiling, **kwargs) def all_point_insertions(tiling, **kwargs): - """The cell insertion strategy using only points.""" + """ + The cell insertion strategy using only points. + """ yield from all_cell_insertions(tiling, maxreqlen=1, **kwargs) -def all_requirement_extensions(tiling, **kwargs): - """Insert longer requirements in to cells which contain a requirement""" - maxreqlen = kwargs.get('maxreqlen') - if not maxreqlen: - maxreqlen = 2 - extra_basis = kwargs.get('extra_basis') - if extra_basis is None: - extra_basis = [] - if (not isinstance(extra_basis, list) or - not all(isinstance(p, Perm) for p in extra_basis)): - raise TypeError("'extra_basis' flag should be a list of Perm to avoid") - - active = tiling.active_cells - bdict = tiling.cell_basis() - for cell in active: - basis = bdict[cell][0] - reqs = bdict[cell][1] - if len(reqs) != 1: - continue - curr_req = reqs[0] - for length in range(len(curr_req) + 1, maxreqlen + 1): - for patt in Av(bdict[cell][0] + extra_basis).of_length(length): - if curr_req in patt: - yield Rule( - formal_step=("Insert {} into cell {}." - "".format(patt, cell)), - comb_classes=[ - tiling.add_single_cell_obstruction(patt, cell), - tiling.add_single_cell_requirement(patt, cell)], - ignore_parent=False, - possibly_empty=[any(len(r) > 1 - for r in tiling.requirements), - True], - inferable=[True for _ in range(2)], - workable=[True for _ in range(2)], - constructor='disjoint') +def all_requirement_extensions(tiling: Tiling, maxreqlen: int = 2, + extra_basis: Optional[List[Perm]] = None, + ignore_parent: bool = False, **kwargs): + """ + Insert longer requirements in to cells which contain a requirement + """ + yield from RequirementExtension(tiling, maxreqlen, + extra_basis).rules(ignore_parent) -def all_row_insertions(tiling, **kwargs): +def all_row_insertions(tiling: Tiling, ignore_parent: bool = False, **kwargs): """Insert a list requirement into every possibly empty row.""" - positive_cells = tiling.positive_cells - for row in range(tiling.dimensions[1]): - row_cells = tiling.cells_in_row(row) - if any(c in positive_cells for c in row_cells): - continue - yield Rule( - formal_step="Either row {} is empty or not.".format(row), - comb_classes=row_insertion_helper(tiling, row, row_cells), - ignore_parent=False, - inferable=[True for _ in range(2)], - possibly_empty=[True, - True], - workable=[True for _ in range(2)], - constructor='disjoint') + yield from RowInsertion(tiling).rules(ignore_parent) -def row_insertion_helper(tiling, row, row_cells, regions=False): - if row_cells is None: - row_cells = tiling.cells_in_row(row) - row_req = tuple(Requirement.single_cell(Perm((0, )), c) - for c in row_cells) - row_obs = tuple(Obstruction.single_cell(Perm((0, )), c) - for c in row_cells) - if regions: - return ([ - Tiling(tiling.obstructions + row_obs, tiling.requirements), - Tiling(tiling.obstructions, tiling.requirements + (row_req,)) - ], [ - {c: frozenset([c]) for c in tiling.active_cells}, - {c: frozenset([c]) for c in tiling.active_cells} - ]) - else: - return [Tiling(tiling.obstructions + row_obs, tiling.requirements), - Tiling(tiling.obstructions, tiling.requirements + (row_req,))] - - -def all_col_insertions(tiling, **kwargs): +def all_col_insertions(tiling, ignore_parent: bool = False, **kwargs): """Insert a list requirement into every possibly empty column.""" - positive_cells = tiling.positive_cells - for col in range(tiling.dimensions[0]): - col_cells = tiling.cells_in_col(col) - if any(c in positive_cells for c in col_cells): - continue - yield Rule( - formal_step="Either col {} is empty or not.".format(col), - comb_classes=col_insertion_helper(tiling, col, col_cells), - ignore_parent=False, - inferable=[True for _ in range(2)], - possibly_empty=[True, - True], - workable=[True for _ in range(2)], - constructor='disjoint') - + yield from ColInsertion(tiling).rules(ignore_parent) -def col_insertion_helper(tiling, col, col_cells, regions=False): - if col_cells is None: - col_cells = tiling.cells_in_col(col) - col_req = tuple(Requirement.single_cell(Perm((0, )), c) - for c in col_cells) - col_obs = tuple(Obstruction.single_cell(Perm((0, )), c) - for c in col_cells) - if regions: - return ([Tiling(tiling.obstructions + col_obs, - tiling.requirements), - Tiling(tiling.obstructions, - tiling.requirements + (col_req,))], - [{c: frozenset([c]) for c in tiling.active_cells}, - {c: frozenset([c]) for c in tiling.active_cells}]) - else: - return [Tiling(tiling.obstructions + col_obs, - tiling.requirements), - Tiling(tiling.obstructions, - tiling.requirements + (col_req,))] - -def all_requirement_insertions(tiling, **kwargs): - """Insert all possible requirements the obstruction allow.""" - if kwargs.get("no_reqs", True) and tiling.requirements: +def all_requirement_insertions(tiling: Tiling, maxreqlen: int = 1, + extra_basis: Optional[List[Perm]] = None, + ignore_parent: bool = False, + **kwargs): + """ + Insert all possible requirements the obstruction allows if the tiling does + not have requirements. + """ + if tiling.requirements: return - maxlen = kwargs.get("maxlen", 2) - ignore_parent = kwargs.get("ignore_parent", False) - obs_tiling = Tiling(tiling.obstructions, - remove_empty=False, derive_empty=False, - minimize=False, sorted_input=True) - for length in range(1, maxlen + 1): - for gp in obs_tiling.gridded_perms_of_length(length): - if len(gp.factors()) == 1: - av = Tiling((tiling.obstructions + - (Obstruction(gp.patt, gp.pos),)), - tiling.requirements) - co = Tiling(tiling.obstructions, - (tiling.requirements) + - ((Requirement(gp.patt, gp.pos),),)) - yield Rule(formal_step="Insert {}.".format(str(gp)), - comb_classes=[av, co], - ignore_parent=ignore_parent, - inferable=[True for _ in range(2)], - possibly_empty=[True for _ in range(2)], - workable=[True for _ in range(2)], - constructor='disjoint') + yield from CrossingInsertion(tiling, maxreqlen, + extra_basis).rules(ignore_parent) -def all_factor_insertions(tiling, **kwargs): - ignore_parent = kwargs.get("ignore_parent", False) - for gp in sorted(set(chain(tiling.obstructions, *tiling.requirements))): - factors = gp.factors() - if len(factors) != 1: - for gp in factors: - av = Tiling((tiling.obstructions + - (Obstruction(gp.patt, gp.pos),)), - tiling.requirements) - co = Tiling(tiling.obstructions, - (tiling.requirements) + - ((Requirement(gp.patt, gp.pos),),)) - yield Rule(formal_step="Insert {}.".format(str(gp)), - comb_classes=[av, co], - ignore_parent=ignore_parent, - inferable=[True for _ in range(2)], - possibly_empty=[True for _ in range(2)], - workable=[True for _ in range(2)], - constructor='disjoint') +def all_factor_insertions(tiling: Tiling, ignore_parent: bool = False, + **kwargs): + """ + Insert all proper factor of the requirement or obstructions on the tiling. + """ + yield from FactorInsertion(tiling).rules(ignore_parent) From 973cadefefe39e3d897ea7137947466f06e4e986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20Nadeau?= Date: Wed, 5 Feb 2020 22:31:36 +0000 Subject: [PATCH 06/12] Migrate requirement corroboration --- .../batch_strategies/cell_insertion.py | 23 ++++++----- .../requirement_corroboration.py | 41 ++++--------------- 2 files changed, 21 insertions(+), 43 deletions(-) diff --git a/tilescopethree/strategies/batch_strategies/cell_insertion.py b/tilescopethree/strategies/batch_strategies/cell_insertion.py index 124d89d9b..2dd026bb5 100644 --- a/tilescopethree/strategies/batch_strategies/cell_insertion.py +++ b/tilescopethree/strategies/batch_strategies/cell_insertion.py @@ -1,6 +1,6 @@ -from itertools import chain -from typing import List, Optional +from typing import Iterable, List, Optional +from comb_spec_searcher import Rule from permuta import Perm from tilings import Tiling from tilings.algorithms import (CellInsertion, ColInsertion, CrossingInsertion, @@ -11,7 +11,7 @@ def all_cell_insertions(tiling: Tiling, maxreqlen: int = 1, extra_basis: Optional[List[Perm]] = None, ignore_parent: bool = False, - **kwargs): + **kwargs) -> Iterable[Rule]: """ The cell insertion strategy. @@ -25,7 +25,7 @@ def all_cell_insertions(tiling: Tiling, maxreqlen: int = 1, extra_basis: extra_basis).rules(ignore_parent) -def root_requirement_insertion(tiling, **kwargs): +def root_requirement_insertion(tiling, **kwargs) -> Iterable[Rule]: """ The cell insertion strategy performed only on 1 by 1 tilings. """ @@ -34,7 +34,7 @@ def root_requirement_insertion(tiling, **kwargs): yield from all_cell_insertions(tiling, **kwargs) -def all_point_insertions(tiling, **kwargs): +def all_point_insertions(tiling, **kwargs) -> Iterable[Rule]: """ The cell insertion strategy using only points. """ @@ -43,7 +43,8 @@ def all_point_insertions(tiling, **kwargs): def all_requirement_extensions(tiling: Tiling, maxreqlen: int = 2, extra_basis: Optional[List[Perm]] = None, - ignore_parent: bool = False, **kwargs): + ignore_parent: bool = False, + **kwargs) -> Iterable[Rule]: """ Insert longer requirements in to cells which contain a requirement """ @@ -51,12 +52,14 @@ def all_requirement_extensions(tiling: Tiling, maxreqlen: int = 2, extra_basis).rules(ignore_parent) -def all_row_insertions(tiling: Tiling, ignore_parent: bool = False, **kwargs): +def all_row_insertions(tiling: Tiling, ignore_parent: bool = False, + **kwargs) -> Iterable[Rule]: """Insert a list requirement into every possibly empty row.""" yield from RowInsertion(tiling).rules(ignore_parent) -def all_col_insertions(tiling, ignore_parent: bool = False, **kwargs): +def all_col_insertions(tiling, ignore_parent: bool = False, + **kwargs) -> Iterable[Rule]: """Insert a list requirement into every possibly empty column.""" yield from ColInsertion(tiling).rules(ignore_parent) @@ -64,7 +67,7 @@ def all_col_insertions(tiling, ignore_parent: bool = False, **kwargs): def all_requirement_insertions(tiling: Tiling, maxreqlen: int = 1, extra_basis: Optional[List[Perm]] = None, ignore_parent: bool = False, - **kwargs): + **kwargs) -> Iterable[Rule]: """ Insert all possible requirements the obstruction allows if the tiling does not have requirements. @@ -76,7 +79,7 @@ def all_requirement_insertions(tiling: Tiling, maxreqlen: int = 1, def all_factor_insertions(tiling: Tiling, ignore_parent: bool = False, - **kwargs): + **kwargs) -> Iterable[Rule]: """ Insert all proper factor of the requirement or obstructions on the tiling. """ diff --git a/tilescopethree/strategies/batch_strategies/requirement_corroboration.py b/tilescopethree/strategies/batch_strategies/requirement_corroboration.py index ccfa20908..e46b48f46 100644 --- a/tilescopethree/strategies/batch_strategies/requirement_corroboration.py +++ b/tilescopethree/strategies/batch_strategies/requirement_corroboration.py @@ -1,15 +1,19 @@ """ Module containing the requirement corroboration strategy. """ +from typing import Iterable + from comb_spec_searcher import Rule -from tilings import Obstruction, Requirement, Tiling +from tilings import Tiling +from tilings.algorithms import RequirementCorroboration -def requirement_corroboration(tiling, basis, **kwargs): +def requirement_corroboration(tiling: Tiling, ignore_parent: bool = True, + **kwargs) -> Iterable[Rule]: """ The requirement corroboration strategy. - The requirement corrobation strategy is a batch strategy that considers + The requirement corroboration strategy is a batch strategy that considers each requirement of each requirement list. For each of these requirements, the strategy returns two tilings; one where the requirement has been turned into an obstruction and another where the requirement has been singled out @@ -21,33 +25,4 @@ def requirement_corroboration(tiling, basis, **kwargs): that avoid the requirement, must therefore satisfy another requirement from the same list and hence the requirement list must be of length at least 2. """ - for reqs in tiling.requirements: - if len(reqs) == 1: - continue - for req in reqs: - yield Rule( - formal_step="Inserting requirement {}.".format(str(req)), - comb_classes=gp_insertion(tiling, req), - ignore_parent=True, - possibly_empty=[True, True], - workable=[True for _ in range(2)], - inferable=[True for _ in range(2)], - constructor='disjoint') - - -def pos_str(pos): - return "/".join("{},{}".format(c[0], c[1]) for c in pos) - - -def gp_insertion(tiling, gp, regions=False): - """Return a list of size 2, where the first tiling avoids the gridded perm - gp and the second contains gp.""" - tilings = [tiling.add_obstruction(gp.patt, gp.pos), - tiling.add_requirement(gp.patt, gp.pos)] - - if regions: - forward_maps = [{c: frozenset([c]) for c in tiling.active_cells}, - {c: frozenset([c]) for c in tiling.active_cells}] - return tilings, forward_maps - else: - return tilings + yield from RequirementCorroboration(tiling).rules(ignore_parent) From 5f81a14579bd5ec9c8311655c6af07112250ab50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20Nadeau?= Date: Wed, 5 Feb 2020 22:38:36 +0000 Subject: [PATCH 07/12] remove targeted cell insertion --- .../strategies/batch_strategies/__init__.py | 1 - .../targeted_cell_insertion.py | 63 ------------------- 2 files changed, 64 deletions(-) delete mode 100644 tilescopethree/strategies/batch_strategies/targeted_cell_insertion.py diff --git a/tilescopethree/strategies/batch_strategies/__init__.py b/tilescopethree/strategies/batch_strategies/__init__.py index b0baf226f..c74256718 100644 --- a/tilescopethree/strategies/batch_strategies/__init__.py +++ b/tilescopethree/strategies/batch_strategies/__init__.py @@ -11,4 +11,3 @@ row_and_col_placements, row_placements) from .requirement_corroboration import requirement_corroboration -from .targeted_cell_insertion import targeted_cell_insertion diff --git a/tilescopethree/strategies/batch_strategies/targeted_cell_insertion.py b/tilescopethree/strategies/batch_strategies/targeted_cell_insertion.py deleted file mode 100644 index 578e0d2e6..000000000 --- a/tilescopethree/strategies/batch_strategies/targeted_cell_insertion.py +++ /dev/null @@ -1,63 +0,0 @@ -from comb_spec_searcher import Rule -from permuta.misc import UnionFind - - -def targeted_cell_insertion(tiling, **kwargs): - """Return combintorial rules formed by inserting """ - factors = factors_of_gridded_perm(tiling) - if not factors: - return - for f in factors: - yield Rule("Insert {}.".format(repr(f)), - [tiling.add_obstruction(f.patt, f.pos), - tiling.add_requirement(f.patt, f.pos)], - inferable=[True, True], - workable=[True, True], - ignore_parent=True, - constructor='disjoint') - - -def components(tiling): - """Return the component of a tiling. Two cells are in the same component if - they are in the same row or column.""" - n, m = tiling.dimensions - - def cell_to_int(cell): - return cell[0] * m + cell[1] - - def int_to_cell(i): - return (i // m, i % m) - - cells = list(tiling.active_cells) - uf = UnionFind(n * m) - for i in range(len(cells)): - for j in range(i + 1, len(cells)): - c1, c2 = cells[i], cells[j] - if c1[0] == c2[0] or c1[1] == c2[1]: - uf.unite(cell_to_int(c1), cell_to_int(c2)) - - # Collect the connected components of the cells - all_components = {} - for cell in cells: - i = uf.find(cell_to_int(cell)) - if i in all_components: - all_components[i].append(cell) - else: - all_components[i] = [cell] - component_cells = list(set(cells) for cells in all_components.values()) - return component_cells - - -def factors_of_gridded_perm(tiling): - """Return factor of gridded permutation if separated from rest of gridded - permutation, if cells are not on the same row or column.""" - comps = components(tiling) - if len(comps) <= 1: - return - factors = set() - for ob in tiling.obstructions: - subperms = [ob.get_gridded_perm_in_cells(c) for c in comps] - subperms = [p for p in subperms if p] - if len(subperms) > 1: - factors.update(subperms) - return factors From 831c4586ccc767fca678e17d4acc0ad08b968c57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20Nadeau?= Date: Thu, 6 Feb 2020 09:52:55 +0000 Subject: [PATCH 08/12] migrate batch strategies --- tilescopethree/strategies/batch_strategies.py | 13 +++ .../strategies/batch_strategies/__init__.py | 13 --- .../batch_strategies/cell_insertion.py | 86 ------------------- .../list_requirement_placements.py | 52 ----------- .../requirement_corroboration.py | 28 ------ 5 files changed, 13 insertions(+), 179 deletions(-) create mode 100644 tilescopethree/strategies/batch_strategies.py delete mode 100644 tilescopethree/strategies/batch_strategies/__init__.py delete mode 100644 tilescopethree/strategies/batch_strategies/cell_insertion.py delete mode 100644 tilescopethree/strategies/batch_strategies/list_requirement_placements.py delete mode 100644 tilescopethree/strategies/batch_strategies/requirement_corroboration.py diff --git a/tilescopethree/strategies/batch_strategies.py b/tilescopethree/strategies/batch_strategies.py new file mode 100644 index 000000000..e567a7d37 --- /dev/null +++ b/tilescopethree/strategies/batch_strategies.py @@ -0,0 +1,13 @@ +from tilings.strategies.batch import (all_cell_insertions, all_col_insertions, + all_factor_insertions, + all_point_insertions, + all_requirement_extensions, + all_requirement_insertions, + all_row_insertions, col_placements, + partial_col_placements, + partial_row_and_col_placements, + partial_row_placements, + requirement_corroboration, + requirement_list_placement, + root_requirement_insertion, + row_and_col_placements, row_placements) diff --git a/tilescopethree/strategies/batch_strategies/__init__.py b/tilescopethree/strategies/batch_strategies/__init__.py deleted file mode 100644 index c74256718..000000000 --- a/tilescopethree/strategies/batch_strategies/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -from .cell_insertion import (all_cell_insertions, all_col_insertions, - all_factor_insertions, all_point_insertions, - all_requirement_extensions, - all_requirement_insertions, all_row_insertions, - root_requirement_insertion) -from .list_requirement_placements import (col_placements, - partial_col_placements, - partial_row_and_col_placements, - partial_row_placements, - requirement_list_placement, - row_and_col_placements, - row_placements) -from .requirement_corroboration import requirement_corroboration diff --git a/tilescopethree/strategies/batch_strategies/cell_insertion.py b/tilescopethree/strategies/batch_strategies/cell_insertion.py deleted file mode 100644 index 2dd026bb5..000000000 --- a/tilescopethree/strategies/batch_strategies/cell_insertion.py +++ /dev/null @@ -1,86 +0,0 @@ -from typing import Iterable, List, Optional - -from comb_spec_searcher import Rule -from permuta import Perm -from tilings import Tiling -from tilings.algorithms import (CellInsertion, ColInsertion, CrossingInsertion, - FactorInsertion, RequirementExtension, - RowInsertion) - - -def all_cell_insertions(tiling: Tiling, maxreqlen: int = 1, extra_basis: - Optional[List[Perm]] = None, - ignore_parent: bool = False, - **kwargs) -> Iterable[Rule]: - """ - The cell insertion strategy. - - The cell insertion strategy is a batch strategy that considers each active - cells, excluding positive cells. For each of these cells, the strategy - considers all patterns (up to some maximum length given by maxreqlen, and - some maximum number given by maxreqnum) and returns two tilings; one which - requires the pattern in the cell and one where the pattern is obstructed. - """ - yield from CellInsertion(tiling, maxreqlen, - extra_basis).rules(ignore_parent) - - -def root_requirement_insertion(tiling, **kwargs) -> Iterable[Rule]: - """ - The cell insertion strategy performed only on 1 by 1 tilings. - """ - if tiling.dimensions != (1, 1) or tiling.requirements: - return - yield from all_cell_insertions(tiling, **kwargs) - - -def all_point_insertions(tiling, **kwargs) -> Iterable[Rule]: - """ - The cell insertion strategy using only points. - """ - yield from all_cell_insertions(tiling, maxreqlen=1, **kwargs) - - -def all_requirement_extensions(tiling: Tiling, maxreqlen: int = 2, - extra_basis: Optional[List[Perm]] = None, - ignore_parent: bool = False, - **kwargs) -> Iterable[Rule]: - """ - Insert longer requirements in to cells which contain a requirement - """ - yield from RequirementExtension(tiling, maxreqlen, - extra_basis).rules(ignore_parent) - - -def all_row_insertions(tiling: Tiling, ignore_parent: bool = False, - **kwargs) -> Iterable[Rule]: - """Insert a list requirement into every possibly empty row.""" - yield from RowInsertion(tiling).rules(ignore_parent) - - -def all_col_insertions(tiling, ignore_parent: bool = False, - **kwargs) -> Iterable[Rule]: - """Insert a list requirement into every possibly empty column.""" - yield from ColInsertion(tiling).rules(ignore_parent) - - -def all_requirement_insertions(tiling: Tiling, maxreqlen: int = 1, - extra_basis: Optional[List[Perm]] = None, - ignore_parent: bool = False, - **kwargs) -> Iterable[Rule]: - """ - Insert all possible requirements the obstruction allows if the tiling does - not have requirements. - """ - if tiling.requirements: - return - yield from CrossingInsertion(tiling, maxreqlen, - extra_basis).rules(ignore_parent) - - -def all_factor_insertions(tiling: Tiling, ignore_parent: bool = False, - **kwargs) -> Iterable[Rule]: - """ - Insert all proper factor of the requirement or obstructions on the tiling. - """ - yield from FactorInsertion(tiling).rules(ignore_parent) diff --git a/tilescopethree/strategies/batch_strategies/list_requirement_placements.py b/tilescopethree/strategies/batch_strategies/list_requirement_placements.py deleted file mode 100644 index 4a16f7547..000000000 --- a/tilescopethree/strategies/batch_strategies/list_requirement_placements.py +++ /dev/null @@ -1,52 +0,0 @@ -from itertools import product - -from comb_spec_searcher import BatchRule -from permuta.misc import DIR_EAST, DIR_NORTH, DIR_SOUTH, DIR_WEST -from tilings.algorithms import RequirementPlacement - - -def requirement_list_placement(tiling, **kwargs): - """Places all requirements on the tiling in every direction.""" - req_placement = RequirementPlacement(tiling) - directions = (DIR_EAST, DIR_NORTH, DIR_SOUTH, DIR_WEST) - for req, direction in product(tiling.requirements, directions): - yield BatchRule(req_placement.place_point_of_req_list(req, direction), - "Inserting {} point of requirement list ({})".format( - req_placement._direction_string(direction), - ", ".join(str(r) for r in req))) - - -def row_placements(tiling, **kwargs): - yield from RequirementPlacement(tiling).all_row_placement_rules() - - -def col_placements(tiling, **kwargs): - yield from RequirementPlacement(tiling).all_col_placement_rules() - - -def row_and_col_placements(tiling, **kwargs): - req_placements = RequirementPlacement(tiling) - yield from req_placements.all_row_placement_rules() - yield from req_placements.all_col_placement_rules() - - -def partial_row_placements(tiling, **kwargs): - req_placements = (RequirementPlacement(tiling, own_row=False), - RequirementPlacement(tiling, own_col=False)) - for req_placement in req_placements: - yield from req_placement.all_row_placement_rules() - - -def partial_col_placements(tiling, **kwargs): - req_placements = (RequirementPlacement(tiling, own_row=False), - RequirementPlacement(tiling, own_col=False)) - for req_placement in req_placements: - yield from req_placement.all_col_placement_rules() - - -def partial_row_and_col_placements(tiling, **kwargs): - req_placements = (RequirementPlacement(tiling, own_row=False), - RequirementPlacement(tiling, own_col=False)) - for req_placement in req_placements: - yield from req_placement.all_row_placement_rules() - yield from req_placement.all_col_placement_rules() diff --git a/tilescopethree/strategies/batch_strategies/requirement_corroboration.py b/tilescopethree/strategies/batch_strategies/requirement_corroboration.py deleted file mode 100644 index e46b48f46..000000000 --- a/tilescopethree/strategies/batch_strategies/requirement_corroboration.py +++ /dev/null @@ -1,28 +0,0 @@ -""" - Module containing the requirement corroboration strategy. -""" -from typing import Iterable - -from comb_spec_searcher import Rule -from tilings import Tiling -from tilings.algorithms import RequirementCorroboration - - -def requirement_corroboration(tiling: Tiling, ignore_parent: bool = True, - **kwargs) -> Iterable[Rule]: - """ - The requirement corroboration strategy. - - The requirement corroboration strategy is a batch strategy that considers - each requirement of each requirement list. For each of these requirements, - the strategy returns two tilings; one where the requirement has been turned - into an obstruction and another where the requirement has been singled out - and a new requirement list added with only the requirement. This new - requirement list contains only the singled out requirement. - - This implements the notion of partitioning the set of gridded permutations - into those that satisfy this requirement and those that avoid it. Those - that avoid the requirement, must therefore satisfy another requirement from - the same list and hence the requirement list must be of length at least 2. - """ - yield from RequirementCorroboration(tiling).rules(ignore_parent) From 20e49084282f905fb342963fa3c0038dc74a8689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20Nadeau?= Date: Thu, 6 Feb 2020 10:01:24 +0000 Subject: [PATCH 09/12] fusion strategies have moved in tilings --- tilescopethree/strategies/equivalence_strategies.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tilescopethree/strategies/equivalence_strategies.py b/tilescopethree/strategies/equivalence_strategies.py index fff24ec43..111d34b44 100644 --- a/tilescopethree/strategies/equivalence_strategies.py +++ b/tilescopethree/strategies/equivalence_strategies.py @@ -1,5 +1,6 @@ -from tilings.strategies.equivalence import (all_placements, component_fusion, - fusion, partial_point_placement, +from tilings.strategies.equivalence import (all_placements, + partial_point_placement, partial_requirement_placement, point_placement, requirement_placement) +from tilings.strategies.fusion import component_fusion, fusion From db5bb297079286440001fbed8dba81635beb7bfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20Nadeau?= Date: Thu, 6 Feb 2020 10:20:28 +0000 Subject: [PATCH 10/12] remove requirement_list_placement --- tilescopethree/strategies/batch_strategies.py | 1 - tilescopethree/strategy_packs_v2.py | 1 - 2 files changed, 2 deletions(-) diff --git a/tilescopethree/strategies/batch_strategies.py b/tilescopethree/strategies/batch_strategies.py index e567a7d37..5a014171c 100644 --- a/tilescopethree/strategies/batch_strategies.py +++ b/tilescopethree/strategies/batch_strategies.py @@ -8,6 +8,5 @@ partial_row_and_col_placements, partial_row_placements, requirement_corroboration, - requirement_list_placement, root_requirement_insertion, row_and_col_placements, row_placements) diff --git a/tilescopethree/strategy_packs_v2.py b/tilescopethree/strategy_packs_v2.py index 94a70d058..ad5b1ecf9 100644 --- a/tilescopethree/strategy_packs_v2.py +++ b/tilescopethree/strategy_packs_v2.py @@ -12,7 +12,6 @@ obstruction_transitivity, partial_requirement_placement, requirement_corroboration, - requirement_list_placement, requirement_placement, root_requirement_insertion, row_and_column_separation) From b4259574466a67742b14e4b48206171c20103af5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20Nadeau?= Date: Thu, 6 Feb 2020 13:54:19 +0000 Subject: [PATCH 11/12] migrate all the strategy test to tilings --- tests/fixtures/diverse_tiling.py | 24 --- tests/fixtures/no_point_tiling.py | 20 --- tests/fixtures/obstructions_requirements.py | 88 ---------- tests/fixtures/positive_one_by_one.py | 11 -- tests/fixtures/simple_tiling.py | 12 -- tests/fixtures/simple_trans.py | 38 ---- tests/strategies/__init__.py | 0 tests/strategies/batch_strategies/__init__.py | 0 .../batch_strategies/test_cell_insertion.py | 160 ----------------- .../test_requirement_corroboration.py | 58 ------ .../test_requirement_extensions.py | 111 ------------ .../decomposition_strategies/test_factor.py | 86 --------- .../test_component_fusion.py | 41 ----- .../equivalence_strategies/test_fusion.py | 69 -------- .../test_point_placements.py | 164 ----------------- .../test_obstruction_transitivity.py | 53 ------ .../test_row_col_seperation.py | 166 ------------------ 17 files changed, 1101 deletions(-) delete mode 100644 tests/fixtures/diverse_tiling.py delete mode 100644 tests/fixtures/no_point_tiling.py delete mode 100644 tests/fixtures/obstructions_requirements.py delete mode 100644 tests/fixtures/positive_one_by_one.py delete mode 100644 tests/fixtures/simple_tiling.py delete mode 100644 tests/fixtures/simple_trans.py delete mode 100644 tests/strategies/__init__.py delete mode 100644 tests/strategies/batch_strategies/__init__.py delete mode 100644 tests/strategies/batch_strategies/test_cell_insertion.py delete mode 100644 tests/strategies/batch_strategies/test_requirement_corroboration.py delete mode 100644 tests/strategies/batch_strategies/test_requirement_extensions.py delete mode 100644 tests/strategies/decomposition_strategies/test_factor.py delete mode 100644 tests/strategies/equivalence_strategies/test_component_fusion.py delete mode 100644 tests/strategies/equivalence_strategies/test_fusion.py delete mode 100644 tests/strategies/equivalence_strategies/test_point_placements.py delete mode 100644 tests/strategies/inferral_strategies/test_obstruction_transitivity.py delete mode 100644 tests/strategies/inferral_strategies/test_row_col_seperation.py diff --git a/tests/fixtures/diverse_tiling.py b/tests/fixtures/diverse_tiling.py deleted file mode 100644 index d70154755..000000000 --- a/tests/fixtures/diverse_tiling.py +++ /dev/null @@ -1,24 +0,0 @@ -import pytest - -from permuta import Perm -from tilings import Obstruction, Requirement, Tiling - - -@pytest.fixture -def diverse_tiling(): - """Returns a simple, but diverse tiling. - - The tiling has positive, possibly empty and empty cells and also few - requirements and a long obstructions.""" - return Tiling( - obstructions=[Obstruction(Perm((0, 2, 3, 1)), - [(0, 0), (1, 1), (1, 1), (2, 0)]), - Obstruction(Perm((0, 1)), [(1, 0), (1, 0)]), - Obstruction(Perm((1, 0)), [(1, 0), (1, 0)]), - Obstruction(Perm((0, 1)), [(2, 1), (2, 1)]), - Obstruction(Perm((1, 0)), [(2, 1), (2, 1)])], - requirements=[[Requirement(Perm((0, 2, 1)), [(0, 1), (0, 2), (1, 2)]), - Requirement(Perm((1, 0)), [(0, 2), (0, 1)])], - [Requirement(Perm((0,)), [(1, 0)])], - [Requirement(Perm((0,)), [(2, 0)])], - [Requirement(Perm((0,)), [(2, 1)])]]) diff --git a/tests/fixtures/no_point_tiling.py b/tests/fixtures/no_point_tiling.py deleted file mode 100644 index a1802f639..000000000 --- a/tests/fixtures/no_point_tiling.py +++ /dev/null @@ -1,20 +0,0 @@ -import pytest - -from permuta import Perm -from tilings import Obstruction, Requirement, Tiling - - -@pytest.fixture -def no_point_tiling(): - """Returns a simple tiling with length of all obs and reqs at least 2. """ - return Tiling( - obstructions=[Obstruction(Perm((1, 0)), [(0, 1), (0, 1)]), - Obstruction(Perm((0, 1, 2)), [(0, 0), (1, 0), (1, 0)]), - Obstruction(Perm((0, 1, 2)), [(1, 0), (1, 0), (2, 0)]), - Obstruction(Perm((0, 2, 1)), [(0, 2), (0, 2), (1, 2)]), - Obstruction(Perm((0, 2, 1)), [(0, 2), (1, 2), (1, 2)])], - requirements=[[Requirement(Perm((0, 1)), [(0, 0), (0, 0)]), - Requirement(Perm((0, 1)), [(0, 0), (2, 0)])], - [Requirement(Perm((0, 2, 1)), [(0, 1), (1, 1), (1, 1)])], - [Requirement(Perm((0, 1)), [(1, 1), (2, 1)]), - Requirement(Perm((0, 1)), [(1, 1), (2, 2)])]]) diff --git a/tests/fixtures/obstructions_requirements.py b/tests/fixtures/obstructions_requirements.py deleted file mode 100644 index 23a121e45..000000000 --- a/tests/fixtures/obstructions_requirements.py +++ /dev/null @@ -1,88 +0,0 @@ -import pytest - -from permuta import Perm -from tilings import Obstruction, Requirement - - -@pytest.fixture -def typical_redundant_obstructions(): - """Returns a very typical list of obstructions clustered together in a - corner of a tiling. """ - return [ - Obstruction(Perm((0, 1)), ((1, 0), (1, 0))), - Obstruction(Perm((0, 1)), ((1, 0), (2, 0))), - Obstruction(Perm((0, 1)), ((1, 0), (3, 0))), - Obstruction(Perm((0, 1)), ((2, 0), (2, 0))), - Obstruction(Perm((0, 1)), ((2, 0), (3, 0))), - Obstruction(Perm((0, 1)), ((3, 1), (3, 1))), - Obstruction(Perm((1, 0)), ((3, 0), (3, 0))), - Obstruction(Perm((1, 0)), ((3, 1), (3, 0))), - Obstruction(Perm((1, 0)), ((3, 1), (3, 1))), - Obstruction(Perm((0, 1, 2)), ((3, 0), (3, 0), (3, 0))), - Obstruction(Perm((0, 1, 2)), ((3, 0), (3, 0), (3, 1))), - Obstruction(Perm((2, 1, 0)), ((1, 0), (1, 0), (1, 0))), - Obstruction(Perm((2, 1, 0)), ((1, 0), (1, 0), (2, 0))), - Obstruction(Perm((2, 1, 0)), ((1, 0), (1, 0), (3, 0))), - Obstruction(Perm((2, 1, 0)), ((1, 0), (2, 0), (2, 0))), - Obstruction(Perm((2, 1, 0)), ((1, 0), (2, 0), (3, 0))), - Obstruction(Perm((2, 1, 0)), ((2, 0), (2, 0), (2, 0))), - Obstruction(Perm((2, 1, 0)), ((2, 0), (2, 0), (3, 0))), - Obstruction(Perm((3, 2, 1, 0)), ((1, 1), (2, 0), (2, 0), (2, 0))), - Obstruction(Perm((3, 2, 1, 0)), ((2, 1), (2, 1), (3, 0), (3, 0))) - ] - - -@pytest.fixture -def typical_redundant_requirements(): - """Returns a very typical list of requirements of a tiling. """ - return [ - [Requirement(Perm((0, 1, 2)), ((0, 0), (1, 0), (2, 3))), - Requirement(Perm((0, 1, 2)), ((0, 0), (1, 0), (2, 4))), - Requirement(Perm((1, 0, 2)), ((0, 0), (1, 0), (2, 3))), - Requirement(Perm((1, 0, 2)), ((0, 1), (1, 0), (2, 3)))], - [Requirement(Perm((0, 1, 2)), ((2, 3), (2, 3), (2, 3))), - Requirement(Perm((1, 0, 2)), ((0, 0), (0, 0), (0, 0))), - Requirement(Perm((0, 1, 2)), ((1, 0), (1, 0), (1, 0)))], - [Requirement(Perm((0, 1)), ((1, 0), (3, 0))), - Requirement(Perm((0, 1)), ((2, 0), (2, 0))), - Requirement(Perm((0, 1)), ((2, 0), (3, 0))), - Requirement(Perm((0, 1)), ((2, 0), (3, 1)))], - [Requirement(Perm((1, 0)), ((3, 3), (3, 1))), - Requirement(Perm((1, 0)), ((3, 1), (3, 1))), - Requirement(Perm((1, 0)), ((3, 1), (3, 0)))]] - - -@pytest.fixture -def typical_obstructions_with_local(): - return [ - Obstruction(Perm((0, 1)), ((1, 0), (1, 0))), - Obstruction(Perm((0, 1)), ((1, 0), (2, 0))), - Obstruction(Perm((0, 1)), ((1, 0), (3, 0))), - Obstruction(Perm((0, 1)), ((2, 0), (2, 0))), - Obstruction(Perm((0, 1)), ((2, 0), (3, 0))), - Obstruction(Perm((0, 1)), ((3, 1), (3, 1))), - Obstruction(Perm((0, 2, 1)), ((3, 0), (3, 0), (3, 0))), - Obstruction(Perm((0, 1, 2)), ((3, 0), (3, 0), (3, 1))), - Obstruction(Perm((1, 2, 0)), ((1, 0), (1, 0), (1, 0))), - - Obstruction(Perm((3, 2, 1, 0)), ((1, 1), (2, 0), (2, 0), (2, 0))), - Obstruction(Perm((3, 2, 1, 0)), ((2, 1), (2, 1), (3, 0), (3, 0))) - ] - - -@pytest.fixture -def typical_requirements_with_local(): - """Return a very typical list of requirements of a tiling, including some - local length 1 requirements.""" - return [ - [Requirement(Perm((0, 1, 2)), ((0, 0), (1, 0), (2, 3))), - Requirement(Perm((0, 1, 2)), ((0, 0), (1, 0), (2, 4))), - Requirement(Perm((1, 0, 2)), ((0, 0), (1, 0), (2, 3))), - Requirement(Perm((1, 0, 2)), ((0, 1), (1, 0), (2, 3)))], - [Requirement(Perm((0, 1)), ((1, 0), (3, 0))), - Requirement(Perm((0, 1)), ((2, 0), (2, 0))), - Requirement(Perm((0, 1)), ((2, 0), (3, 0))), - Requirement(Perm((0, 1)), ((2, 0), (3, 1)))], - [Requirement(Perm((0, )), ((3, 0),))], - [Requirement(Perm((1, 0)), ((2, 0), (2, 0)))], - [Requirement(Perm((0, 2, 1)), ((0, 0), (2, 3), (2, 3)))]] diff --git a/tests/fixtures/positive_one_by_one.py b/tests/fixtures/positive_one_by_one.py deleted file mode 100644 index 5fcdd1e1b..000000000 --- a/tests/fixtures/positive_one_by_one.py +++ /dev/null @@ -1,11 +0,0 @@ -import pytest - -from permuta import Perm -from tilings import Obstruction, Requirement, Tiling - - -@pytest.fixture -def positive_one_by_one(): - return Tiling( - obstructions=[Obstruction(Perm((0, 2, 1)), [(0, 0), (0, 0), (0, 0)])], - requirements=[[Requirement(Perm((0, )), [(0, 0)])]]) diff --git a/tests/fixtures/simple_tiling.py b/tests/fixtures/simple_tiling.py deleted file mode 100644 index 5df026f45..000000000 --- a/tests/fixtures/simple_tiling.py +++ /dev/null @@ -1,12 +0,0 @@ -import pytest - -from permuta import Perm -from tilings import Obstruction, Requirement, Tiling - - -@pytest.fixture -def simple_tiling(): - return Tiling( - obstructions=[Obstruction(Perm((1, 0)), [(0, 1), (1, 0)])], - requirements=[[Requirement(Perm((0, 1)), [(0, 0), (1, 0)]), - Requirement(Perm((0, 1)), [(0, 0), (1, 1)])]]) diff --git a/tests/fixtures/simple_trans.py b/tests/fixtures/simple_trans.py deleted file mode 100644 index 6f1ebd889..000000000 --- a/tests/fixtures/simple_trans.py +++ /dev/null @@ -1,38 +0,0 @@ -import pytest - -from permuta import Perm -from tilings import Obstruction, Requirement, Tiling - - -@pytest.fixture -def simple_trans_row(): - return Tiling(obstructions=[Obstruction(Perm((0, 1)), [(0, 0), (1, 0)]), - Obstruction(Perm((0, 1)), [(1, 0), (2, 0)])], - requirements=[[Requirement(Perm((0,)), [(1, 0)])]]) - - -@pytest.fixture -def simple_trans_col(): - return Tiling(obstructions=[Obstruction(Perm((0, 1)), [(0, 0), (0, 1)]), - Obstruction(Perm((0, 1)), [(0, 1), (0, 2)])], - requirements=[[Requirement(Perm((0,)), [(0, 1)])]]) - - -@pytest.fixture -def simple_trans_row_len2(): - return Tiling(obstructions=[Obstruction(Perm((0, 1)), [(0, 0), (1, 0)]), - Obstruction(Perm((0, 1)), [(1, 0), (2, 0)]), - Obstruction(Perm((0, 1)), [(2, 0), (3, 0)])], - requirements=[[Requirement(Perm((0,)), [(1, 0)])], - [Requirement(Perm((0,)), [(2, 0)])]]) - - -@pytest.fixture -def simple_trans_row_len3(): - return Tiling(obstructions=[Obstruction(Perm((0, 1)), [(0, 0), (1, 0)]), - Obstruction(Perm((0, 1)), [(1, 0), (2, 0)]), - Obstruction(Perm((0, 1)), [(2, 0), (3, 0)]), - Obstruction(Perm((0, 1)), [(3, 0), (4, 0)])], - requirements=[[Requirement(Perm((0,)), [(1, 0)])], - [Requirement(Perm((0,)), [(2, 0)])], - [Requirement(Perm((0,)), [(3, 0)])]]) diff --git a/tests/strategies/__init__.py b/tests/strategies/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/strategies/batch_strategies/__init__.py b/tests/strategies/batch_strategies/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/strategies/batch_strategies/test_cell_insertion.py b/tests/strategies/batch_strategies/test_cell_insertion.py deleted file mode 100644 index 8bb15ba48..000000000 --- a/tests/strategies/batch_strategies/test_cell_insertion.py +++ /dev/null @@ -1,160 +0,0 @@ -from permuta import Perm -from tilescopethree.strategies import (all_cell_insertions, all_col_insertions, - all_factor_insertions, - all_requirement_extensions, - all_requirement_insertions, - all_row_insertions) -from tilings import Obstruction, Requirement, Tiling - -pytest_plugins = [ - 'tests.fixtures.obstructions_requirements', - 'tests.fixtures.simple_tiling' -] - - -def test_all_cell_insertions_points(simple_tiling): - strats = set([tuple(s.comb_classes) - for s in all_cell_insertions(simple_tiling, maxreqlen=1)]) - assert all(len(s) == 2 for s in strats) - actual = set() - actual.add((Tiling( - obstructions=[Obstruction(Perm((0,)), [(0, 1)])], - requirements=[[Requirement(Perm((0, 1)), [(0, 0), (1, 0)]), - Requirement(Perm((0, 1)), [(0, 0), (1, 1)])]]), - Tiling( - obstructions=[Obstruction(Perm((0,)), [(1, 0)])], - requirements=[[Requirement(Perm((0,)), [(0, 1)])], - [Requirement(Perm((0, 1)), [(0, 0), (1, 1)])]]))) - - actual.add((Tiling( - obstructions=[Obstruction(Perm((0,)), ((0, 1),)), - Obstruction(Perm((0,)), ((1, 0),))], - requirements=[[Requirement(Perm((0, 1)), ((0, 0), (1, 1)))]]), - Tiling( - obstructions=[Obstruction(Perm((0,)), ((0, 1),))], - requirements=[[Requirement(Perm((0,)), ((1, 0),))], - [Requirement(Perm((0, 1)), ((0, 0), (1, 0))), - Requirement(Perm((0, 1)), ((0, 0), (1, 1)))]]))) - - actual.add((Tiling(obstructions=[Obstruction(Perm(tuple()), tuple())]), - Tiling( - obstructions=[Obstruction(Perm((1, 0)), ((0, 1), (1, 0)))], - requirements=[[Requirement(Perm((0,)), ((0, 0),))], - [Requirement(Perm((0, 1)), ((0, 0), (1, 0))), - Requirement(Perm((0, 1)), ((0, 0), (1, 1)))]]))) - - actual.add((Tiling( - requirements=[[Requirement(Perm((0, 1)), ((0, 0), (1, 0)))]]), - Tiling( - obstructions=[Obstruction(Perm((1, 0)), ((0, 1), (1, 0)))], - requirements=[[Requirement(Perm((0,)), ((1, 1),))], - [Requirement(Perm((0, 1)), ((0, 0), (1, 0))), - Requirement(Perm((0, 1)), ((0, 0), (1, 1)))]]))) - print(simple_tiling) - assert strats == actual - - -def test_all_cell_insertions(typical_redundant_requirements, - typical_redundant_obstructions): - tiling = Tiling(obstructions=typical_redundant_obstructions, - requirements=typical_redundant_requirements) - strats = set([tuple(s.comb_classes) - for s in all_cell_insertions(tiling, maxreqlen=3)]) - assert all(len(s) == 2 for s in strats) - assert ((Tiling( - obstructions=typical_redundant_obstructions + [ - Obstruction(Perm((0, 1, 2)), [(0, 1), (0, 1), (0, 1)])], - requirements=typical_redundant_requirements), - Tiling( - obstructions=typical_redundant_obstructions, - requirements=typical_redundant_requirements + [ - [Requirement(Perm((0, 1, 2)), [(0, 1), (0, 1), (0, 1)])]]) - ) in strats) - - -def test_all_requirement_extension(): - t = Tiling.from_string('123_132').add_single_cell_requirement( - Perm((0, 1)), (0, 0)) - strats = set([tuple(s.comb_classes) - for s in all_requirement_extensions(t, maxreqlen=3)]) - actual = set([ - (t.add_single_cell_obstruction(Perm((2, 0, 1)), (0, 0)), - t.add_single_cell_requirement(Perm((2, 0, 1)), (0, 0))), - (t.add_single_cell_obstruction(Perm((1, 0, 2)), (0, 0)), - t.add_single_cell_requirement(Perm((1, 0, 2)), (0, 0))), - (t.add_single_cell_obstruction(Perm((1, 2, 0)), (0, 0)), - t.add_single_cell_requirement(Perm((1, 2, 0)), (0, 0))), - ]) - assert actual == strats - - -def test_all_row_insertion(): - t = Tiling(obstructions=[ - Obstruction(Perm((0, 1)), ((0, 0),)*2), - Obstruction(Perm((0, 1)), ((1, 0),)*2), - Obstruction(Perm((0, 1, 2)), ((0, 1),)*3), - ], requirements=[ - [Requirement(Perm((0, 1)), ((0, 1),)*2)] - ]) - strats = set([tuple(s.comb_classes) - for s in all_row_insertions(t)]) - actual = set([ - (Tiling(obstructions=[Obstruction(Perm((0, 1, 2)), ((0, 0),)*3)], - requirements=[[Requirement(Perm((0, 1)), ((0, 0),)*2)]]), - t.add_list_requirement([Requirement(Perm((0,)), ((0, 0),)), - Requirement(Perm((0,)), ((1, 0),)), ])), ]) - assert actual == strats - assert (next(all_row_insertions(t)).formal_step == - 'Either row 0 is empty or not.') - - -def test_all_col_insertion(): - t = Tiling(obstructions=[ - Obstruction(Perm((0, 1)), ((0, 0),)*2), - Obstruction(Perm((0, 1)), ((1, 0),)*2), - Obstruction(Perm((0, 1, 2)), ((0, 1),)*3), - ], requirements=[ - [Requirement(Perm((0, 1)), ((0, 1),)*2)] - ]) - strats = set([tuple(s.comb_classes) - for s in all_col_insertions(t)]) - actual = set([ - (t.add_single_cell_obstruction(Perm((0,)), (1, 0)), - t.add_single_cell_requirement(Perm((0,)), (1, 0)),) - ]) - assert actual == strats - assert (next(all_col_insertions(t)).formal_step == - 'Either column 1 is empty or not.') - - -def test_all_requirement_insertion(): - t = Tiling(obstructions=[ - Obstruction(Perm((0, 1)), ((0, 0), (0, 0))), - Obstruction(Perm((0, 1)), ((1, 0), (1, 0))), - Obstruction(Perm((0, 1)), ((0, 0), (1, 0))), - ]) - strats = set(tuple(s.comb_classes) - for s in all_requirement_insertions(t, 2)) - assert len(strats) == 5 - strat_formal_steps = ( - set(s.formal_step for s in all_requirement_insertions(t, 2))) - assert 'Insert 0 in cell (1, 0).' in strat_formal_steps - assert 'Insert 10: (0, 0), (1, 0).' in strat_formal_steps - - -def test_all_factor_insertions(): - t = Tiling(obstructions=[ - Obstruction(Perm((0, 1)), ((0, 0), (0, 0))), - Obstruction(Perm((0, 1)), ((1, 0), (1, 0))), - Obstruction(Perm((1, 0)), ((1, 1), (1, 1))), - Obstruction(Perm((1, 0)), ((1, 2), (1, 2))), - Obstruction(Perm((0, 1, 2)), ((0, 0), (1, 1), (1, 2))), - Obstruction(Perm((0, 1)), ((0, 0), (1, 0))), - ]) - strats = set(tuple(s.comb_classes) - for s in all_factor_insertions(t)) - assert len(strats) == 2 - strat_formal_steps = ( - set(s.formal_step for s in all_factor_insertions(t))) - assert 'Insert 0 in cell (0, 0).' in strat_formal_steps - assert 'Insert 01: (1, 1), (1, 2).' in strat_formal_steps diff --git a/tests/strategies/batch_strategies/test_requirement_corroboration.py b/tests/strategies/batch_strategies/test_requirement_corroboration.py deleted file mode 100644 index 04f2c05ae..000000000 --- a/tests/strategies/batch_strategies/test_requirement_corroboration.py +++ /dev/null @@ -1,58 +0,0 @@ -from permuta import Perm -from tilescopethree.strategies import requirement_corroboration -from tilings import Obstruction, Requirement, Tiling - -pytest_plugins = [ - 'tests.fixtures.obstructions_requirements' -] - - -def test_requirement_corroboration(typical_redundant_requirements, - typical_redundant_obstructions): - tiling = Tiling( - obstructions=[Obstruction(Perm((1, 0)), [(0, 1), (1, 0)])], - requirements=[[Requirement(Perm((0, 1)), [(0, 0), (1, 0)]), - Requirement(Perm((0, 1)), [(0, 0), (1, 1)])]]) - reqins = list(strat.comb_classes - for strat in requirement_corroboration(tiling, None)) - assert len(reqins) == 2 - strat1, strat2 = reqins - - assert len(strat1) == 2 - til1, til2 = strat1 - assert til1 == Tiling( - obstructions=[Obstruction(Perm((0, 1)), [(0, 0), (1, 0)]), - Obstruction(Perm((1, 0)), [(0, 1), (1, 0)])], - requirements=[[Requirement(Perm((0,)), [(0, 0)])], - [Requirement(Perm((0,)), [(1, 1)])]]) - assert til2 == Tiling( - obstructions=[], - requirements=[[Requirement(Perm((0, 1)), [(0, 0), (1, 0)])]]) - - tiling = Tiling( - obstructions=typical_redundant_obstructions, - requirements=typical_redundant_requirements) - reqins = list(strat.comb_classes - for strat in requirement_corroboration(tiling, None)) - assert len(reqins) == sum(len(reqs) for reqs in tiling.requirements - if len(reqs) > 1) - til1, til2 = reqins[0] - assert (set([til1, til2]) == set([ - Tiling(requirements=[ - [Requirement(Perm((0, 1)), ((2, 0), (3, 1)))], - [Requirement(Perm((1, 0)), ((3, 2), (3, 1)))], - [Requirement(Perm((0, 1, 2)), ((0, 0), (1, 0), (2, 2)))], - [Requirement(Perm((0, 1, 2)), ((2, 2), (2, 2), (2, 2))), - Requirement(Perm((1, 0, 2)), ((0, 0), (0, 0), (0, 0)))]], - obstructions=typical_redundant_obstructions), - Tiling(requirements=[ - [Requirement(Perm((0, 1)), ((2, 0), (3, 1)))], - [Requirement(Perm((1, 0)), ((3, 2), (3, 1)))], - [Requirement(Perm((0, 1, 2)), ((0, 0), (1, 0), (2, 3))), - Requirement(Perm((1, 0, 2)), ((0, 0), (1, 0), (2, 2))), - Requirement(Perm((1, 0, 2)), ((0, 1), (1, 0), (2, 2)))], - [Requirement(Perm((0, 1, 2)), ((2, 2), (2, 2), (2, 2))), - Requirement(Perm((1, 0, 2)), ((0, 0), (0, 0), (0, 0)))]], - obstructions=(typical_redundant_obstructions + - [Obstruction(Perm((0, 1, 2)), - ((0, 0), (1, 0), (2, 2)))]))])) diff --git a/tests/strategies/batch_strategies/test_requirement_extensions.py b/tests/strategies/batch_strategies/test_requirement_extensions.py deleted file mode 100644 index 7dded1530..000000000 --- a/tests/strategies/batch_strategies/test_requirement_extensions.py +++ /dev/null @@ -1,111 +0,0 @@ -from permuta import Perm -from tilescopethree.strategies import all_requirement_extensions -from tilings import Obstruction, Requirement, Tiling - -pytest_plugins = [ - 'tests.fixtures.obstructions_requirements', - 'tests.fixtures.simple_tiling' -] - - -def test_requirement_extensions(typical_obstructions_with_local, - typical_requirements_with_local): - tiling = Tiling(obstructions=typical_obstructions_with_local, - requirements=typical_requirements_with_local) - strats = set([frozenset(s.comb_classes) - for s in all_requirement_extensions(tiling, maxreqlen=3)]) - - actual = set([ - frozenset([ - tiling.add_single_cell_obstruction(Perm((0, 1)), (0, 0)), - tiling.add_single_cell_requirement(Perm((0, 1)), (0, 0)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((1, 0)), (0, 0)), - tiling.add_single_cell_requirement(Perm((1, 0)), (0, 0)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((0, 1, 2)), (0, 0)), - tiling.add_single_cell_requirement(Perm((0, 1, 2)), (0, 0)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((0, 2, 1)), (0, 0)), - tiling.add_single_cell_requirement(Perm((0, 2, 1)), (0, 0)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((1, 0, 2)), (0, 0)), - tiling.add_single_cell_requirement(Perm((1, 0, 2)), (0, 0)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((1, 2, 0)), (0, 0)), - tiling.add_single_cell_requirement(Perm((1, 2, 0)), (0, 0)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((2, 0, 1)), (0, 0)), - tiling.add_single_cell_requirement(Perm((2, 0, 1)), (0, 0)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((2, 1, 0)), (0, 0)), - tiling.add_single_cell_requirement(Perm((2, 1, 0)), (0, 0)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((1, 0)), (3, 1)), - tiling.add_single_cell_requirement(Perm((1, 0)), (3, 1)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((2, 1, 0)), (3, 1)), - tiling.add_single_cell_requirement(Perm((2, 1, 0)), (3, 1)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((2, 1, 0)), (2, 0)), - tiling.add_single_cell_requirement(Perm((2, 1, 0)), (2, 0)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((0, 2, 1)), (2, 2)), - tiling.add_single_cell_requirement(Perm((0, 2, 1)), (2, 2)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((1, 0, 2)), (2, 2)), - tiling.add_single_cell_requirement(Perm((1, 0, 2)), (2, 2)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((1, 2, 0)), (2, 2)), - tiling.add_single_cell_requirement(Perm((1, 2, 0)), (2, 2)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((2, 0, 1)), (2, 2)), - tiling.add_single_cell_requirement(Perm((2, 0, 1)), (2, 2)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((2, 1, 0)), (2, 2)), - tiling.add_single_cell_requirement(Perm((2, 1, 0)), (2, 2)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((0, 1)), (3, 0)), - tiling.add_single_cell_requirement(Perm((0, 1)), (3, 0)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((1, 0)), (3, 0)), - tiling.add_single_cell_requirement(Perm((1, 0)), (3, 0)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((0, 1, 2)), (3, 0)), - tiling.add_single_cell_requirement(Perm((0, 1, 2)), (3, 0)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((1, 0, 2)), (3, 0)), - tiling.add_single_cell_requirement(Perm((1, 0, 2)), (3, 0)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((1, 2, 0)), (3, 0)), - tiling.add_single_cell_requirement(Perm((1, 2, 0)), (3, 0)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((2, 0, 1)), (3, 0)), - tiling.add_single_cell_requirement(Perm((2, 0, 1)), (3, 0)) - ]), - frozenset([ - tiling.add_single_cell_obstruction(Perm((2, 1, 0)), (3, 0)), - tiling.add_single_cell_requirement(Perm((2, 1, 0)), (3, 0)) - ])]) - assert strats == actual diff --git a/tests/strategies/decomposition_strategies/test_factor.py b/tests/strategies/decomposition_strategies/test_factor.py deleted file mode 100644 index 66a39e6b3..000000000 --- a/tests/strategies/decomposition_strategies/test_factor.py +++ /dev/null @@ -1,86 +0,0 @@ -from permuta import Perm -from tilescopethree.strategies import ( - factor, factor_with_interleaving, factor_with_monotone_interleaving, - unions_of_factor, unions_of_factor_with_interleaving, - unions_of_factor_with_monotone_interleaving) -from tilings import Obstruction, Requirement, Tiling -from tilings.algorithms import (Factor, FactorWithInterleaving, - FactorWithMonotoneInterleaving) -from tilings.strategies.decomposition import general_factor - -pytest_plugins = [ - 'tests.fixtures.simple_tiling', - 'tests.fixtures.diverse_tiling', - 'tests.fixtures.no_point_tiling', -] - - -def test_general_factor(simple_tiling, diverse_tiling): - assert len(list(general_factor(simple_tiling, Factor))) == 0 - assert (len(list(general_factor(simple_tiling, - FactorWithMonotoneInterleaving))) == 0) - assert (len(list(general_factor(simple_tiling, - FactorWithInterleaving))) == 0) - assert (len(list(general_factor(diverse_tiling, - FactorWithInterleaving))) == 1) - # Test union param - strats = list(general_factor(diverse_tiling, - FactorWithInterleaving, - union=True)) - assert len(strats) == 14 - assert sum(1 for s in strats if 'unions' in s.formal_step) == 13 - assert sum(1 for s in strats if all(s.workable)) == 1 - assert sum(1 for s in strats if not any(s.workable)) == 13 - # Test union param with workable to False - strats = list(general_factor(diverse_tiling, - FactorWithInterleaving, - union=True, - workable=False)) - assert sum(1 for s in strats if all(s.workable)) == 0 - assert sum(1 for s in strats if not any(s.workable)) == 14 - # Test union param with workable to True - strats = list(general_factor(diverse_tiling, - FactorWithInterleaving, - union=True, - workable=True)) - assert sum(1 for s in strats if all(s.workable)) == 1 - assert sum(1 for s in strats if not any(s.workable)) == 13 - - -def test_factor_no_unions(simple_tiling, - diverse_tiling, - no_point_tiling): - assert len(list(factor(simple_tiling))) == 0 - assert len(list(factor(diverse_tiling))) == 0 - tiling = Tiling( - obstructions=[Obstruction(Perm((0, 1)), [(0, 0), (0, 0)])], - requirements=[[Requirement(Perm((0, 1)), [(1, 1), (1, 1)]), - Requirement(Perm((0, 1)), [(1, 1), (1, 2)])]]) - strats = [s.comb_classes for s in factor(tiling)] - assert len(strats) == 1 - factors = strats[0] - assert set(factors) == set([ - Tiling(requirements=[[Requirement(Perm((0, 1)), [(0, 0), (0, 0)]), - Requirement(Perm((0, 1)), [(0, 0), (0, 1)])]]), - Tiling(obstructions=[Obstruction(Perm((0, 1)), [(0, 0), (0, 0)])])]) - - strats = [s.comb_classes - for s in factor_with_interleaving(diverse_tiling)] - assert len(strats) == 1 - factors = strats[0] - assert len(factors) == 4 - print(diverse_tiling) - - assert set(factors) == set([ - Tiling(obstructions=[Obstruction(Perm((0, 2, 3, 1)), - [(0, 0), (1, 1), (1, 1), (2, 0)])], - requirements=[[Requirement(Perm((0,)), [(2, 0)])]]), - Tiling(obstructions=[Obstruction(Perm((0, 1)), [(0, 0), (0, 0)]), - Obstruction(Perm((1, 0)), [(0, 0), (0, 0)])], - requirements=[[Requirement(Perm((0,)), [(0, 0)])]]), - Tiling(obstructions=[Obstruction(Perm((0, 1)), [(0, 0), (0, 0)]), - Obstruction(Perm((1, 0)), [(0, 0), (0, 0)])], - requirements=[[Requirement(Perm((0,)), [(0, 0)])]]), - Tiling(requirements=[[Requirement(Perm((1, 0)), [(0, 2), (0, 1)]), - Requirement(Perm((0, 2, 1)), - [(0, 1), (0, 2), (1, 2)])]])]) diff --git a/tests/strategies/equivalence_strategies/test_component_fusion.py b/tests/strategies/equivalence_strategies/test_component_fusion.py deleted file mode 100644 index 27bfebaaa..000000000 --- a/tests/strategies/equivalence_strategies/test_component_fusion.py +++ /dev/null @@ -1,41 +0,0 @@ -import pytest - -from permuta import Perm -from tilescopethree.strategies import component_fusion -from tilings import Obstruction, Tiling - - -@pytest.fixture -def tiling1(): - t = Tiling(obstructions=[ - Obstruction(Perm((1, 0)), ((0, 1), (1, 1))), - Obstruction(Perm((1, 0)), ((0, 1), (0, 1))), - Obstruction(Perm((1, 0)), ((0, 1), (1, 0))), - Obstruction(Perm((1, 0)), ((0, 1), (0, 0))), - Obstruction(Perm((1, 0)), ((0, 0), (0, 0))), - Obstruction(Perm((1, 0)), ((0, 0), (1, 0))), - Obstruction(Perm((1, 0)), ((1, 0), (1, 0))), - Obstruction(Perm((1, 0)), ((1, 1), (1, 0))), - Obstruction(Perm((1, 0)), ((1, 1), (1, 1))) - ]) - return t - - -@pytest.fixture -def tiling2(): - t = Tiling(obstructions=[ - Obstruction(Perm((0, 1)), ((0, 0), (1, 0))), - Obstruction(Perm((0, 2, 1)), ((0, 0), (0, 0), (0, 0))), - Obstruction(Perm((0, 2, 1)), ((1, 0), (1, 0), (1, 0))), - Obstruction(Perm((0, 2, 1, 3)), ((0, 0), (0, 0), (2, 0), (2, 0))), - Obstruction(Perm((0, 2, 1, 3)), ((0, 0), (2, 0), (2, 0), (2, 0))), - Obstruction(Perm((0, 2, 1, 3)), ((1, 0), (1, 0), (2, 0), (2, 0))), - Obstruction(Perm((0, 2, 1, 3)), ((1, 0), (2, 0), (2, 0), (2, 0))), - Obstruction(Perm((0, 2, 1, 3)), ((2, 0), (2, 0), (2, 0), (2, 0))) - ]) - return t - - -def test_fusion_with_interleaving(tiling1, tiling2): - assert len(list(component_fusion(tiling1))) == 0 - assert len(list(component_fusion(tiling2))) == 1 diff --git a/tests/strategies/equivalence_strategies/test_fusion.py b/tests/strategies/equivalence_strategies/test_fusion.py deleted file mode 100644 index dbed429b5..000000000 --- a/tests/strategies/equivalence_strategies/test_fusion.py +++ /dev/null @@ -1,69 +0,0 @@ -import pytest - -from comb_spec_searcher import Rule -from permuta import Perm -from tilescopethree.strategies.equivalence_strategies import fusion -from tilings import Obstruction, Tiling - - -@pytest.fixture -def small_tiling(): - t = Tiling(obstructions=[ - Obstruction(Perm((1, 0)), ((0, 1), (1, 1))), - Obstruction(Perm((1, 0)), ((0, 1), (0, 1))), - Obstruction(Perm((1, 0)), ((0, 1), (1, 0))), - Obstruction(Perm((1, 0)), ((0, 1), (0, 0))), - Obstruction(Perm((1, 0)), ((0, 0), (0, 0))), - Obstruction(Perm((1, 0)), ((0, 0), (1, 0))), - Obstruction(Perm((1, 0)), ((1, 0), (1, 0))), - Obstruction(Perm((1, 0)), ((1, 1), (1, 0))), - Obstruction(Perm((1, 0)), ((1, 1), (1, 1))) - ]) - return t - - -@pytest.fixture -def big_tiling(): - """ The original tiling from Jay's idea """ - t = Tiling(obstructions=( - Obstruction(Perm((0,)), ((0, 1),)), - Obstruction(Perm((0,)), ((0, 2),)), - Obstruction(Perm((0,)), ((0, 3),)), - Obstruction(Perm((0,)), ((1, 2),)), - Obstruction(Perm((0,)), ((1, 3),)), - Obstruction(Perm((1, 0)), ((0, 0), (0, 0))), - Obstruction(Perm((1, 0)), ((0, 0), (1, 0))), - Obstruction(Perm((1, 0)), ((0, 0), (2, 0))), - Obstruction(Perm((1, 0)), ((1, 0), (1, 0))), - Obstruction(Perm((1, 0)), ((1, 0), (2, 0))), - Obstruction(Perm((1, 0)), ((1, 1), (1, 0))), - Obstruction(Perm((1, 0)), ((1, 1), (1, 1))), - Obstruction(Perm((1, 0)), ((1, 1), (2, 0))), - Obstruction(Perm((1, 0)), ((1, 1), (2, 1))), - Obstruction(Perm((1, 0)), ((2, 0), (2, 0))), - Obstruction(Perm((1, 0)), ((2, 1), (2, 0))), - Obstruction(Perm((1, 0)), ((2, 1), (2, 1))), - Obstruction(Perm((1, 0)), ((2, 2), (2, 0))), - Obstruction(Perm((1, 0)), ((2, 2), (2, 1))), - Obstruction(Perm((1, 0)), ((2, 2), (2, 2))), - Obstruction(Perm((2, 1, 0)), ((2, 3), (2, 3), (2, 0))), - Obstruction(Perm((2, 1, 0)), ((2, 3), (2, 3), (2, 1))), - Obstruction(Perm((2, 1, 0)), ((2, 3), (2, 3), (2, 2))), - Obstruction(Perm((2, 1, 0)), ((2, 3), (2, 3), (2, 3))) - ), requirements=()) - return t - - -def test_fusion(small_tiling, big_tiling): - assert len(list(fusion(big_tiling))) == 0 - small_tiling_rules = list(fusion(small_tiling)) - assert len(small_tiling_rules) == 2 - assert all(isinstance(rule, Rule) for rule in small_tiling_rules) - assert all(rule.constructor == 'other' for rule in small_tiling_rules) - t = Tiling(obstructions=[ - Obstruction(Perm((0, 1)), ((0, 0), (0, 0))), - Obstruction(Perm((0, 1)), ((0, 0), (1, 0))), - Obstruction(Perm((0, 1)), ((1, 0), (1, 0))), - ]) - t_rules = list(fusion(t)) - assert len(t_rules) == 1 diff --git a/tests/strategies/equivalence_strategies/test_point_placements.py b/tests/strategies/equivalence_strategies/test_point_placements.py deleted file mode 100644 index ee765e8f4..000000000 --- a/tests/strategies/equivalence_strategies/test_point_placements.py +++ /dev/null @@ -1,164 +0,0 @@ -from permuta import Perm -from permuta.misc import DIR_EAST, DIR_NORTH, DIR_SOUTH, DIR_WEST, DIRS -from tilescopethree.strategies import point_placement, requirement_placement -from tilings import Obstruction, Requirement, Tiling - -pytest_plugins = [ - 'tests.fixtures.obstructions_requirements', - 'tests.fixtures.simple_tiling', - 'tests.fixtures.diverse_tiling', - 'tests.fixtures.no_point_tiling' -] - - -def test_point_placement(diverse_tiling, no_point_tiling): - strats = list(point_placement(diverse_tiling)) - assert len(strats) == 5 * len(DIRS) - strats = list(requirement_placement(no_point_tiling)) - assert len(strats) == 9 * len(DIRS) - strats = list(point_placement(no_point_tiling)) - assert len(strats) == 3 * len(DIRS) - - -def test_place_point_of_requirement_point_only(diverse_tiling): - tiling = diverse_tiling.place_point_of_gridded_permutation( - diverse_tiling.requirements[0][0], 0, DIR_WEST) - assert tiling == Tiling( - obstructions=[ - Obstruction(Perm((0,)), [(1, 0)]), - Obstruction(Perm((0,)), [(1, 2)]), - Obstruction(Perm((0,)), [(2, 0)]), - Obstruction(Perm((0,)), [(2, 2)]), - Obstruction(Perm((0, 1)), [(2, 1), (2, 1)]), - Obstruction(Perm((0, 1)), [(4, 3), (4, 3)]), - Obstruction(Perm((1, 0)), [(2, 1), (2, 1)]), - Obstruction(Perm((1, 0)), [(4, 3), (4, 3)]), - Obstruction(Perm((0, 2, 3, 1)), [(0, 0), (1, 3), (1, 3), (4, 0)]), - Obstruction(Perm((0, 2, 3, 1)), [(0, 0), (1, 3), (1, 3), (4, 2)]), - Obstruction(Perm((0, 2, 3, 1)), [(0, 0), (1, 3), (3, 3), (4, 0)]), - Obstruction(Perm((0, 2, 3, 1)), [(0, 0), (1, 3), (3, 3), (4, 2)]), - Obstruction(Perm((0, 2, 3, 1)), [(0, 0), (3, 3), (3, 3), (4, 0)]), - Obstruction(Perm((0, 2, 3, 1)), [(0, 0), (3, 3), (3, 3), (4, 2)]), - Obstruction(Perm((0, 2, 3, 1)), [(0, 2), (1, 3), (1, 3), (4, 2)]), - Obstruction(Perm((0, 2, 3, 1)), [(0, 2), (1, 3), (3, 3), (4, 2)]), - Obstruction(Perm((0, 2, 3, 1)), [(0, 2), (3, 3), (3, 3), (4, 2)])], - requirements=[ - [Requirement(Perm((0,)), [(2, 1)])], - [Requirement(Perm((0,)), [(4, 3)])], - [Requirement(Perm((0,)), [(4, 0)]), - Requirement(Perm((0,)), [(4, 2)])], - [Requirement(Perm((1, 0)), [(0, 4), (0, 3)]), - Requirement(Perm((0, 2, 1)), [(0, 3), (0, 4), (1, 4)]), - Requirement(Perm((0, 2, 1)), [(0, 3), (0, 4), (3, 4)])]]) - - assert tiling == diverse_tiling.place_point_of_gridded_permutation( - diverse_tiling.requirements[0][0], 0, DIR_EAST) - assert tiling == diverse_tiling.place_point_of_gridded_permutation( - diverse_tiling.requirements[0][0], 0, DIR_NORTH) - assert tiling == diverse_tiling.place_point_of_gridded_permutation( - diverse_tiling.requirements[0][0], 0, DIR_SOUTH) - - print(Tiling( - obstructions=[ - Obstruction(Perm((0,)), [(2, 0)]), - Obstruction(Perm((0,)), [(2, 2)]), - Obstruction(Perm((0, 1)), [(1, 0), (1, 0)]), - Obstruction(Perm((0, 1)), [(1, 0), (1, 2)]), - Obstruction(Perm((0, 1)), [(1, 2), (1, 2)]), - Obstruction(Perm((0, 1)), [(3, 1), (3, 1)]), - Obstruction(Perm((0, 1)), [(2, 3), (2, 3)]), - Obstruction(Perm((0, 1)), [(2, 3), (4, 3)]), - Obstruction(Perm((0, 1)), [(4, 3), (4, 3)]), - Obstruction(Perm((1, 0)), [(1, 0), (1, 0)]), - Obstruction(Perm((1, 0)), [(1, 2), (1, 0)]), - Obstruction(Perm((1, 0)), [(1, 2), (1, 2)]), - Obstruction(Perm((1, 0)), [(3, 1), (3, 1)]), - Obstruction(Perm((1, 0)), [(2, 3), (2, 3)]), - Obstruction(Perm((1, 0)), [(2, 3), (4, 3)]), - Obstruction(Perm((1, 0)), [(4, 3), (4, 3)]), - Obstruction(Perm((0, 1, 2)), [(0, 0), (1, 3), (1, 3)]), - Obstruction(Perm((0, 2, 3, 1)), [(0, 2), (1, 3), (1, 3), (4, 2)])], - requirements=[ - [Requirement(Perm((0,)), [(3, 1)])], - [Requirement(Perm((0,)), [(1, 0)]), - Requirement(Perm((0,)), [(1, 2)])], - [Requirement(Perm((0,)), [(2, 3)]), - Requirement(Perm((0,)), [(4, 3)])], - [Requirement(Perm((1, 0)), [(0, 4), (0, 3)]), - Requirement(Perm((0, 2, 1)), [(0, 3), (0, 4), (1, 4)])]])) - tiling = diverse_tiling.place_point_of_gridded_permutation( - diverse_tiling.requirements[1][0], 0, DIR_WEST) - assert tiling == Tiling( - obstructions=[ - Obstruction(Perm((0,)), [(2, 0)]), - Obstruction(Perm((0,)), [(2, 2)]), - Obstruction(Perm((0, 1)), [(1, 0), (1, 0)]), - Obstruction(Perm((0, 1)), [(1, 0), (1, 2)]), - Obstruction(Perm((0, 1)), [(1, 2), (1, 2)]), - Obstruction(Perm((0, 1)), [(3, 1), (3, 1)]), - Obstruction(Perm((0, 1)), [(2, 3), (2, 3)]), - Obstruction(Perm((0, 1)), [(2, 3), (4, 3)]), - Obstruction(Perm((0, 1)), [(4, 3), (4, 3)]), - Obstruction(Perm((1, 0)), [(1, 0), (1, 0)]), - Obstruction(Perm((1, 0)), [(1, 2), (1, 0)]), - Obstruction(Perm((1, 0)), [(1, 2), (1, 2)]), - Obstruction(Perm((1, 0)), [(3, 1), (3, 1)]), - Obstruction(Perm((1, 0)), [(2, 3), (2, 3)]), - Obstruction(Perm((1, 0)), [(2, 3), (4, 3)]), - Obstruction(Perm((1, 0)), [(4, 3), (4, 3)]), - Obstruction(Perm((0, 1, 2)), [(0, 0), (1, 3), (1, 3)]), - Obstruction(Perm((0, 2, 3, 1)), [(0, 2), (1, 3), (1, 3), (4, 2)])], - requirements=[ - [Requirement(Perm((0,)), [(3, 1)])], - [Requirement(Perm((0,)), [(1, 0)]), - Requirement(Perm((0,)), [(1, 2)])], - [Requirement(Perm((0,)), [(2, 3)]), - Requirement(Perm((0,)), [(4, 3)])], - [Requirement(Perm((1, 0)), [(0, 4), (0, 3)]), - Requirement(Perm((0, 2, 1)), [(0, 3), (0, 4), (1, 4)])]]) - - tiling = Tiling(requirements=[[Requirement(Perm((0,)), [(0, 0)])]]) - assert tiling.place_point_of_gridded_permutation(tiling.requirements[0][0], - 0, DIR_SOUTH) == Tiling( - obstructions=[Obstruction(Perm((0, 1)), [(0, 0), (0, 0)]), - Obstruction(Perm((1, 0)), [(0, 0), (0, 0)])], - requirements=[[Requirement(Perm((0,)), [(0, 0)])]]) - - -def test_place_point_of_requirement(no_point_tiling): - tiling = no_point_tiling.place_point_of_gridded_permutation( - no_point_tiling.requirements[2][0], 1, DIR_WEST) - tiling2 = Tiling( - obstructions=[ - Obstruction(Perm((0, 1)), [(0, 1), (1, 3)]), - Obstruction(Perm((0, 1)), [(2, 2), (2, 2)]), - Obstruction(Perm((1, 0)), [(0, 1), (0, 1)]), - Obstruction(Perm((1, 0)), [(0, 3), (0, 1)]), - Obstruction(Perm((1, 0)), [(0, 3), (0, 3)]), - Obstruction(Perm((1, 0)), [(2, 2), (2, 2)]), - Obstruction(Perm((0, 1, 2)), [(0, 0), (1, 0), (1, 0)]), - Obstruction(Perm((0, 1, 2)), [(0, 0), (1, 0), (3, 0)]), - Obstruction(Perm((0, 1, 2)), [(0, 0), (3, 0), (3, 0)]), - Obstruction(Perm((0, 1, 2)), [(1, 0), (1, 0), (4, 0)]), - Obstruction(Perm((0, 1, 2)), [(1, 0), (3, 0), (4, 0)]), - Obstruction(Perm((0, 1, 2)), [(3, 0), (3, 0), (4, 0)]), - Obstruction(Perm((0, 2, 1)), [(0, 1), (1, 1), (1, 1)]), - Obstruction(Perm((0, 2, 1)), [(0, 1), (1, 1), (3, 1)]), - Obstruction(Perm((0, 2, 1)), [(0, 3), (1, 3), (1, 3)]), - Obstruction(Perm((0, 2, 1)), [(0, 3), (1, 3), (3, 3)]), - Obstruction(Perm((0, 2, 1)), [(0, 4), (0, 4), (1, 4)]), - Obstruction(Perm((0, 2, 1)), [(0, 4), (0, 4), (3, 4)]), - Obstruction(Perm((0, 2, 1)), [(0, 4), (1, 4), (1, 4)]), - Obstruction(Perm((0, 2, 1)), [(0, 4), (1, 4), (3, 4)]), - Obstruction(Perm((0, 2, 1)), [(0, 4), (3, 4), (3, 4)])], - requirements=[ - [Requirement(Perm((0,)), [(2, 2)])], - [Requirement(Perm((0, 1)), [(0, 0), (0, 0)]), - Requirement(Perm((0, 1)), [(0, 0), (4, 0)])], - [Requirement(Perm((0, 1)), [(0, 1), (3, 1)])], - [Requirement(Perm((0, 1)), [(1, 1), (4, 1)]), - Requirement(Perm((0,)), [(4, 3)]), - Requirement(Perm((0,)), [(4, 4)]), - Requirement(Perm((0, 1)), [(3, 1), (4, 1)])]] - ) - assert tiling == tiling2 diff --git a/tests/strategies/inferral_strategies/test_obstruction_transitivity.py b/tests/strategies/inferral_strategies/test_obstruction_transitivity.py deleted file mode 100644 index 47c913e50..000000000 --- a/tests/strategies/inferral_strategies/test_obstruction_transitivity.py +++ /dev/null @@ -1,53 +0,0 @@ -from permuta import Perm -from tilescopethree.strategies import obstruction_transitivity -from tilings import Obstruction, Requirement, Tiling - -pytest_plugins = [ - 'tests.fixtures.simple_trans' -] - - -def test_obstruction_transitivity(simple_trans_row, - simple_trans_col, - simple_trans_row_len2, - simple_trans_row_len3): - strat = obstruction_transitivity(simple_trans_row) - assert strat.comb_classes[0] == Tiling( - obstructions=[Obstruction(Perm((0, 1)), [(0, 0), (1, 0)]), - Obstruction(Perm((0, 1)), [(1, 0), (2, 0)]), - Obstruction(Perm((0, 1)), [(0, 0), (2, 0)])], - requirements=[[Requirement(Perm((0,)), [(1, 0)])]]) - - strat = obstruction_transitivity(simple_trans_col) - assert strat.comb_classes[0] == Tiling( - obstructions=[Obstruction(Perm((0, 1)), [(0, 0), (0, 1)]), - Obstruction(Perm((0, 1)), [(0, 1), (0, 2)]), - Obstruction(Perm((0, 1)), [(0, 0), (0, 2)])], - requirements=[[Requirement(Perm((0,)), [(0, 1)])]]) - - strat = obstruction_transitivity(simple_trans_row_len2) - assert strat.comb_classes[0] == Tiling( - obstructions=[Obstruction(Perm((0, 1)), [(0, 0), (1, 0)]), - Obstruction(Perm((0, 1)), [(0, 0), (2, 0)]), - Obstruction(Perm((0, 1)), [(0, 0), (3, 0)]), - Obstruction(Perm((0, 1)), [(1, 0), (2, 0)]), - Obstruction(Perm((0, 1)), [(1, 0), (3, 0)]), - Obstruction(Perm((0, 1)), [(2, 0), (3, 0)])], - requirements=[[Requirement(Perm((0,)), [(1, 0)])], - [Requirement(Perm((0,)), [(2, 0)])]]) - - strat = obstruction_transitivity(simple_trans_row_len3) - assert strat.comb_classes[0] == Tiling( - obstructions=[Obstruction(Perm((0, 1)), [(0, 0), (1, 0)]), - Obstruction(Perm((0, 1)), [(0, 0), (2, 0)]), - Obstruction(Perm((0, 1)), [(0, 0), (3, 0)]), - Obstruction(Perm((0, 1)), [(0, 0), (4, 0)]), - Obstruction(Perm((0, 1)), [(1, 0), (2, 0)]), - Obstruction(Perm((0, 1)), [(1, 0), (3, 0)]), - Obstruction(Perm((0, 1)), [(1, 0), (4, 0)]), - Obstruction(Perm((0, 1)), [(2, 0), (3, 0)]), - Obstruction(Perm((0, 1)), [(2, 0), (4, 0)]), - Obstruction(Perm((0, 1)), [(3, 0), (4, 0)])], - requirements=[[Requirement(Perm((0,)), [(1, 0)])], - [Requirement(Perm((0,)), [(2, 0)])], - [Requirement(Perm((0,)), [(3, 0)])]]) diff --git a/tests/strategies/inferral_strategies/test_row_col_seperation.py b/tests/strategies/inferral_strategies/test_row_col_seperation.py deleted file mode 100644 index ec4836e79..000000000 --- a/tests/strategies/inferral_strategies/test_row_col_seperation.py +++ /dev/null @@ -1,166 +0,0 @@ -import pytest - -from comb_spec_searcher import InferralRule -from permuta import Perm -from tilescopethree.strategies.inferral_strategies import \ - row_and_column_separation -from tilings import Obstruction, Tiling - - -@pytest.fixture -def not_separable_tilings(): - t1 = Tiling(obstructions=[ - Obstruction(Perm((0, 1, 2)), ((0, 0),)*3), - Obstruction(Perm((0, 1, 2)), ((1, 0),)*3), - Obstruction(Perm((0, 1, 2)), ((2, 0),)*3), - Obstruction(Perm((0, 1)), ((0, 0), (1, 0))), - Obstruction(Perm((0, 1)), ((1, 0), (2, 0))) - ]) - t2 = Tiling(obstructions=[ - Obstruction(Perm((0, 1, 2)), ((0, 0),)*3), - Obstruction(Perm((0, 1, 2)), ((1, 0),)*3), - Obstruction(Perm((0, 1, 2)), ((2, 0),)*3), - Obstruction(Perm((0, 1, 2)), ((3, 0),)*3), - Obstruction(Perm((0, 1)), ((0, 0), (1, 0))), - Obstruction(Perm((0, 1)), ((0, 0), (2, 0))), - Obstruction(Perm((0, 1)), ((1, 0), (2, 0))), - Obstruction(Perm((0, 1)), ((2, 0), (3, 0))), - ]) - t3 = Tiling(obstructions=[ - Obstruction(Perm((0, 1, 2)), ((0, 0),)*3), - Obstruction(Perm((0, 1, 2)), ((1, 0),)*3), - Obstruction(Perm((0, 1, 2)), ((2, 0),)*3), - Obstruction(Perm((0, 1, 2)), ((3, 0),)*3), - Obstruction(Perm((0, 1)), ((0, 0), (2, 0))), - Obstruction(Perm((0, 1)), ((0, 0), (3, 0))), - Obstruction(Perm((1, 0)), ((1, 0), (2, 0))), - Obstruction(Perm((0, 1)), ((1, 0), (3, 0))), - ]) - return [t1, t2, t3] - - -@pytest.fixture -def seperable_tiling1(): - t1 = Tiling(obstructions=[ - Obstruction(Perm((0, 1, 2)), ((0, 0),)*3), - Obstruction(Perm((0, 1, 2)), ((1, 0),)*3), - Obstruction(Perm((0, 1, 2)), ((2, 0),)*3), - Obstruction(Perm((0, 1)), ((0, 0), (1, 0))), - Obstruction(Perm((0, 1)), ((1, 0), (2, 0))), - Obstruction(Perm((0, 1)), ((0, 0), (2, 0))), - ]) - return t1 - - -@pytest.fixture -def seperable_tiling2(): - t2 = Tiling(obstructions=[ - Obstruction(Perm((0, 1, 2)), ((0, 0),)*3), - Obstruction(Perm((0, 1, 2)), ((1, 0),)*3), - Obstruction(Perm((0, 1, 2)), ((2, 0),)*3), - Obstruction(Perm((0, 1, 2)), ((3, 0),)*3), - Obstruction(Perm((0, 1, 2)), ((0, 1),)*3), - Obstruction(Perm((0, 1, 2)), ((1, 1),)*3), - Obstruction(Perm((0, 1, 2)), ((2, 1),)*3), - Obstruction(Perm((0,)), ((3, 1),)), - Obstruction(Perm((0, 1)), ((0, 0), (0, 1))), - Obstruction(Perm((0, 1)), ((0, 0), (1, 0))), - Obstruction(Perm((0, 1)), ((0, 0), (2, 0))), - Obstruction(Perm((0, 1)), ((0, 0), (3, 0))), - Obstruction(Perm((0, 1)), ((1, 0), (2, 0))), - Obstruction(Perm((0, 1)), ((2, 0), (3, 0))), - Obstruction(Perm((0, 1)), ((0, 1), (1, 1))), - Obstruction(Perm((0, 1)), ((0, 1), (2, 1))), - Obstruction(Perm((0, 1)), ((0, 1), (3, 1))), - Obstruction(Perm((0, 1)), ((1, 1), (2, 1))), - Obstruction(Perm((0, 1)), ((2, 1), (3, 1))), - ]) - return t2 - - -@pytest.fixture -def seperable_tiling3(): - t3 = Tiling(obstructions=[ - Obstruction(Perm((0, 1, 2)), ((0, 0),)*3), - Obstruction(Perm((0, 1, 2)), ((1, 0),)*3), - Obstruction(Perm((0, 1, 2)), ((2, 0),)*3), - Obstruction(Perm((0, 1, 2)), ((3, 0),)*3), - Obstruction(Perm((0, 1)), ((0, 0), (2, 0))), - Obstruction(Perm((0, 1)), ((0, 0), (3, 0))), - Obstruction(Perm((0, 1)), ((1, 0), (2, 0))), - Obstruction(Perm((0, 1)), ((1, 0), (3, 0))), - ]) - return t3 - - -def test_row_col_seperation(not_separable_tilings, seperable_tiling1, - seperable_tiling2, seperable_tiling3): - t = Tiling(obstructions=[ - Obstruction(Perm((0, 1)), ((0, 0),)*2), - Obstruction(Perm((0, 1)), ((1, 0),)*2), - Obstruction(Perm((0, 1)), ((0, 0), (1, 0))), - ]) - rcs = row_and_column_separation(t) - assert rcs.comb_classes[0] == Tiling(obstructions=[ - Obstruction(Perm((0, 1)), ((0, 1),)*2), - Obstruction(Perm((0, 1)), ((1, 0),)*2), - ]) - - for t in not_separable_tilings: - assert row_and_column_separation(t) is None - t1_sep = Tiling(obstructions=( - Obstruction(Perm((0,)), ((0, 0),)), - Obstruction(Perm((0,)), ((0, 1),)), - Obstruction(Perm((0,)), ((1, 0),)), - Obstruction(Perm((0,)), ((1, 2),)), - Obstruction(Perm((0,)), ((2, 1),)), - Obstruction(Perm((0,)), ((2, 2),)), - Obstruction(Perm((0, 1, 2)), ((0, 2), (0, 2), (0, 2))), - Obstruction(Perm((0, 1, 2)), ((1, 1), (1, 1), (1, 1))), - Obstruction(Perm((0, 1, 2)), ((2, 0), (2, 0), (2, 0))) - ), requirements=()) - t2_sep = Tiling(obstructions=( - Obstruction(Perm((0,)), ((0, 0),)), - Obstruction(Perm((0,)), ((0, 1),)), - Obstruction(Perm((0,)), ((0, 2),)), - Obstruction(Perm((0,)), ((0, 3),)), - Obstruction(Perm((0,)), ((1, 0),)), - Obstruction(Perm((0,)), ((1, 2),)), - Obstruction(Perm((0,)), ((1, 3),)), - Obstruction(Perm((0,)), ((1, 4),)), - Obstruction(Perm((0,)), ((2, 1),)), - Obstruction(Perm((0,)), ((2, 2),)), - Obstruction(Perm((0,)), ((2, 4),)), - Obstruction(Perm((0,)), ((3, 1),)), - Obstruction(Perm((0,)), ((3, 3),)), - Obstruction(Perm((0,)), ((3, 4),)), - Obstruction(Perm((0,)), ((4, 1),)), - Obstruction(Perm((0,)), ((4, 2),)), - Obstruction(Perm((0,)), ((4, 3),)), - Obstruction(Perm((0,)), ((4, 4),)), - Obstruction(Perm((0, 1)), ((2, 0), (3, 0))), - Obstruction(Perm((0, 1)), ((3, 0), (4, 0))), - Obstruction(Perm((0, 1, 2)), ((0, 4), (0, 4), (0, 4))), - Obstruction(Perm((0, 1, 2)), ((1, 1), (1, 1), (1, 1))), - Obstruction(Perm((0, 1, 2)), ((2, 0), (2, 0), (2, 0))), - Obstruction(Perm((0, 1, 2)), ((2, 3), (2, 3), (2, 3))), - Obstruction(Perm((0, 1, 2)), ((3, 0), (3, 0), (3, 0))), - Obstruction(Perm((0, 1, 2)), ((3, 2), (3, 2), (3, 2))), - Obstruction(Perm((0, 1, 2)), ((4, 0), (4, 0), (4, 0))) - ), requirements=()) - t3_sep = Tiling(obstructions=( - Obstruction(Perm((0,)), ((0, 0),)), - Obstruction(Perm((0,)), ((1, 0),)), - Obstruction(Perm((0,)), ((2, 1),)), - Obstruction(Perm((0,)), ((3, 1),)), - Obstruction(Perm((0, 1, 2)), ((0, 1), (0, 1), (0, 1))), - Obstruction(Perm((0, 1, 2)), ((1, 1), (1, 1), (1, 1))), - Obstruction(Perm((0, 1, 2)), ((2, 0), (2, 0), (2, 0))), - Obstruction(Perm((0, 1, 2)), ((3, 0), (3, 0), (3, 0))) - ), requirements=()) - assert (row_and_column_separation(seperable_tiling1).comb_classes[0] == - t1_sep) - assert (row_and_column_separation(seperable_tiling2).comb_classes[0] == - t2_sep) - assert (row_and_column_separation(seperable_tiling3).comb_classes[0] == - t3_sep) From 89bc0b0206573b3fc97d89e4b412b636383a83b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20Nadeau?= Date: Fri, 7 Feb 2020 10:24:32 +0000 Subject: [PATCH 12/12] move all_placements for equivalence to batch --- tilescopethree/strategies/batch_strategies.py | 1 + tilescopethree/strategies/equivalence_strategies.py | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tilescopethree/strategies/batch_strategies.py b/tilescopethree/strategies/batch_strategies.py index 5a014171c..318f82674 100644 --- a/tilescopethree/strategies/batch_strategies.py +++ b/tilescopethree/strategies/batch_strategies.py @@ -1,5 +1,6 @@ from tilings.strategies.batch import (all_cell_insertions, all_col_insertions, all_factor_insertions, + all_placements, all_point_insertions, all_requirement_extensions, all_requirement_insertions, diff --git a/tilescopethree/strategies/equivalence_strategies.py b/tilescopethree/strategies/equivalence_strategies.py index 111d34b44..28c84491c 100644 --- a/tilescopethree/strategies/equivalence_strategies.py +++ b/tilescopethree/strategies/equivalence_strategies.py @@ -1,5 +1,4 @@ -from tilings.strategies.equivalence import (all_placements, - partial_point_placement, +from tilings.strategies.equivalence import (partial_point_placement, partial_requirement_placement, point_placement, requirement_placement)