From e6f57d8235da92235aed097050a9fe1511bff11e Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 5 Feb 2024 15:23:03 +0000 Subject: [PATCH] push WIP --- estimator/lwe_primal.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/estimator/lwe_primal.py b/estimator/lwe_primal.py index 22deeeb..5533837 100644 --- a/estimator/lwe_primal.py +++ b/estimator/lwe_primal.py @@ -300,10 +300,21 @@ def gaussian_heuristic_log_input(r): d = len(r) r = [log(x) for x in r] - for i, _ in enumerate(r): - if gaussian_heuristic_log_input(r[i:]) < D.stddev**2 * (d - i): - return ZZ(d - (i - 1)) - return ZZ(2) + + + if len(r) > 8192: + for i in range(len(r) - 1000, len(r)): + print("i = {}".format(i)) + if gaussian_heuristic_log_input(r[i:]) < D.stddev**2 * (d - i): + return ZZ(d - (i - 1)) + return ZZ(2) + + else: + for i, _ in enumerate(r): + print("i = {}".format(i)) + if gaussian_heuristic_log_input(r[i:]) < D.stddev**2 * (d - i): + return ZZ(d - (i - 1)) + return ZZ(2) @staticmethod @cached_function @@ -480,8 +491,11 @@ def cost_zeta( 40, baseline_cost["beta"] + 1, precision=2, log_level=log_level + 1 ) as it: for beta in it: + #print("beta = {}".format(beta)) it.update(f(beta)) + #print(f(beta)) for beta in it.neighborhood: + #print("beta = {}".format(beta)) it.update(f(beta)) cost = it.y @@ -490,9 +504,10 @@ def cost_zeta( # step 2. optimize d if cost and cost.get("tag", "XXX") != "usvp" and optimize_d: with local_minimum( - params.n, cost["d"] + cost["zeta"] + 1, log_level=log_level + 1 + params.n, cost["d"] + cost["zeta"] + 1, log_level= log_level - 1 ) as it: for d in it: + #print("d = {}".format(d)) it.update(f(beta=cost["beta"], d=d)) cost = it.y Logging.log("bdd", log_level, f"H2: {cost!r}")