bool for look for slice only

This commit is contained in:
Maria Marchwicka 2019-04-15 13:01:48 +02:00
parent 6928baeebd
commit 3057bca96d

View File

@ -11,6 +11,7 @@ import itertools as it
class MySettings(object): class MySettings(object):
def __init__(self): def __init__(self):
self.f_results = os.path.join(os.getcwd(), "results.out") self.f_results = os.path.join(os.getcwd(), "results.out")
self.only_slice_candidates = True
def main(arg): def main(arg):
@ -21,12 +22,29 @@ def main(arg):
def tests(limit=10): def tests(limit=10):
k_size = 5
settings = MySettings() settings = MySettings()
knot_sum_formula = "[[k[0], k[1], k[2]], [k[3], k[4]], \ knot_sum_formula = "[[k[0], k[1], k[2]], [k[3], k[4]], \
[-k[0], -k[3], -k[4]], [-k[1], -k[2]]]" [-k[0], -k[3], -k[4]], [-k[1], -k[2]]]"
# F = get_function_of_theta_for_sum([k_3], [-k_2],
# [-k_0, -k_1, -k_3],
# [k_0, k_1, k_2])
with open(settings.f_results, 'w') as f_results: with open(settings.f_results, 'w') as f_results:
for k in it.combinations_with_replacement(range(1, limit + 1), 5): combinations = it.combinations_with_replacement(range(1, limit + 1),
k_size)
for comb in combinations:
if settings.only_slice_candidates:
k = [comb[0], 4 * comb[0] + comb[1],
4 * (4 * comb[0] + comb[1]) + comb[2],
4 * comb[0] + comb[3],
4 * (4 * comb[0] + comb[3]) + comb[4]]
else:
k = comb
if k[3] == k[1] and k[2] == k[4]:
continue
knot_sum = eval(knot_sum_formula) knot_sum = eval(knot_sum_formula)
result = eval_cable_for_thetas(knot_sum) result = eval_cable_for_thetas(knot_sum)
if result is not None: if result is not None:
@ -35,10 +53,6 @@ def tests(limit=10):
str(all_comb) + "\n") str(all_comb) + "\n")
f_results.write(line) f_results.write(line)
# for comb in it.combinations_with_replacement(range(1, limit + 1), 4):
# print comb
# print first_sum(*comb)
class SignatureFunction(object): class SignatureFunction(object):
""" """
@ -169,8 +183,7 @@ def get_cable_signature_as_theta_function(*arg):
for _ in range(i): for _ in range(i):
b = b.double_cover() b = b.double_cover()
c = c.double_cover() c = c.double_cover()
b += c cable_signature += b + c
cable_signature += b
return cable_signature return cable_signature
return signture_function return signture_function
@ -219,43 +232,32 @@ def mod_one(n):
return n - floor(n) return n - floor(n)
# ###################### TEMPORARY TESTS #########
# first_sum
# F = get_function_of_theta_for_sum([k_3], [-k_2],
# [-k_0, -k_1, -k_3],
# [k_0, k_1, k_2])
def eval_cable_for_thetas(knot_sum): def eval_cable_for_thetas(knot_sum):
F = get_function_of_theta_for_sum(*knot_sum)
f = get_function_of_theta_for_sum(*knot_sum)
knot_description = get_knot_descrption(*knot_sum) knot_description = get_knot_descrption(*knot_sum)
all_combinations = get_number_of_combinations(*knot_sum) all_combinations = get_number_of_combinations(*knot_sum)
null_combinations = 1
# non_trivial_zeros = 0 null_combinations = 0
theta_limits = [] zero_theta_combinations = []
ranges_list = []
for knot in knot_sum: ranges_list = [range(abs(knot[-1]) + 1) for knot in knot_sum]
ranges_list.append(range(abs(knot[-1]) + 1))
null_combinations = 1
good_theta_combinations = []
for v_theta in it.product(*ranges_list): for v_theta in it.product(*ranges_list):
f = F(*v_theta)
assert f.sum_of_absolute_values() == 0 or sum(v_theta) != 0 if f(*v_theta).sum_of_absolute_values() == 0:
if f.sum_of_absolute_values() == 0 and sum(v_theta) != 0: zero_theta_combinations.append(v_theta)
good_theta_combinations.append(v_theta)
m = len([theta for theta in v_theta if theta != 0]) m = len([theta for theta in v_theta if theta != 0])
null_combinations += 2^m null_combinations += 2^m
# if len(arg) == len(set(arg)) and len(set(v_theta)) > 1: else:
# non_trivial_zeros += 1 assert sum(v_theta) != 0
# print "\nNontrivial zero"
# print arg
# print v_theta
# print
if null_combinations^2 >= all_combinations: if null_combinations^2 >= all_combinations:
print print
print knot_description print knot_description
print "Zero cases: " + str(null_combinations) print "Zero cases: " + str(null_combinations)
print "All cases: " + str(all_combinations) print "All cases: " + str(all_combinations)
for el in good_theta_combinations: print "Zero theta combinations: "
for el in zero_theta_combinations:
print el print el
return knot_description, null_combinations, all_combinations return knot_description, null_combinations, all_combinations
return None return None
@ -269,8 +271,7 @@ def get_knot_descrption(*arg):
description += "T(" description += "T("
for k in knot: for k in knot:
description += "2, " + str(2 * abs(k) + 1) + "; " description += "2, " + str(2 * abs(k) + 1) + "; "
description = description[:-2] description = description[:-2] + ") # "
description += ") # "
return description[:-3] return description[:-3]