From 765323c3cd539ab1ec7aacdcbd4d7279445273af Mon Sep 17 00:00:00 2001 From: lsaldyt Date: Mon, 16 Oct 2017 13:21:19 -0700 Subject: [PATCH] Updates adjustment formula to a satisfactory formula Out of all of the formulas I've tried, I believe this formula to be a more elegant alternative to Mitchell's formula. However, like Mitchell's original formula, it still provides weird answers in some cases, but I believe these to source from elsewhere, not from the adjustment formula. For more information, please see: https://docs.google.com/spreadsheets/d/1JT2yCBUAsFzMcbKsQUcH1DhcBbuWDKTgPvUwD9EqyTY/edit?usp=sharing wq --- copycat/copycat.py | 3 ++- copycat/temperature.py | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/copycat/copycat.py b/copycat/copycat.py index 1f16cd9..e66a738 100644 --- a/copycat/copycat.py +++ b/copycat/copycat.py @@ -68,7 +68,7 @@ class Copycat(object): def run(self, initial, modified, target, iterations): self.workspace.resetWithStrings(initial, modified, target) - self.temperature.useAdj('original') + #self.temperature.useAdj('original') #self.temperature.useAdj('entropy') #self.temperature.useAdj('inverse') # 100 weight #self.temperature.useAdj('fifty_converge') @@ -76,6 +76,7 @@ class Copycat(object): #self.temperature.useAdj('weighted_soft') #self.temperature.useAdj('alt_fifty') #self.temperature.useAdj('average_alt') + self.temperature.useAdj('best') answers = {} for i in range(iterations): diff --git a/copycat/temperature.py b/copycat/temperature.py index 20aca17..e62f0a8 100644 --- a/copycat/temperature.py +++ b/copycat/temperature.py @@ -56,6 +56,12 @@ def _averaged_alt(temp, prob): u = prob ** 2 if prob < .5 else math.sqrt(prob) return _weighted(temp, prob, s, u) +def _working_best(temp, prob): + s = .5 # convergence + r = 1.05 # power + u = prob ** r if prob < .5 else prob ** (1/r) + return _weighted(temp, prob, s, u) + class Temperature(object): def __init__(self): self.reset() @@ -68,7 +74,8 @@ class Temperature(object): 'soft' : _soft_curve, 'weighted_soft' : _weighted_soft_curve, 'alt_fifty' : _alt_fifty, - 'average_alt' : _averaged_alt} + 'average_alt' : _averaged_alt, + 'best' : _working_best} def reset(self): self.actual_value = 100.0