From ecb1b7b66409149c9ff5bb0bcd8765f625f439f0 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 5 Feb 2024 20:05:46 +0000 Subject: [PATCH] try this instead --- estimator/lwe_primal.py | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/estimator/lwe_primal.py b/estimator/lwe_primal.py index 5533837..51744be 100644 --- a/estimator/lwe_primal.py +++ b/estimator/lwe_primal.py @@ -300,21 +300,12 @@ def gaussian_heuristic_log_input(r): d = len(r) r = [log(x) for x in r] - - 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) + for i, _ in enumerate(r): + if gaussian_heuristic_log_input(r[d - (i + 1):]) > D.stddev**2 * (i + 1): + return ZZ(i) + 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 @@ -491,11 +482,10 @@ 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)) + print("beta = {}".format(beta)) it.update(f(beta)) - #print(f(beta)) for beta in it.neighborhood: - #print("beta = {}".format(beta)) + print("beta = {}".format(beta)) it.update(f(beta)) cost = it.y @@ -504,10 +494,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)) + print("d = {}".format(d)) it.update(f(beta=cost["beta"], d=d)) cost = it.y Logging.log("bdd", log_level, f"H2: {cost!r}")