Update test_battery.py
This commit is contained in:
parent
319965a61e
commit
74903afce7
108
test_battery.py
108
test_battery.py
@ -11,6 +11,107 @@ load("minimalModel_parallel.py")
|
||||
#smodel = load("sullivan_model_K3_deg3.sobj")
|
||||
#smorphism = load("model_morphism_K3_deg3.sobj")
|
||||
|
||||
|
||||
######### TEST INTEGRAND/INTEGRAL APLn
|
||||
"""
|
||||
N=10
|
||||
for dim in range(10):
|
||||
print("Start test at dimension ", dim, flush=True)
|
||||
s = SimplicialAlgebraplN(dim)
|
||||
for i in range(N):
|
||||
value = randint(-20,20);
|
||||
p = s.integrand(value);
|
||||
#print(p);
|
||||
equal = p.integral() == value
|
||||
if not equal:
|
||||
raise Exception("The integral is not equal")
|
||||
else:
|
||||
None
|
||||
#print("ok", flush=True)
|
||||
print("Test finished")
|
||||
"""
|
||||
######### TEST SOLVE PRIMITIVE WITH RANDOM COCHAINS
|
||||
"""
|
||||
S = simplicial_complexes.Sphere(4)
|
||||
#S = simplicial_complexes.K3Surface()
|
||||
S.set_immutable()
|
||||
A = AlgebraAplK(S)
|
||||
cochainComplex = S.chain_complex(base_ring=QQ).dual()
|
||||
N = 4
|
||||
for dim in range(1,4):
|
||||
for r in range(N):
|
||||
print("Working on dimension ", dim, flush=True)
|
||||
v = random_vector(QQ, len(S.n_cells(dim)))
|
||||
print("Lifting random cochain", flush=True)
|
||||
a = A.lift_cochain(A.vector_to_cochain(v,dim))
|
||||
print("Checking Apl(K) structure", flush=True)
|
||||
a.check()
|
||||
#if a.check():
|
||||
# print("lift ok", flush=True)
|
||||
da = a.differential()
|
||||
print("Checking Apl(K) structure of the differential", flush=True)
|
||||
da.check()
|
||||
#if da.check():
|
||||
# print("da ok", flush=True)
|
||||
#p_basis = da._get_primitive_basis()
|
||||
print("Solving primitive", flush=True)
|
||||
b = da.solve_primitive()
|
||||
print("Checking Apl(K) structure of the solution found", flush=True)
|
||||
b.check()
|
||||
#if b.check():
|
||||
# print("solve_primitive ok", flush=True)
|
||||
print(b.differential()==da)
|
||||
print("Test INTEGRAL/DIFFERENTIAL COMMUTATION", flush=True)
|
||||
Diff = cochainComplex.differential(dim)
|
||||
cb = A.cochain_to_vector(b.integral(), dim)
|
||||
cda = A.cochain_to_vector(da.integral(), dim + 1)
|
||||
equal = Diff*cb == cda
|
||||
if not equal:
|
||||
raise ValueError("the cochains are not equal at degree " + str(degree))
|
||||
else:
|
||||
print("OK", flush=True)
|
||||
|
||||
"""
|
||||
def zip_with_constants(a, b, c, l):
|
||||
return [(a, b, c, i) for i in l]
|
||||
|
||||
@parallel(ncpus=Integer(24))
|
||||
def check_solve_primitive(A, dim, Diff, v):
|
||||
#print("Lift random cochain to Apl(K)", flush=True)
|
||||
a = A.lift_cochain(A.vector_to_cochain(v,dim))
|
||||
#print("Checking Apl(K) structure of the random element ", flush=True)
|
||||
a.check()
|
||||
#print(a.check(), flush=True)
|
||||
da = a.differential()
|
||||
b = da.solve_primitive()
|
||||
print("Checking Apl(K) structure of the primitive element ", flush=True)
|
||||
b.check()
|
||||
print("Checking b.differential()==da ", flush=True)
|
||||
equal = b.differential()==da
|
||||
if not equal:
|
||||
raise ValueError("the differential is not equal")
|
||||
return -1
|
||||
cb = A.cochain_to_vector(b.integral(), dim)
|
||||
cda = A.cochain_to_vector(da.integral(), dim + 1)
|
||||
equal = Diff*cb == cda
|
||||
if not equal:
|
||||
raise ValueError("the cochains are not equal at degree " + str(dim))
|
||||
return 0
|
||||
|
||||
#S = simplicial_complexes.Sphere(3)
|
||||
S = simplicial_complexes.K3Surface()
|
||||
S.set_immutable()
|
||||
A = AlgebraAplK(S)
|
||||
cochainComplex = S.chain_complex(base_ring=QQ).dual()
|
||||
N = 96
|
||||
for dim in range(1,4):
|
||||
Diff = cochainComplex.differential(dim)
|
||||
random_cochains = [random_vector(QQ, len(S.n_cells(dim))) for i in range(N)]
|
||||
data = zip_with_constants(A, dim, Diff, random_cochains)
|
||||
print("Start parallel tests at dimension " + str(dim), flush=True)
|
||||
results = [i[1] for i in check_solve_primitive(data)]
|
||||
|
||||
print("Test finished", flush=True)
|
||||
######### RUN MINIMAL MODEL ALGORITHM
|
||||
"""
|
||||
[sullivan_model, model_morphism, cohomology_correspondence] = minimal_model(S, max_depth=12000, max_dim=3)
|
||||
@ -109,6 +210,7 @@ for f in range(n+1):
|
||||
"""
|
||||
######### TEST DIFFERENTIAL/INTEGRAL COMMUTATION APL(K)
|
||||
|
||||
"""
|
||||
def zip_with_constants(a,s,c, l):
|
||||
return [(a,s,c, i) for i in l]
|
||||
|
||||
@ -139,20 +241,20 @@ def check_dif_int(A, S, cochainComplex, v):
|
||||
return -1
|
||||
return 0
|
||||
|
||||
S = simplicial_complexes.Sphere(7)
|
||||
S = simplicial_complexes.Sphere(5)
|
||||
#S = simplicial_complexes.K3Surface()
|
||||
S.set_immutable()
|
||||
A = AlgebraAplK(S)
|
||||
cochainComplex = S.chain_complex(base_ring=QQ).dual()
|
||||
N = 1
|
||||
for dim in range(5):
|
||||
for dim in range(7):
|
||||
l = [random_vector(QQ, len(S.n_cells(dim))) for i in range(N)]
|
||||
data = zip_with_constants(A, S, cochainComplex, l)
|
||||
print("Start parallel test at dimension " + str(dim), flush=True)
|
||||
results = [i[1] for i in check_dif_int(data)]
|
||||
|
||||
print("Test finished", flush=True)
|
||||
|
||||
"""
|
||||
######### TEST DIFFERENTIAL/INTEGRAL COMMUTATION WITH RANDOM COCHAINS
|
||||
"""
|
||||
def zip_with_constants(a, b, c, l):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user