Minor annotations to temperature calculations

This commit is contained in:
LSaldyt
2017-09-29 13:12:16 -06:00
parent cd3ad65ff8
commit 42a875a492
2 changed files with 24 additions and 1 deletions

View File

@ -222,3 +222,21 @@ class Temperature(object):
c = (10 - a) / 100 c = (10 - a) / 100
f = (c + 1) * value f = (c + 1) * value
return (0 + (-f * math.log2(f))) # max(f, 0.0000) 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)

View File

@ -39,7 +39,7 @@ class Workspace(object):
self.changedObject = None self.changedObject = None
self.objects = [] self.objects = []
self.structures = [] self.structures = []
self.rule = None self.rule = None # Only one rule? : LSaldyt
self.initial = WorkspaceString(self.ctx, self.initialString) self.initial = WorkspaceString(self.ctx, self.initialString)
self.modified = WorkspaceString(self.ctx, self.modifiedString) self.modified = WorkspaceString(self.ctx, self.modifiedString)
self.target = WorkspaceString(self.ctx, self.targetString) self.target = WorkspaceString(self.ctx, self.targetString)
@ -99,6 +99,11 @@ class Workspace(object):
# TODO: use entropy # TODO: use entropy
def getUpdatedTemperature(self): def getUpdatedTemperature(self):
'''
Calculation of global tolerance towards irrelevance
temp = weightedAverage(totalUnhappiness(.8), ruleWeakness(.2))
'''
self.calculateIntraStringUnhappiness() self.calculateIntraStringUnhappiness()
self.calculateInterStringUnhappiness() self.calculateInterStringUnhappiness()
self.calculateTotalUnhappiness() self.calculateTotalUnhappiness()