Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

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 GoodRequestGR/e33c76c4b0d8fcc1693492e70e595922 to your computer and use it in GitHub Desktop.
Save GoodRequestGR/e33c76c4b0d8fcc1693492e70e595922 to your computer and use it in GitHub Desktop.
AI Simulated annealing
fun accept(actual: Solution, neighbor: Solution, temp: Double) : Boolean {
val diff = neighbor.cost - actual.cost
if (diff < 0) { return true }
return random.nextDouble() < exp(-diff / temp)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment