Created
July 14, 2022 19:47
-
-
Save GoodRequestGR/e33c76c4b0d8fcc1693492e70e595922 to your computer and use it in GitHub Desktop.
AI Simulated annealing
This file contains 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
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