diff --git a/copycat/temperature.py b/copycat/temperature.py index eb49cea..b294491 100644 --- a/copycat/temperature.py +++ b/copycat/temperature.py @@ -212,6 +212,44 @@ class Temperature(object): Need to play with this more... and WTF is f anyways? + + LSaldyt: + + Recall self.value(): + def value(self): + return 100.0 if self.clamped else self.actual_value + + f in terms of value() and value only + f = ((10 - sqrt(100 - self.value()))/100 + 1) * value + + For the original LISP program: + + ; This function is a filter: it inputs a value (from 0 to 100) and returns + ; a probability (from 0 - 1) based on that value and the temperature. When + ; the temperature is 0, the result is (/ value 100), but at higher + ; temperatures, values below 50 get raised and values above 50 get lowered + ; as a function of temperature. + ; I think this whole formula could probably be simplified. + + (setq result + (cond ((= prob 0) 0) + ((<= prob .5) + (setq low-prob-factor (max 1 (truncate (abs (log prob 10))))) + (min (+ prob + (* (/ (- 10 (sqrt (fake-reciprocal *temperature*))) + 100) + (- (expt 10 (- (1- low-prob-factor))) prob))) + .5)) + + ((= prob .5) .5) + ((> prob .5) + (max (- 1 + (+ (- 1 prob) + (* (/ (- 10 (sqrt (fake-reciprocal *temperature*))) + 100) + (- 1 (- 1 prob))))) + .5)))) + result) """ if value == 0 or value == 0.5 or self.value() == 0: return value @@ -221,22 +259,7 @@ class Temperature(object): a = math.sqrt(coldness) c = (10 - a) / 100 f = (c + 1) * value - return (0 + (-f * math.log2(f))) # max(f, 0.0000) - - def getAdjustedProbability(self, value): - # Recall self.value(): - # def value(self): - # return 100.0 if self.clamped else self.actual_value - # - # f in terms of value() and value only - # f = ((10 - sqrt(100 - self.value()))/100 + 1) * value - - if value == 0 or value == 0.5 or self.value() == 0: - return value - if value < 0.5: - return 1.0 - self.getAdjustedProbability(1.0 - value) - coldness = 100.0 - self.value() - a = math.sqrt(coldness) - c = (10 - a) / 100 - f = (c + 1) * value - return max(f, 0.5) + # return max(f, 0.5) + # return max(f, 0.0) + # return (0 + (-f * math.log2(f))) + return -f * math.log2(f) diff --git a/temp_usages.txt b/temp_usages.txt deleted file mode 100644 index efc6806..0000000 --- a/temp_usages.txt +++ /dev/null @@ -1,168 +0,0 @@ -copycat/codeletMethods.py: temperature = ctx.temperature -copycat/codeletMethods.py: weightedStrength1 = temperature.getAdjustedValue( -copycat/codeletMethods.py: weightedStrength2 = temperature.getAdjustedValue( -copycat/codeletMethods.py: temperature = ctx.temperature -copycat/codeletMethods.py: probabilityOfSlippage = temperature.getAdjustedProbability(slippiness) -copycat/codeletMethods.py: temperature = ctx.temperature -copycat/codeletMethods.py: probabilityOfFizzle = (100.0 - temperature.value()) / 100.0 -copycat/codeletMethods.py: breakProbability = temperature.getAdjustedProbability( -copycat/codeletMethods.py: temperature = ctx.temperature -copycat/codeletMethods.py: probability = temperature.getAdjustedProbability(association) -copycat/codeletMethods.py: temperature = ctx.temperature -copycat/codeletMethods.py: probability = temperature.getAdjustedProbability(strength / 100.0) -copycat/codeletMethods.py: temperature = ctx.temperature -copycat/codeletMethods.py: temperature.getAdjustedValue(node.conceptualDepth) -copycat/codeletMethods.py: temperature.getAdjustedValue(node.conceptualDepth) -copycat/codeletMethods.py: temperature = ctx.temperature -copycat/codeletMethods.py: probability = temperature.getAdjustedProbability(rule.totalStrength / 100.0) -copycat/codeletMethods.py: temperature = ctx.temperature -copycat/codeletMethods.py: probability = temperature.getAdjustedProbability(strength / 100.0) -copycat/codeletMethods.py: temperature = ctx.temperature -copycat/codeletMethods.py: probability = temperature.getAdjustedProbability(strength / 100.0) -copycat/codeletMethods.py: temperature = ctx.temperature -copycat/codeletMethods.py: if cutoff >= temperature.actual_value: -copycat/codeletMethods.py: temperature.clampUntil(coderack.codeletsRun + 100) -copycat/codeletMethods.py: temperature = ctx.temperature -copycat/codeletMethods.py: weights = [temperature.getAdjustedValue(n.conceptualDepth) for n in descriptors] -copycat/codeletMethods.py: temperature = ctx.temperature -copycat/codeletMethods.py: probability = temperature.getAdjustedProbability(strength / 100.0) -copycat/coderack.py: temperature = self.ctx.temperature -copycat/coderack.py: return (temperature.value() / 100.0) ** 2 -copycat/coderack.py: temperature = self.ctx.temperature -copycat/coderack.py: if temperature.value() < 25.0 and 'translator' in codeletName: -copycat/coderack.py: temperature = self.ctx.temperature -copycat/coderack.py: scale = (100.0 - temperature.value() + 10.0) / 15.0 -copycat/copycat.py:from .temperature import Temperature -copycat/copycat.py: def report_temperature(self, temperature): -copycat/copycat.py: self.temperature = Temperature() -copycat/copycat.py: self.temperature.tryUnclamp(currentTime) -copycat/copycat.py: self.temperature.update(self.workspace.getUpdatedTemperature()) -copycat/copycat.py: self.reporter.report_temperature(self.temperature) -copycat/copycat.py: self.temperature.reset() -copycat/copycat.py: 'temp': self.temperature.last_unclamped_value, -copycat/copycat.py: 'sumtemp': 0, -copycat/copycat.py: d['sumtemp'] += answer['temp'] -copycat/copycat.py: d['avgtemp'] = d.pop('sumtemp') / d['count'] -copycat/curses_reporter.py: self.temperatureWindow = SafeSubwindow(window, height, 5, 0, 0) -copycat/curses_reporter.py: for w in [self.temperatureWindow, self.upperWindow, self.answersWindow, self.fpsWindow]: -copycat/curses_reporter.py: w = self.temperatureWindow # just a random window -copycat/curses_reporter.py: 'sumtemp': 0, -copycat/curses_reporter.py: d['sumtemp'] += answer['temp'] -copycat/curses_reporter.py: d['avgtemp'] = d['sumtemp'] / d['count'] -copycat/curses_reporter.py: return 3 * d['count'] - d['avgtemp'] -copycat/curses_reporter.py: return '%s: %d (avg time %.1f, avg temp %.1f)' % ( -copycat/curses_reporter.py: d['answer'], d['count'], d['avgtime'], d['avgtemp'], -copycat/curses_reporter.py: def report_temperature(self, temperature): -copycat/curses_reporter.py: w = self.temperatureWindow -copycat/curses_reporter.py: mercury = max_mercury * temperature.value() / 100.0 -copycat/curses_reporter.py: w.addnstr(height - 2, 1, '%3d' % temperature.actual_value, 3) -copycat/group.py: temperature = self.ctx.temperature -copycat/group.py: return temperature.getAdjustedProbability(supportedActivation) -copycat/group.py: temperature = self.ctx.temperature -copycat/group.py: value = temperature.getAdjustedProbability(probability) -copycat/temperature.py: iiijjjlll: 670 (avg time 1108.5, avg temp 23.6) -copycat/temperature.py: iiijjjd: 2 (avg time 1156.0, avg temp 35.0) -copycat/temperature.py: iiijjjkkl: 315 (avg time 1194.4, avg temp 35.5) -copycat/temperature.py: iiijjjkll: 8 (avg time 2096.8, avg temp 44.1) -copycat/temperature.py: iiijjjkkd: 5 (avg time 837.2, avg temp 48.0) -copycat/temperature.py: wyz: 5 (avg time 2275.2, avg temp 14.9) -copycat/temperature.py: xyd: 982 (avg time 2794.4, avg temp 17.5) -copycat/temperature.py: yyz: 7 (avg time 2731.9, avg temp 25.1) -copycat/temperature.py: dyz: 2 (avg time 3320.0, avg temp 27.1) -copycat/temperature.py: xyy: 2 (avg time 4084.5, avg temp 31.1) -copycat/temperature.py: xyz: 2 (avg time 1873.5, avg temp 52.1) -copycat/temperature.py: wyz: 7 (avg time 3192.9, avg temp 13.1) -copycat/temperature.py: xyd: 985 (avg time 2849.1, avg temp 17.5) -copycat/temperature.py: yyz: 6 (avg time 3836.7, avg temp 18.6) -copycat/temperature.py: xyy: 1 (avg time 1421.0, avg temp 19.5) -copycat/temperature.py: xyz: 1 (avg time 7350.0, avg temp 48.3) -copycat/temperature.py: wyz: 8 (avg time 4140.5, avg temp 13.3) -copycat/temperature.py: yyz: 6 (avg time 2905.2, avg temp 14.5) -copycat/temperature.py: xyd: 982 (avg time 3025.4, avg temp 17.6) -copycat/temperature.py: dyz: 4 (avg time 4265.0, avg temp 17.7) -copycat/temperature.py: dyz: 1 (avg time 5198.0, avg temp 15.3) -copycat/temperature.py: wyz: 3 (avg time 4043.7, avg temp 17.1) -copycat/temperature.py: yyz: 9 (avg time 3373.6, avg temp 21.0) -copycat/temperature.py: xyd: 84 (avg time 5011.1, avg temp 23.3) -copycat/temperature.py: xyy: 3 (avg time 4752.0, avg temp 27.9) -copycat/temperature.py: xyd: 1000 (avg time 1625.2, avg temp 17.3) -copycat/temperature.py: xyz: 3 (avg time 3996.7, avg temp 81.1) -copycat/temperature.py: dyz: 46 (avg time 5931.7, avg temp 82.6) -copycat/temperature.py: xd: 17 (avg time 6090.3, avg temp 83.8) -copycat/temperature.py: xyd: 934 (avg time 7699.8, avg temp 88.1) -copycat/temperature.py: wyz: 123 (avg time 5933.1, avg temp 16.5) -copycat/temperature.py: xyy: 200 (avg time 6486.7, avg temp 27.8) -copycat/temperature.py: yyz: 330 (avg time 6310.2, avg temp 38.5) -copycat/temperature.py: dyz: 75 (avg time 6393.3, avg temp 39.6) -copycat/temperature.py: yzz: 5 (avg time 4965.0, avg temp 59.3) -copycat/temperature.py: xyz: 160 (avg time 6886.2, avg temp 60.2) -copycat/temperature.py: xd: 4 (avg time 2841.0, avg temp 61.8) -copycat/temperature.py: dz: 3 (avg time 3721.0, avg temp 62.1) -copycat/temperature.py: xyd: 100 (avg time 5853.1, avg temp 67.5) -copycat/temperature.py: wyz: 78 (avg time 7793.7, avg temp 16.6) -copycat/temperature.py: xyy: 202 (avg time 9168.5, avg temp 27.5) -copycat/temperature.py: wxz: 1 (avg time 3154.0, avg temp 33.4) -copycat/temperature.py: dyz: 63 (avg time 7950.3, avg temp 41.7) -copycat/temperature.py: yyz: 217 (avg time 8147.4, avg temp 41.7) -copycat/temperature.py: xyz: 201 (avg time 7579.7, avg temp 62.5) -copycat/temperature.py: xxy: 1 (avg time 7994.0, avg temp 64.8) -copycat/temperature.py: yzz: 8 (avg time 4672.6, avg temp 65.7) -copycat/temperature.py: xd: 9 (avg time 9215.2, avg temp 68.1) -copycat/temperature.py: xyd: 217 (avg time 7677.9, avg temp 73.8) -copycat/temperature.py: dz: 3 (avg time 20379.0, avg temp 77.3) -copycat/temperature.py: xyd: 100 (avg time 2984.3, avg temp 18.2) -copycat/temperature.py: jijjkk: 66 (avg time 3200.1, avg temp 61.3) -copycat/temperature.py: iijjkk: 114 (avg time 5017.2, avg temp 63.5) -copycat/temperature.py: dijjkk: 23 (avg time 2209.0, avg temp 67.3) -copycat/temperature.py: iijjkl: 748 (avg time 3262.8, avg temp 70.0) -copycat/temperature.py: iijjkd: 49 (avg time 2315.9, avg temp 76.3) -copycat/temperature.py: iijjll: 59 (avg time 797.4, avg temp 19.8) -copycat/temperature.py: iijjkl: 41 (avg time 696.1, avg temp 28.5) -copycat/temperature.py: mrrlll: 77 (avg time 2195.7, avg temp 41.4) -copycat/temperature.py: mrrd: 2 (avg time 1698.0, avg temp 42.6) -copycat/temperature.py: mrrkkl: 20 (avg time 1317.8, avg temp 46.6) -copycat/temperature.py: mrrkkd: 1 (avg time 1835.0, avg temp 48.6) -copycat/temperature.py: nrrkkk: 11 (avg time 3637.8, avg temp 64.6) -copycat/temperature.py: drrkkk: 3 (avg time 5921.3, avg temp 66.2) -copycat/temperature.py: mrrkkd: 7 (avg time 6771.3, avg temp 74.6) -copycat/temperature.py: mrrkkl: 79 (avg time 3723.0, avg temp 74.9) -copycat/tests.py:def lower_bound_on_probability(hits, attempts, confidence=0.95): -copycat/tests.py: if attempts == 0: -copycat/tests.py: phat = 1.0 * hits / attempts -copycat/tests.py: under_sqrt = (phat * (1 - phat) + zsqr / (4 * attempts)) / attempts -copycat/tests.py: denominator = (1 + zsqr / attempts) -copycat/tests.py: return (phat + zsqr / (2 * attempts) - z * (under_sqrt ** 0.5)) / denominator -copycat/tests.py:def upper_bound_on_probability(hits, attempts, confidence=0.95): -copycat/tests.py: misses = attempts - hits -copycat/tests.py: return 1.0 - lower_bound_on_probability(misses, attempts, confidence) -copycat/tests.py: if abs(actual[k]['avgtemp'] - expected[k]['avgtemp']) >= 10.0 + (10.0 / actual[k]['count']): -copycat/tests.py: print('Failed (%s - %s >= %s)' % (actual[k]['avgtemp'], expected[k]['avgtemp'], 10.0 + (10.0 / actual[k]['count']))) -copycat/tests.py: 'efd': {'count': 1, 'avgtemp': 16}, -copycat/tests.py: 'efh': {'count': 99, 'avgtemp': 19}, -copycat/tests.py: 'ijd': {'count': 4, 'avgtemp': 24}, -copycat/tests.py: 'ijl': {'count': 96, 'avgtemp': 20}, -copycat/tests.py: 'xyd': {'count': 100, 'avgtemp': 19}, -copycat/tests.py: 'ijkkk': {'count': 7, 'avgtemp': 21}, -copycat/tests.py: 'ijll': {'count': 47, 'avgtemp': 28}, -copycat/tests.py: 'ijkl': {'count': 44, 'avgtemp': 32}, -copycat/tests.py: 'ijkd': {'count': 2, 'avgtemp': 65}, -copycat/tests.py: 'mrrjjjj': {'count': 4, 'avgtemp': 16}, -copycat/tests.py: 'mrrkkk': {'count': 31, 'avgtemp': 47}, -copycat/tests.py: 'mrrjjk': {'count': 64, 'avgtemp': 51}, -copycat/tests.py: 'mrrjkk': {'count': 1, 'avgtemp': 52}, -copycat/tests.py: 'mrrjjd': {'count': 1, 'avgtemp': 54}, -copycat/tests.py: 'milj': {'count': 85, 'avgtemp': 55}, -copycat/tests.py: 'mikj': {'count': 10, 'avgtemp': 56}, -copycat/tests.py: 'milk': {'count': 1, 'avgtemp': 56}, -copycat/tests.py: 'lilk': {'count': 1, 'avgtemp': 57}, -copycat/tests.py: 'milb': {'count': 3, 'avgtemp': 57}, -copycat/tests.py: 'xc': {'count': 9, 'avgtemp': 57}, -copycat/tests.py: 'xyc': {'count': 82, 'avgtemp': 59}, -copycat/tests.py: 'cyx': {'count': 7, 'avgtemp': 68}, -copycat/tests.py: 'xyx': {'count': 2, 'avgtemp': 69}, -copycat/tests.py: 'cakg': {'count': 99, 'avgtemp': 70}, -copycat/tests.py: 'gake': {'count': 1, 'avgtemp': 59}, -copycat/tests.py: 'kitteg': {'count': 96, 'avgtemp': 66}, -copycat/tests.py: 'kitten': {'count': 4, 'avgtemp': 68}, -copycat/workspaceFormulas.py: temperature = ctx.temperature -copycat/workspaceFormulas.py: temperature.getAdjustedValue( diff --git a/todos.txt b/todos.txt deleted file mode 100644 index 5775650..0000000 --- a/todos.txt +++ /dev/null @@ -1,53 +0,0 @@ -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO:use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/codeletMethods.py: # TODO: use entropy -copycat/coderack.py: # TODO: use entropy -copycat/coderack.py: # TODO: use entropy -copycat/coderack.py: # TODO: use entropy -copycat/coderack.py: # TODO: use entropy -copycat/coderack.py: # TODO: use entropy -copycat/coderack.py: # TODO: use entropy -copycat/copycat.py: def report_temperature(self, temperature): #TODO: use entropy -copycat/copycat.py: self.temperature = Temperature() # TODO: use entropy -copycat/copycat.py: self.temperature.tryUnclamp(currentTime) # TODO: use entropy -copycat/copycat.py: self.temperature.update(self.workspace.getUpdatedTemperature()) # TODO: use entropy -copycat/copycat.py: self.temperature.reset() # TODO: use entropy -copycat/copycat.py: 'temp': self.temperature.last_unclamped_value, # TODO: use entropy -copycat/copycat.py: 'sumtemp': 0, # TODO: use entropy -copycat/copycat.py: d['sumtemp'] += answer['temp'] # TODO: use entropy -copycat/curses_reporter.py: self.temperatureWindow = SafeSubwindow(window, height, 5, 0, 0) # TODO: use entropy (entropyWindow) -copycat/curses_reporter.py: #TODO: use entropy -copycat/group.py: #TODO: use entropy -copycat/group.py: #TODO: use entropy -copycat/temperature.py: # TODO: use entropy -copycat/tests.py:# TODO: update test cases to use entropy -copycat/workspaceFormulas.py: # TODO: use entropy -copycat/workspaceObject.py: from .group import Group # gross, TODO FIXME -copycat/workspace.py: # TODO: Initial part of refactoring in this method -copycat/workspace.py: # TODO: Extract method? -copycat/workspace.py: # TODO: these 3 methods seem to be the same... are they? If so, Extract method. -copycat/workspace.py: # TODO: use entropy