From 34390ba769214994a08f23745e639eae1ca2bb8e Mon Sep 17 00:00:00 2001 From: Peter Piech Date: Sun, 22 May 2016 23:38:40 -0400 Subject: [PATCH] Eliminate redundant calculations after incrementing --- prefpy/evbwie1.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/prefpy/evbwie1.py b/prefpy/evbwie1.py index 9227cf9..d19f51d 100644 --- a/prefpy/evbwie1.py +++ b/prefpy/evbwie1.py @@ -93,6 +93,7 @@ def aggregate(self, rankings, K, epsilon, tot_iters, epsilon_mm, max_iters_em): pi_h = np.copy(pi_h0) inner = tot_iters // max_iters_em + isIncremented = False for g in range(max_iters_em): #for g in range(max_iters): @@ -110,9 +111,11 @@ def aggregate(self, rankings, K, epsilon, tot_iters, epsilon_mm, max_iters_em): z_h1[i][k] = (pi_h[k] * EMMMixPLAggregator.f(x[i], p_h[k])) / denom_sum # M-Step: - test = (g + 1) * inner + (max_iters_em - g - 1) * (inner + 1) - if test < tot_iters: - inner += 1 + if not isIncremented: + test = (g + 1) * inner + (max_iters_em - g - 1) * (inner + 1) + if test < tot_iters: + inner += 1 + isIncremented = True for l in range(inner): #for l in range(max_iters_mm): #for l in range(int(g/50) + 5):