Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
82917fb
Algos
ReedActon Oct 16, 2025
0bd918f
tox
Ollson2921 Nov 10, 2025
3dd6713
Merge branch 'main' into il-factoring
ReedActon Nov 11, 2025
caf3ac5
Log
ReedActon Nov 24, 2025
003963f
Merge branch 'main' into il-factoring
ReedActon Nov 27, 2025
4008cbd
OOps
ReedActon Nov 27, 2025
35965d7
Merge branch 'main' into cleaner-log
ReedActon Nov 27, 2025
a60ad7a
Built Log Display
ReedActon Nov 29, 2025
a7f2a09
Merge branch 'main' into il-factoring
ReedActon Dec 1, 2025
ba40560
Changes
ReedActon Dec 1, 2025
4870f93
Merge branch 'main' into cleaner-log
ReedActon Dec 1, 2025
a7a967a
Update from Main
ReedActon Dec 1, 2025
2c56c72
tox?
ReedActon Dec 1, 2025
a2a545c
Tox Again?
ReedActon Dec 1, 2025
7c182f4
Merge pull request #66 from Ollson2921/main
Ollson2921 Dec 3, 2025
54df492
Various Fixes
ReedActon Dec 3, 2025
213f71f
Brought Back Cleaning Strategy
ReedActon Dec 3, 2025
943e062
Delete .tox/py312/.tox-info.json
ReedActon Dec 3, 2025
8b7c1e5
Update tox.ini to include types-tabulate
christianbean Dec 4, 2025
1528527
Cast new_status to Callable type
christianbean Dec 4, 2025
70321fe
Fix type hint for CombinatorialSpecificationSearcher
christianbean Dec 4, 2025
51f6002
Refactor status casting in CombinatorialSpecificationSearcher
christianbean Dec 4, 2025
04b4ca3
Add 'Any' type to import statements
christianbean Dec 4, 2025
c623f0f
Refactor new_status method for improved readability
christianbean Dec 4, 2025
8119360
Refactor new_status method for cleaner return
christianbean Dec 4, 2025
70f7741
Update tilescope_strategies.py
christianbean Dec 4, 2025
6beec10
Fix type casting for new_status in status assignment
christianbean Dec 4, 2025
dcc5c17
Update tilescope_strategies.py
christianbean Dec 4, 2025
21833ac
Refactor new_status method for better readability
christianbean Dec 4, 2025
c2c247d
Fix formatting of status assignment in tilescope_strategies.py
christianbean Dec 4, 2025
3079b56
Fix type ignore comment for status assignment
christianbean Dec 4, 2025
6e5a672
Refactor status assignment in CombinatorialSpecificationSearcher
christianbean Dec 4, 2025
c7865e8
Display Improvements and Strategy Overwrites
ReedActon Dec 4, 2025
281754c
Merge branch 'cleaner-log' of https://github.com/Ollson2921/MapplePy …
ReedActon Dec 4, 2025
3419e65
Tox and Display
ReedActon Dec 4, 2025
3b3a894
Merge branch 'cleaner-log' into il-factoring
ReedActon Dec 4, 2025
28df247
Add IL Factoring Strategies
ReedActon Dec 4, 2025
8579547
Update tilescope_strategies.py
ReedActon Dec 4, 2025
56f6fec
New Parameter Strategies
ReedActon Dec 4, 2025
fd9d5b9
Strategy Updates
ReedActon Dec 4, 2025
612d39e
tox
ReedActon Dec 4, 2025
02eb19c
Merge branch 'main' into param-strategies
christianbean Dec 8, 2025
952cda8
Do it smart
ReedActon Dec 11, 2025
ad7cea2
Lots of Fixes
ReedActon Dec 11, 2025
af70889
tox fix
ReedActon Dec 11, 2025
41a21c3
tox
ReedActon Dec 11, 2025
59aa891
Pylint
ReedActon Dec 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mapplings/algorithms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .factor import Factor, ILFactorInverted, ILFactorNormal
from .row_col_sep_mt import LTRowColSeparationMT, LTORERowColSeparationMT
from .point_placement import MTRequirementPlacement

from .parmeter_placement import ParameterPlacement

__all__ = [
"Factor",
Expand All @@ -12,5 +12,6 @@
"LTRowColSeparationMT",
"LTORERowColSeparationMT",
"MTRequirementPlacement",
"ParameterPlacement",
]
__version__ = "0.1.0"
27 changes: 17 additions & 10 deletions mapplings/algorithms/factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ILFactorNormal(Factor):
"""Does IL factoring with 00 obs as normal"""

@cached_property
def find_factors_as_cells(self):
def find_factors_as_cells(self) -> tuple[tuple[Cell, ...], ...]:
self.combine_cells_in_obs_and_reqs()
self.combine_cells_from_parameters()
factors = []
Expand All @@ -99,16 +99,16 @@ def find_factors_as_cells(self):

def make_enumerators(self):
"""Creates the enumerators needed for interleaving"""
factor_rows_and_cols = (
map(tuple, map(set, zip(*factor))) for factor in self.find_factors_as_cells
)
factor_rows_and_cols = tuple(
map(lambda x: tuple(chain.from_iterable(x)), zip(*factor_rows_and_cols))
)
cols_in_factors = list[int]()
rows_in_factors = list[int]()
for factor in self.find_factors_as_cells:
f_cols, f_rows = map(set, zip(*factor))
cols_in_factors += list(f_cols)
rows_in_factors += list(f_rows)
new_enumerators = set()
dimensions = self.tiling.dimensions
for row in range(dimensions[1]):
if factor_rows_and_cols[1].count(row) > 1:
if rows_in_factors.count(row) > 1:
new_enumerators.add(
ParameterList(
(
Expand All @@ -123,7 +123,7 @@ def make_enumerators(self):
)
)
for col in range(dimensions[0]):
if factor_rows_and_cols[0].count(col) > 1:
if cols_in_factors.count(col) > 1:
new_enumerators.add(
ParameterList(
(
Expand Down Expand Up @@ -157,11 +157,18 @@ def combine_cells_in_obs_and_reqs(self):
new_obs = set()
for row in range(self.tiling.dimensions[1]):
for col1, col2 in combinations(range(self.tiling.dimensions[0]), 2):
new_obs.add(GriddedCayleyPerm((0, 0), ((col1, row), (col2, row))))
cell1, cell2 = (col1, row), (col2, row)
if cell1 in self.cells_dict and cell2 in self.cells_dict:
new_obs.add(GriddedCayleyPerm((0, 0), (cell1, cell2)))
new_obs.symmetric_difference_update(set(self.tiling.obstructions))
for gcp in new_obs:
if not self.point_row_ob(gcp):
for cell, cell2 in combinations((gcp.find_active_cells()), 2):

if cell2 not in self.cells_dict:
print(cell, cell2)
print(self.tiling)
print(gcp)
Comment on lines +168 to +171
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you forgot to remove this

self.combine_cells(cell, cell2)
for cell, cell2 in chain.from_iterable(
combinations(
Expand Down
175 changes: 175 additions & 0 deletions mapplings/algorithms/parmeter_placement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
"""Algorithm for parameter placement"""

from cayley_permutations import CayleyPermutation

from gridded_cayley_permutations import GriddedCayleyPerm, Tiling
from gridded_cayley_permutations.point_placements import PointPlacement
from gridded_cayley_permutations.row_col_map import RowColMap

from mapplings import MappedTiling, Parameter, ParameterList
from .point_placement import MTRequirementPlacement


Cell = tuple[int, int]


class ParameterPlacement:
"""For a given mappling and containing parameter, places the parameter
in a cell of the tiling of the mappling. Places the point of the parameter
at the given index (0 based) in the given direction."""

def __init__(self, mappling: MappedTiling, param_list: ParameterList) -> None:
"""cell is the cell in the tiling which the parameter will be placed into"""
assert len(param_list) == 1, "Too many Parameters in ParameterList."
assert (
param_list in mappling.containing_parameters
), "ParameterList does not exist."
self.mappling = mappling
new_containers = list(mappling.containing_parameters)
new_containers.remove(param_list)
self.adjusted_mappling = MappedTiling(
mappling.tiling,
mappling.avoiding_parameters,
new_containers,
mappling.enumerating_parameters,
)
self.param = tuple(param_list)[0]

def param_placement(self, direction: int, index_of_pattern: int) -> MappedTiling:
"""Place a parameter in the tiling.
index_of_pattern is the index of the pattern that is placed in the tiling and is 0 based.
"""
param_cell = tuple(self.param.point_cells())[index_of_pattern]
cell = (self.param.col_map[param_cell[0]], self.param.col_map[param_cell[1]])
new_mappling = MTRequirementPlacement(
self.adjusted_mappling
).directionless_point_placement(cell)
new_avoiding_parameters = list(
new_mappling.avoiding_parameters
) + self.find_new_avoiding_parameters(direction, cell, param_cell)

new_containing_parameters = self.update_containing_parameters(
param_cell, cell, new_mappling.containing_parameters
)
new_base = new_mappling.tiling
algo = PointPlacement(self.mappling.tiling)
point_obs, point_reqs = algo.point_obstructions_and_requirements(cell)
new_obs = new_base.obstructions + point_obs
new_reqs = new_base.requirements + point_reqs
new_base = Tiling(new_obs, new_reqs, new_base.dimensions)
return MappedTiling(
new_base,
new_avoiding_parameters,
new_containing_parameters,
new_mappling.enumerating_parameters,
)

def find_new_avoiding_parameters(
self, direction: int, base_cell: Cell, param_cell: Cell
):
"""Return a list of new avoiding parameters for the new mappling."""
cells_to_insert_in = self.cells_to_insert_point_in(
direction, base_cell, param_cell
)
new_avoiding_parameters = []
for cell in cells_to_insert_in:
new_ghost = PointPlacement(self.param.ghost).directionless_point_placement(
cell
)
new_avoiding_parameters.append(
MTRequirementPlacement(
self.mappling
).new_parameter_from_point_placed_tiling(self.param, new_ghost, cell)
)
return new_avoiding_parameters

def cells_in_parameter(self, base_cell: Cell) -> tuple[Cell, ...]:
"""Gets the preimage of the base cell according to the param map."""
return self.param.map.preimage_of_cell(base_cell)

def cells_to_insert_point_in(
self, direction: int, base_cell: Cell, param_cell: Cell
):
"""Returns a list of cells in the parameter which a point can be
placed into for the resulting tiling to be an avoiding parameter (cells
which are not further in the given direction so that the pattern in the
parameter will be, therefore it must be avoided.)"""
all_cells = [
cell
for cell in self.cells_in_parameter(base_cell)
if GriddedCayleyPerm(CayleyPermutation([0]), [cell])
not in self.param.ghost.obstructions
]
cell_of_point_being_placed = param_cell
cells_to_insert_in = [
cell
for cell in all_cells
if PointPlacement(self.param.ghost).farther(
cell_of_point_being_placed, cell, direction
)
]
return cells_to_insert_in

def update_containing_parameters(
self,
param_cell: Cell,
base_cell: Cell,
containing_parameters: tuple[ParameterList, ...],
) -> tuple[ParameterList, ...]:
"""Remove [self.param] from containing parameters and add new
containing parameter list (one that is the identity)."""
param_to_update = Parameter(self.param.ghost, self.param.map)
point_placed_ghost = PointPlacement(
param_to_update.ghost
).directionless_point_placement(param_cell)
new_map = self.new_containing_param_map(
param_cell, base_cell, point_placed_ghost
)
new_containing_param = Parameter(point_placed_ghost, new_map)
return (ParameterList((new_containing_param,)),) + containing_parameters

def new_containing_param_map(
self, param_cell: Cell, base_cell: Cell, ghost: Tiling
):
"""Return a new RowColMap for the containing parameter that was placed."""
new_row_map = self.adjust_dict_in_param(
param_cell, base_cell, True, ghost.dimensions[1]
)
new_col_map = self.adjust_dict_in_param(
param_cell, base_cell, False, ghost.dimensions[0]
)
return RowColMap(new_col_map, new_row_map)

def adjust_dict_in_param(
self,
middle_cell: Cell,
base_cell: Cell,
adjust_rows: bool,
dimension: int,
):
"""Update a row or col map given the cell in the new parameter where the point is placed
and the old row or col map.
If adjust_rows = 0 then it returns the new col map, if 1 then it returns the new row map.
"""
if adjust_rows:
new_map = self.param.row_map.copy()
else:
new_map = self.param.col_map.copy()
vals_in_param = set(
cell[adjust_rows] for cell in self.cells_in_parameter(base_cell)
)
middle_val = middle_cell[adjust_rows] + 1
for val in range(dimension):
if val not in vals_in_param:
if val > middle_val:
if val not in new_map:
new_map[val] = base_cell[adjust_rows] + 2
else:
new_map[val] += 2
elif val < middle_val:
new_map[val] = base_cell[adjust_rows]
elif val > middle_val:
new_map[val] = base_cell[adjust_rows] + 2
else:
new_map[val] = base_cell[adjust_rows] + 1
return new_map
17 changes: 15 additions & 2 deletions mapplings/cleaners/mappling_cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ def _clean_parameters(mappling: MappedTiling) -> MappedTiling:
for e_list in new_enumerators
]
return MappedTiling(
mappling.tiling, new_avoiders, new_containers, new_enumerators
mappling.tiling,
new_avoiders,
new_containers,
new_enumerators,
)

return _clean_parameters
Expand All @@ -92,6 +95,13 @@ def try_to_kill(mappling: MappedTiling) -> MappedTiling:
for avoider in mappling.avoiding_parameters
):
return MappedTiling.empty_mappling()
if any(
(
all(container.positive_cells() for container in c_list)
for c_list in mappling.containing_parameters
)
):
return MappedTiling.empty_mappling()
return MappedTiling(
Tiling(
[GriddedCayleyPerm(CayleyPermutation((0,)), ((0, 0),))], [], (1, 1)
Expand Down Expand Up @@ -155,7 +165,10 @@ def reap_all_contradictions(mappling: MappedTiling) -> MappedTiling:
if new_e_list:
new_enumerators.append(e_list)
return MappedTiling(
mappling.tiling, new_avoiders, new_containers, new_enumerators
mappling.tiling,
new_avoiders,
new_containers,
new_enumerators,
)

@staticmethod
Expand Down
4 changes: 3 additions & 1 deletion mapplings/mapped_tiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ def get_objects(self, n: int) -> Objects:
objects[param].append(gcp)
return objects

def get_parameters(self, obj: GriddedCayleyPerm) -> tuple[int, ...]:
def get_parameters(
self, obj: GriddedCayleyPerm
) -> tuple[int, ...]: # This function is broken
"""Parameters are not what you think!!! This is specific to
combinatorical class parameters"""
return tuple(
Expand Down
62 changes: 62 additions & 0 deletions mapplings/strategies/mapped_tilescope.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
MapplingLessThanRowColSeparationStrategy,
MapplingLessThanOrEqualRowColSeparationStrategy,
MapplingCellInsertionFactory,
# ParamPlacementFactory,
# AvoiderExorcismFactory,
# ParameterInsertionFactory,
Comment on lines +23 to +25
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was left by mistake?

MapplingILFactorStrategy,
MapplingInvertedILFactorStrategy,
)


Expand Down Expand Up @@ -312,3 +317,60 @@ def insertion_row_and_col_placement(cls, rootmt: MappedTiling):
symmetries=[],
iterative=False,
)

@classmethod
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a point to this pack, or should it just be deleted?

def parameter_tomfoolery(cls, rootmt: MappedTiling):
"""
Create a row and column placement strategy pack which initially
makes all cells positive.
"""
return MappedTileScopePack(
initial_strats=[MapplingFactorStrategy()],
inferral_strats=[],
expansion_strats=[
[
MapplingLessThanRowColSeparationStrategy(),
]
],
ver_strats=[
AtomStrategy(),
NoParameterVerificationStrategy(rootmt),
# MapplingVerticalInsertionEncodableVerificationStrategy(),
# MapplingHorizontalInsertionEncodableVerificationStrategy(),
],
name="Param Nonsense",
symmetries=[],
iterative=False,
)

@classmethod
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to remove these changes to ?

def pack_for_1_32(
cls,
):
"""Pack to get the 1-32 tree"""
return MappedTileScopePack(
initial_strats=[
# MapplingFactorStrategy(),
MapplingInvertedILFactorStrategy(),
MapplingILFactorStrategy(),
],
inferral_strats=[
MapplingCellInsertionFactory(),
# ParamPlacementFactory(),
],
expansion_strats=[
[
# ParameterInsertionFactory(ParameterList({special_param})),
MapplingPointPlacementFactory(),
]
],
ver_strats=[
AtomStrategy(),
# NoParameterVerificationStrategy(rootmt),
MapplingVerticalInsertionEncodableVerificationStrategy(),
MapplingHorizontalInsertionEncodableVerificationStrategy(),
],
name="1-32",
symmetries=[],
iterative=False,
)
Loading