Major overhaul of temperature logic. Behavioral change.
I think the reason the temperature logic was so confused in the old code is because the Java code has a class `Temperature` that is used for graphical display *and* two variables in `formulas` that are used for most of the actual math. But somewhere along the line, some of the code in `formulas.java` started reading from `Temperature.value` as well. So the Python code was just faithfully copying that confusion. The actual abstraction here is a very simple "temperature" object with a stored value. It can be "clamped" to 100.0 for a given period. The only complication is that one of the codelets (the rule-transformer codelet) wants to get access to the "actual value" of the temperature even when it is clamped. The Python rule-transformer codelet also had a bug: it was accidentally setting `temperature.value` on the `temperature` module instead of on the `temperature.temperature` object! This turned some of its behavior into a no-op, for whatever that's worth. Lastly, the calculation of `finalTemperature` in the main program can now report 100.0 if the answer is found while the temperature is clamped. I don't fully understand why this didn't happen in the old code. I've hacked around it with `temperature.last_unclamped_value` for now, but I should TODO FIXME.
This commit is contained in:
@ -3,7 +3,7 @@ import logging
|
||||
import random
|
||||
|
||||
from slipnet import slipnet
|
||||
import temperature
|
||||
from temperature import temperature
|
||||
import formulas
|
||||
from workspaceFormulas import chooseDirectedNeighbor
|
||||
from workspaceFormulas import chooseNeighbor
|
||||
@ -130,7 +130,7 @@ def __slippability(conceptMappings):
|
||||
|
||||
@codelet('breaker')
|
||||
def breaker(coderack, codelet):
|
||||
probabilityOfFizzle = (100.0 - formulas.Temperature) / 100.0
|
||||
probabilityOfFizzle = (100.0 - temperature.value()) / 100.0
|
||||
if formulas.coinFlip(probabilityOfFizzle):
|
||||
return
|
||||
# choose a structure at random
|
||||
@ -804,13 +804,11 @@ def rule_translator(coderack, codelet):
|
||||
if bondDensity > 1.0:
|
||||
bondDensity = 1.0
|
||||
cutoff = __getCutOff(bondDensity) * 10.0
|
||||
assert cutoff >= formulas.actualTemperature
|
||||
if workspace.rule.buildTranslatedRule():
|
||||
workspace.foundAnswer = True
|
||||
else:
|
||||
temperature.clampTime = coderack.codeletsRun + 100
|
||||
temperature.clamped = True
|
||||
formulas.Temperature = 100.0
|
||||
if cutoff >= temperature.actual_value:
|
||||
if workspace.rule.buildTranslatedRule():
|
||||
workspace.foundAnswer = True
|
||||
else:
|
||||
temperature.clampUntil(coderack.codeletsRun + 100)
|
||||
|
||||
|
||||
@codelet('bottom-up-correspondence-scout')
|
||||
|
||||
Reference in New Issue
Block a user