From de1d670d04c716b69c0e106ca0d7fd256f3a74e0 Mon Sep 17 00:00:00 2001 From: FedericoAureliano Date: Mon, 12 Oct 2020 22:36:04 -0700 Subject: [PATCH] fix and reverting to old timeout punishment --- bin/medley | 1 - medleysolver/classifiers.py | 13 ++++++++----- medleysolver/timers.py | 7 +------ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/bin/medley b/bin/medley index c2f1ea8..1306dbe 100755 --- a/bin/medley +++ b/bin/medley @@ -30,7 +30,6 @@ def main(): ) global_parser.add_argument( "--kind", - "-k", help="configurations for neighbor and thompson", type=str, default="full", diff --git a/medleysolver/classifiers.py b/medleysolver/classifiers.py index 2e36b6a..2e76e23 100644 --- a/medleysolver/classifiers.py +++ b/medleysolver/classifiers.py @@ -33,7 +33,6 @@ def __init__(self, epsilon, decay, kind): self.decay = decay self.counter = 0 self.kind = kind - self.k = k def get_ordering(self, point, count): if self.kind == "greedy": @@ -169,8 +168,9 @@ def get_ordering(self, point, count): for i in range(len(SOLVERS))] ps = [thetas[i].T @ point + beta.T @ point + self.alpha * np.sqrt(sigmas[i]) for i in range(len(SOLVERS))] - - i_order = sorted(random.shuffle(list(range(len(ps)))), key=lambda x: -1 * ps[x]) + ss = list(range(len(ps))) + random.shuffle(ss) + i_order = sorted(ss, key=lambda x: -1 * ps[x]) order = [list(SOLVERS.keys())[int(choice)] for choice in i_order] return list(unique_everseen(order)) @@ -209,11 +209,14 @@ def get_ordering(self, point, count): if np.random.rand() >= self.epsilon * (self.decay ** count) and self.solved: candidates = sorted(self.solved, key=lambda entry: np.linalg.norm(entry.datapoint - point))[:self.k] methods = [x.solve_method for x in candidates] - order = sorted(random.shuffle(list(SOLVERS.keys())), key= lambda x: methods.count(x)) + ss = list(SOLVERS.keys()) + random.shuffle(ss) + order = sorted(ss, key= lambda x: methods.count(x)) else: order = Random.get_ordering(self, point, count) - return order + return list(unique_everseen(order)) + def update(self, solved_prob, rewards): #TODO: Implement pruning if is_solved(solved_prob.result): diff --git a/medleysolver/timers.py b/medleysolver/timers.py index cbe84b4..c999007 100644 --- a/medleysolver/timers.py +++ b/medleysolver/timers.py @@ -33,10 +33,5 @@ def update(self, solver, time, timeout, success, error): if error: self.timers[solver].add_error() else: - if time < timeout/3: - # give more time - self.timers[solver].add_timeout() - else: - # remove time (assuming 1 is small compared to timeout) - self.timers[solver].add_sample(1) + self.timers[solver].add_timeout()