Ejemplo n.º 1
0
 def make_elementary(self) -> "TileScopePack":
     """
     Create a new pack by using only one by one and elementary
     verification.
     """
     if (strat.ElementaryVerificationStrategy() in self
             and strat.OneByOneVerificationStrategy() in self
             and len(self.ver_strats) == 2 and self.iterative):
         raise ValueError("The pack is already elementary.")
     pack = self.make_iterative()
     pack = pack.add_verification(strat.OneByOneVerificationStrategy(),
                                  replace=True)
     return pack.add_verification(strat.ElementaryVerificationStrategy(),
                                  "elementary")
Ejemplo n.º 2
0
    def requirement_placements(
        cls, length: int = 2, partial: bool = False
    ) -> "TileScopePack":
        name = "".join(
            [
                "length_{length}_" if length != 2 else "",
                "partial_" if partial else "",
                "requirement_placements",
            ]
        )

        initial_strats: List[CSSstrategy] = [strat.FactorFactory()]
        if length > 1:
            initial_strats.append(strat.RequirementCorroborationFactory())

        return TileScopePack(
            initial_strats=initial_strats,
            ver_strats=[
                strat.BasicVerificationStrategy(),
                strat.InsertionEncodingVerificationStrategy(),
                strat.OneByOneVerificationStrategy(),
                strat.LocallyFactorableVerificationStrategy(),
            ],
            inferral_strats=[
                strat.RowColumnSeparationStrategy(),
                strat.ObstructionTransitivityFactory(),
            ],
            expansion_strats=[
                [
                    strat.RequirementInsertionFactory(maxreqlen=length),
                    strat.PatternPlacementFactory(partial=partial),
                ],
            ],
            name=name,
        )
Ejemplo n.º 3
0
 def only_root_placements(
     cls,
     length: int = 3,
     max_num_req: Optional[int] = 1,
     max_placement_rules_per_req: Optional[int] = None,
     partial: bool = False,
 ) -> "TileScopePack":
     partial_str = "partial_" if partial else ""
     if max_num_req is not None:
         name = (
             f"only_length_{length}_{max_num_req}_reqs_root_{partial_str}placements"
         )
     else:
         name = f"only_length_{length}_root_{partial_str}placements"
     placement_factory = strat.RequirementPlacementFactory(
         max_rules_per_req=max_placement_rules_per_req, partial=partial
     )
     return TileScopePack(
         initial_strats=[
             strat.RootInsertionFactory(maxreqlen=length, max_num_req=max_num_req),
             strat.FactorFactory(unions=True, ignore_parent=False, workable=False),
         ],
         ver_strats=[
             strat.BasicVerificationStrategy(),
             strat.InsertionEncodingVerificationStrategy(),
             strat.OneByOneVerificationStrategy(),
             strat.LocallyFactorableVerificationStrategy(),
         ],
         inferral_strats=[
             strat.RowColumnSeparationStrategy(),
             strat.ObstructionTransitivityFactory(),
         ],
         expansion_strats=[[placement_factory]],
         name=name,
     )
Ejemplo n.º 4
0
    def all_the_strategies(cls, length: int = 1) -> "TileScopePack":
        initial_strats: List[CSSstrategy] = [strat.FactorFactory()]
        if length > 1:
            initial_strats.append(strat.RequirementCorroborationFactory())

        return TileScopePack(
            initial_strats=initial_strats,
            ver_strats=[
                strat.BasicVerificationStrategy(),
                strat.InsertionEncodingVerificationStrategy(),
                strat.OneByOneVerificationStrategy(),
                strat.LocallyFactorableVerificationStrategy(),
            ],
            inferral_strats=[
                strat.RowColumnSeparationStrategy(),
                strat.ObstructionTransitivityFactory(),
            ],
            expansion_strats=[
                [
                    strat.RequirementInsertionFactory(maxreqlen=length),
                    strat.AllPlacementsFactory(),
                ],
            ],
            name=f"all_the_strategies_{length}",
        )
Ejemplo n.º 5
0
 def requirement_placements(cls,
                            length: int = 2,
                            partial: bool = False) -> "TileScopePack":
     name = "{}{}requirement_placements".format(
         "length_{}_".format(length) if length != 2 else "",
         "partial_" if partial else "",
     )
     return TileScopePack(
         initial_strats=[
             strat.FactorFactory(),
             strat.RequirementCorroborationFactory(),
         ],
         ver_strats=[
             strat.BasicVerificationStrategy(),
             strat.InsertionEncodingVerificationStrategy(),
             strat.OneByOneVerificationStrategy(),
             strat.LocallyFactorableVerificationStrategy(),
         ],
         inferral_strats=[
             strat.RowColumnSeparationStrategy(),
             strat.ObstructionTransitivityFactory(),
         ],
         expansion_strats=[
             [strat.RequirementInsertionFactory(maxreqlen=length)],
             [strat.PatternPlacementFactory(partial=partial)],
         ],
         name=name,
     )
Ejemplo n.º 6
0
 def row_and_col_placements(cls,
                            row_only: bool = False,
                            col_only: bool = False,
                            partial: bool = False) -> "TileScopePack":
     if row_only and col_only:
         raise ValueError("Can't be row and col only.")
     place_row = not col_only
     place_col = not row_only
     both = place_col and place_row
     name = "{}{}{}{}_placements".format(
         "partial_" if partial else "",
         "row" if not col_only else "",
         "_and_" if both else "",
         "col" if not row_only else "",
     )
     rowcol_strat = strat.RowAndColumnPlacementFactory(place_row=place_row,
                                                       place_col=place_col,
                                                       partial=partial)
     return TileScopePack(
         initial_strats=[strat.FactorFactory()],
         ver_strats=[
             strat.BasicVerificationStrategy(),
             strat.InsertionEncodingVerificationStrategy(),
             strat.OneByOneVerificationStrategy(),
             strat.LocallyFactorableVerificationStrategy(),
         ],
         inferral_strats=[
             strat.RowColumnSeparationStrategy(),
             strat.ObstructionTransitivityFactory(),
         ],
         expansion_strats=[[rowcol_strat]],
         name=name,
     )
Ejemplo n.º 7
0
 def insertion_point_placements(cls,
                                length: int = 1,
                                partial: bool = False) -> "TileScopePack":
     name = "insertion_"
     if length > 1:
         name += "length_{}_".format(length)
     partial_str = "partial_" if partial else ""
     name += f"{partial_str}point_placements"
     return TileScopePack(
         initial_strats=[
             strat.FactorFactory(),
             strat.RequirementCorroborationFactory(),
             strat.CellInsertionFactory(maxreqlen=length,
                                        ignore_parent=True),
         ],
         ver_strats=[
             strat.BasicVerificationStrategy(),
             strat.InsertionEncodingVerificationStrategy(),
             strat.OneByOneVerificationStrategy(),
             strat.LocallyFactorableVerificationStrategy(),
         ],
         inferral_strats=[
             strat.RowColumnSeparationStrategy(),
             strat.ObstructionTransitivityFactory(),
         ],
         expansion_strats=[[strat.PatternPlacementFactory(partial=partial)]
                           ],
         name=name,
     )
Ejemplo n.º 8
0
 def cell_insertions(cls, length: int):
     return TileScopePack(
         initial_strats=[],
         ver_strats=[
             strat.BasicVerificationStrategy(),
             strat.InsertionEncodingVerificationStrategy(),
             strat.OneByOneVerificationStrategy(),
         ],
         inferral_strats=[],
         expansion_strats=[[strat.CellInsertionFactory(maxreqlen=length)]],
         name="length_{length}_cell_insertions",
     )
Ejemplo n.º 9
0
    def point_and_row_and_col_placements(
        cls,
        length: int = 1,
        row_only: bool = False,
        col_only: bool = False,
        partial: bool = False,
    ) -> "TileScopePack":
        if row_only and col_only:
            raise ValueError("Can't be row and col only.")
        place_row = not col_only
        place_col = not row_only
        both = place_col and place_row
        name = "".join(
            [
                "length_{length}_" if length > 1 else "",
                "partial_" if partial else "",
                "point_and_",
                "row" if not col_only else "",
                "_and_" if both else "",
                "col" if not row_only else "",
                "_placements",
            ]
        )
        rowcol_strat = strat.RowAndColumnPlacementFactory(
            place_row=place_row, place_col=place_col, partial=partial
        )

        initial_strats: List[CSSstrategy] = [strat.FactorFactory()]
        if length > 1:
            initial_strats.append(strat.RequirementCorroborationFactory())

        return TileScopePack(
            initial_strats=initial_strats,
            ver_strats=[
                strat.BasicVerificationStrategy(),
                strat.InsertionEncodingVerificationStrategy(),
                strat.OneByOneVerificationStrategy(),
                strat.LocallyFactorableVerificationStrategy(),
            ],
            inferral_strats=[
                strat.RowColumnSeparationStrategy(),
                strat.ObstructionTransitivityFactory(),
            ],
            expansion_strats=[
                [
                    strat.CellInsertionFactory(maxreqlen=length),
                    strat.PatternPlacementFactory(partial=partial),
                    rowcol_strat,
                ],
            ],
            name=name,
        )
Ejemplo n.º 10
0
 def all_the_strategies(cls, length: int = 1) -> "TileScopePack":
     return TileScopePack(
         initial_strats=[
             strat.FactorFactory(unions=False),
             strat.RequirementCorroborationFactory(),
         ],
         ver_strats=[
             strat.BasicVerificationStrategy(),
             strat.InsertionEncodingVerificationStrategy(),
             strat.OneByOneVerificationStrategy(),
             strat.LocallyFactorableVerificationStrategy(),
         ],
         inferral_strats=[
             strat.RowColumnSeparationStrategy(),
             strat.ObstructionTransitivityFactory(),
         ],
         expansion_strats=[
             [strat.RequirementInsertionFactory(maxreqlen=length)],
             [strat.AllPlacementsFactory()],
         ],
         name="all_the_strategies",
     )
Ejemplo n.º 11
0
def _one_by_one(tiling: Tiling, basis: Tuple[Perm, ...]):
    try:
        return strats.OneByOneVerificationStrategy(basis)(tiling)
    except StrategyDoesNotApply:
        return None