I want to code simulated annealing in HTML and JavaScript. I want to code it for placement, but for simplicity I am assuming that all the cells are in one row. I have around 30 cells. I looked for some material online but I couldn’t find code to start with.
My pseudocode is as follows:
Simulated_Annealing{
S = initial solution
T = initial temperature (>0)
while( T > 0 ) {
S’ = pick a random neighbor to S
C = cost of S – cost of S’
if( C > 0 ){
S = S’
} else {
r = random number in range [0…1]
m = 1/e| C/T |
if( r < m ) {
S = S’
}
}
T = reduced T;
}
}
Any help is appreciated.
Thanks.
Doing a quick search on GitHub found https://github.com/ebobby/Jsqueens which uses simulated annealing to solve the 9 queens problem. Here’s the relevant code: