Skip to content

Instantly share code, notes, and snippets.

@vjeux
Created November 7, 2011 19:37
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 vjeux/1345916 to your computer and use it in GitHub Desktop.
Save vjeux/1345916 to your computer and use it in GitHub Desktop.
while outer_condition()
while inner_condition()
[a, b] = pick2()
delta = swap a, b
if delta < 0 or Math.random() < Math.exp(-(delta + 1) / T)
cost += delta
else
swap a, b # revert
T *= C
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment