Created
January 21, 2019 22:03
-
-
Save oscar6echo/1793bd8b2a9e3602a51e4873139eaca0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Objective | |
# Find energy with low, hopefully minimum, energy | |
# Inputs | |
energy(): function state -> energy | |
mutate(): function state -> state - typically random | |
temperature T reduction profile from Tmax down to Tmin | |
# Start | |
s = init_state | |
for T from T_max to T_min: | |
E_s = energy(s) | |
m = mutate(s) # random | |
E_m = energy(m) | |
dE = E_m - E_s | |
if rand(0, 1) < exp(-dE/T): | |
# always true for dE < 0 | |
# sometimes true for dE > 0, all the more so if T is high | |
s = m | |
return s # should be a low energy state |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment