Skip to content

Commit

Permalink
made estimation more justified
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikhil Pimpalkhare authored and Nikhil Pimpalkhare committed Oct 13, 2020
1 parent 55ad970 commit dcc664a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bin/medley
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def main():
if args.timeout_manager == "expo":
if not args.set_lambda:
args.set_lambda = 1 / (args.timeout / len(SOLVERS))
timeout_manager = Exponential(args.set_lambda, args.confidence)
timeout_manager = Exponential(args.set_lambda, args.confidence, args.timeout)
elif args.timeout_manager == "const":
if not args.set_const:
args.set_const = args.timeout // len(SOLVERS)
Expand Down
2 changes: 1 addition & 1 deletion medleysolver/classifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def get_ordering(self, point, count):
methods = [x.solve_method for x in candidates]
ss = list(SOLVERS.keys())
random.shuffle(ss)
order = sorted(ss, key= lambda x: methods.count(x))
order = sorted(ss, key= lambda x: -1 * methods.count(x))
else:
order = Random.get_ordering(self, point, count)

Expand Down
5 changes: 3 additions & 2 deletions medleysolver/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import numpy as np

class ExponentialDist:
def __init__(self, lamb, conf):
def __init__(self, lamb, conf, T):
self.lamb = lamb
self.count = 0
self.total = 0
self.confidence = conf
self.T = T

def add_sample(self, sample):
self.total += sample
Expand All @@ -17,7 +18,7 @@ def add_timeout(self):
self.add_sample(1/self.lamb + self.get_cutoff())

def get_cutoff(self):
return log(1 - self.confidence) / (-1 * self.lamb)
return log(1 - self.confidence + np.exp(-1 * self.lamb * self.T)) / (-1 * self.lamb)

class ThompsonDist(object):
def __init__(self, n, init_a=1, init_b=1):
Expand Down
4 changes: 2 additions & 2 deletions medleysolver/timers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def update(self, solver, time, success):
pass

class Exponential(TimerInterface):
def __init__(self, init_lambda, confidence):
self.timers = {solver:ExponentialDist(init_lambda, confidence) for solver in SOLVERS}
def __init__(self, init_lambda, confidence, T):
self.timers = {solver:ExponentialDist(init_lambda, confidence, T) for solver in SOLVERS}

def get_timeout(self, solver):
return self.timers[solver].get_cutoff()
Expand Down

0 comments on commit dcc664a

Please sign in to comment.