Adds adjustment formulas and embeds them in paper

This commit is contained in:
LSaldyt
2017-11-13 10:49:15 -07:00
parent 7a39d6b00d
commit a3d693d457
5 changed files with 77 additions and 1 deletions

21
papers/formulas/best.py Normal file
View File

@ -0,0 +1,21 @@
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)
def _soft_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)
def _parameterized_best(temp, prob):
alpha = 5
beta = 1
s = .5
s = (alpha * prob + beta * s) / (alpha + beta)
r = 1.05
u = prob ** r if prob < .5 else prob ** (1/r)
return _weighted(temp, prob, s, u)

View File

@ -0,0 +1,12 @@
import math
def _entropy(temp, prob):
if prob == 0 or prob == 0.5 or temp == 0:
return prob
if prob < 0.5:
return 1.0 - _original(temp, 1.0 - prob)
coldness = 100.0 - temp
a = math.sqrt(coldness)
c = (10 - a) / 100
f = (c + 1) * prob
return -f * math.log2(f)

View File

@ -0,0 +1,12 @@
import math
def _original(temp, prob):
if prob == 0 or prob == 0.5 or temp == 0:
return prob
if prob < 0.5:
return 1.0 - _original(temp, 1.0 - prob)
coldness = 100.0 - temp
a = math.sqrt(coldness)
c = (10 - a) / 100
f = (c + 1) * prob
return max(f, 0.5)

View File

@ -0,0 +1,28 @@
def _weighted(temp, prob, s, u, alpha=1, beta=1):
weighted = (temp / 100) * s + ((100 - temp) / 100) * u
return weighted
def _weighted_inverse(temp, prob):
iprob = 1 - prob
return _weighted(temp, prob, iprob, prob)
# Uses .5 instead of 1-prob
def _fifty_converge(temp, prob):
return _weighted(temp, prob, .5, prob)
# Curves to the average of the (1-p) and .5
def _soft_curve(temp, prob):
return min(1, _weighted(temp, prob, (1.5-prob)/2, prob))
# Curves to the weighted average of the (1-p) and .5
def _weighted_soft_curve(temp, prob):
weight = 100
gamma = .5 # convergance value
alpha = 1 # gamma weight
beta = 3 # iprob weight
curved = min(1,
(temp / weight) *
((alpha * gamma + beta * (1 - prob)) /
(alpha + beta)) +
((weight - temp) / weight) * prob)
return curved

View File

@ -150,7 +150,10 @@ The original formulas being used to do this were overly complicated.
In summary, many formulas were tested in a spreadsheet, and an optimal one was chosen that replicated the desired behavior.
[]
\lstinputlisting[language=Python]{test.py}
\lstinputlisting[language=Python]{formulas/original.py}
\lstinputlisting[language=Python]{formulas/entropy.py}
\lstinputlisting[language=Python]{formulas/weighted.py}
\lstinputlisting[language=Python]{formulas/best.py}
\subsection{Steps/plan}