-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_diam.py
132 lines (111 loc) · 4.23 KB
/
run_diam.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/env python
# -*- coding: utf8 -*-
from datetime import datetime
from functools import reduce
import logging
from folpy.utils.parser.parser import Parser
from globalspectrum import is_global_indecomposable
# from globalkernel import all_global_kernels
from atomic import is_global_indecomposable_atomics
# from minion_globalspectrum import is_global_spectrum_minion_relation_n
def check_isos(sub, subs):
for s in subs:
logging.debug(s.universe)
if sub.is_isomorphic(s):
logging.debug("iso")
return True
logging.debug("no iso")
return False
def gen_subdirect_sublattices(lattices, verbose=False):
start_time = datetime.now()
L = reduce((lambda x, y: x * y), lattices)
subs = []
j = 0
i = 0
for sub in L.substructures(
filter_isos=True,
filter_subdirect=True,
proper=True):
j = j + 1
if j % 1 == 0:
logging.debug(
'Substructure Nº: %s (Time: %s)',
j,
(datetime.now() - start_time))
is_subdirect = sub.is_subdirect()
logging.debug("subdirect: %s", is_subdirect)
is_iso = sub.is_isomorphic(L)
logging.debug("iso: %s", is_iso)
if is_subdirect and not is_iso:
logging.debug("cumple")
if not check_isos(sub, subs):
subs.append(sub)
i = i + 1
if i % 1 == 0:
logging.debug('Subdirect Product Nº: %s', i)
if verbose:
logging.info("Cantidad de sublattices subdirectos: %s", len(subs))
logging.info("Tiempo sublattices: %s", (datetime.now() - start_time))
return subs
if __name__ == "__main__":
logging.basicConfig(
filename='out_run_diam2.log',
format='%(asctime)s - %(levelname)s: %(message)s',
level=logging.DEBUG
)
start_time = datetime.now()
C2 = Parser("examples/lattices/2chain.model").parse()
M3 = Parser("examples/lattices/M3.model").parse()
DiamDiam = M3 * M3
Diam2 = M3 * C2
logging.info("Tiempo carga de modelos: %s", (datetime.now() - start_time))
logging.info("Tiempo total: %s", (datetime.now() - start_time))
logging.info("--------------------------")
logging.info("Diam*2")
logging.info("--------------------------")
subs_Diam2 = gen_subdirect_sublattices([M3, C2], verbose=True)
i = 0
for lat in subs_Diam2:
lat.to_file('output/diam_variety/Diam2_%s.model' % i)
# lat.draw()
i += 1
logging.info("--------------------------")
logging.info("Diam*Diam")
logging.info("--------------------------")
subs_DiamDiam = gen_subdirect_sublattices([M3, M3], verbose=True)
i = 0
for lat in subs_DiamDiam:
lat.to_file('output/diam_variety/DiamDiam_%s.model' % i)
# lat.draw()
i += 1
logging.info("--------------------------")
logging.info("Globalmente Indescomponibles")
logging.info("--------------------------")
i = 0
logging.info("ver globalmente indescomponible para subestructuras de M3xC2")
for lat in subs_Diam2:
con_lat = lat.congruence_lattice()
logging.info("Is %s globally indecomposable? %s" %
(i, is_global_indecomposable_atomics(con_lat)))
logging.info("Is %s globally indecomposable? %s" %
(i, is_global_indecomposable(lat,
congruence_lattice=con_lat)))
i += 1
i = 0
logging.info("ver globalmente indescomponible para subestructuras de M3xM3")
for lat in subs_DiamDiam:
con_lat = lat.congruence_lattice()
logging.info("Is %s globally indecomposable? %s" %
(i, is_global_indecomposable_atomics(con_lat)))
logging.info("Is %s globally indecomposable? %s" %
(i, is_global_indecomposable(lat,
congruence_lattice=con_lat)))
i += 1
logging.info("FIN")
# continuos = subs_Diam2[4].continous()
# con = continuos[0].principal_congruence(1, 5)
# print(continuos)
# print(con)
# con_lat = subs_Diam2[4].congruence_lattice()
# con_lat.draw()
# is_global_indecomposable_atomics(con_lat)