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, )
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, )
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}", )
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, )
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, )
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, )
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, )
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", )