Skip to content

Instantly share code, notes, and snippets.

@oscar6echo
Created January 21, 2019 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oscar6echo/1793bd8b2a9e3602a51e4873139eaca0 to your computer and use it in GitHub Desktop.
Save oscar6echo/1793bd8b2a9e3602a51e4873139eaca0 to your computer and use it in GitHub Desktop.
# 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