def cyclic_flats_height3(config, groundset=None): # Assume config is of a simple matroid with no isthmuses # Replace default groundset with the given one def change_groundset(cyclic_flats): if groundset is None: return cyclic_flats permutation = dict(enumerate(groundset)) new_cfs = set() for cf in cyclic_flats: new_cfs.add(frozenset(permutation[elem] for elem in cf)) return new_cfs matroid6_3_3 = BinaryMatroid2( matrix(GF(2), [ [1, 0, 0, 1, 1, 1], [0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 1, 1], ])) if config == matroid6_3_3.cf_lattice_config(): return change_groundset(matroid6_3_3.cyclic_flats()) matroid7_3_4 = BinaryMatroid2( matrix(GF(2), [ [1, 0, 0, 1, 1, 0, 1], [0, 1, 0, 1, 0, 1, 1], [0, 0, 1, 0, 1, 1, 1], ])) if config == matroid7_3_4.cf_lattice_config(): return change_groundset(matroid7_3_4.cyclic_flats()) if config == matroid7_3_4.dual().cf_lattice_config(): return change_groundset(matroid7_3_4.dual().cyclic_flats()) matroid8_4_4 = BinaryMatroid2( matrix(GF(2), [ [1, 0, 0, 0, 1, 0, 1, 1], [0, 1, 0, 0, 1, 1, 0, 1], [0, 0, 1, 0, 1, 1, 1, 0], [0, 0, 0, 1, 0, 1, 1, 1], ])) if config == matroid8_4_4.cf_lattice_config(): return change_groundset(matroid8_4_4.cyclic_flats()) # the matroid is none of the above, so it is one with nullity 2. # assume those are also known matroid5_3_2 = BinaryMatroid2( matrix(GF(2), [ [1, 0, 0, 1, 0], [0, 1, 0, 0, 1], [0, 0, 1, 1, 1], ])) if config == matroid5_3_2.cf_lattice_config(): return change_groundset(matroid5_3_2.cyclic_flats()) # uniform matroids if len(config) == 2: poset = config.poset() assert poset.bottom().size == 0 and poset.bottom().rank == 0 matroid = Uniform(poset.top().rank, poset.top().size) return change_groundset(matroid.cyclic_flats())
def iteration(matrix_): global n n += 1 if print_progress: print('\r{}'.format(n), end='', file=sys.stderr) matroid = BinaryMatroid2(matrix=matrix_) # Only consider simple matroids with no isthmuses if not matroid.is_simple() or matroid.coloops(): return candidate_config = matroid.cf_lattice_config() if candidate_config == search_config: print("\nFound:") print(matroid) print(matrix_) print('--------') return matroid
def iteration(matrix_): global n n += 1 if print_progress: print('\r{}'.format(n), end='', file=sys.stderr) matroid = BinaryMatroid2(matrix=matrix_) # Only consider simple matroids with no isthmuses if not matroid.is_simple() or matroid.coloops(): return config = matroid.cf_lattice_config() if config in results: if not matroid.is_isomorphic(results[config][0]): print("\nFound:") print(matrix_) print('--------') print(results[config][1]) config.show(index=True) return config else: results[config] = (matroid, matrix_)
[0, 0, 1, 0, 1, 1, 1], ]) matrix8_4_4 = matrix(GF(2), [ [1, 0, 0, 0, 1, 0, 1, 1], [0, 1, 0, 0, 1, 1, 0, 1], [0, 0, 1, 0, 1, 1, 1, 0], [0, 0, 0, 1, 0, 1, 1, 1], ]) matrix11_4_5 = matrix(GF(2), [ [1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1], [0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1], [0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1], ]) matroid6_3_3 = BinaryMatroid2(matrix6_3_3) matroid6_4_2 = BinaryMatroid2(matrix6_4_2) matroid7_3_4 = BinaryMatroid2(matrix7_3_4) matroid8_4_4 = BinaryMatroid2(matrix8_4_4) matroid11_4_5 = BinaryMatroid2(matrix11_4_5) #print("Isomorphic:", matroid1.is_isomorphic(matroid2)) #print("Same config:", # matroid1.cf_lattice_config() == matroid2.cf_lattice_config()) # Return atoms (in Z) of a poset, configuration or matroid def atoms(data): if isinstance(data, sage.matroids.matroid.Matroid): poset = Poset((data.cyclic_flats(), operator.le)) elif isinstance(data, Configuration):
elements2 = [ Element(size=0, rank=0, index=6), Element(3, 2, 5), Element(3, 2, 4), Element(5, 4, 3), Element(5, 4, 2), Element(5, 4, 1), Element(8, 5, 0), ] covers2 = make_covers(elements2, [(6, 5), (6, 4), (6, 2), (6, 1), (5, 3), (4, 3), (3, 0), (2, 0), (1, 0)]) config2 = Configuration(elements2, covers2) matroid = BinaryMatroid2(matrix=matrix(GF(2), [ [0, 0, 0, 0], [0, 0, 0, 0], [1, 0, 0, 1], [0, 1, 1, 0], ])) config3 = matroid.cf_lattice_config() if SHOW: config1.show(index=True, title='config1') config2.show(index=True, title="config2 (" + ("not " if config1 != config2 else "") + "equal to config1)") config3.show(label=True, title=config3) d = {config1: True} for edge in config3.covers:
return None # Finished show_progress(cyclic_flats) return cyclic_flats # Tests if __name__ == '__main__': matrix11_4_5 = matrix(GF(2), [ [1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1], [0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1], [0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1], ]) matroid11_4_5 = BinaryMatroid2(matrix11_4_5) h4 = matroid11_4_5.restrict({0, 2, 4, 5, 6, 7, 8, 9, 10}) # (9,4,3)-matroid h4 = matroid11_4_5.restrict({0, 1, 3, 4, 5, 6, 7, 8, 9, 10}) # (10,4,4)-matroid h4 = matroid11_4_5.restrict({0, 1, 3, 4, 5, 6, 7, 8, 9, 10}).restrict({0, 2, 3, 4, 5, 6, 7}) # (7,4,2)-matroid print(h4) config = h4.cf_lattice_config() # Check correctness (up to isomorphism) try: cfs = sorted( sorted(cf) for cf in cyclic_flats_height4(len( h4), h4.cf_lattice_config()).values())