Accept a solution in a simple program
1 view (last 30 days)
Show older comments
Hello, i am not quite sure about the result i got, whether to ACCEPT or NOT ACCEPT with probability , i think its a metropolis algorithm or simulated annealing Algorithm, it says :
-
%M = number of moves to attempt
%T=current temperature
%for m = 1 to M{
%Generate a random move e.g, move a particle
%Evaluate the change in energy, Delta E
%if (Delta E < 0)
%/*downhill move : accept it*/
%accept this move and update configuration
%}
%else{
%/*uphill move : accept maybe*/
%accept this move with probability of P = e^(-Delta E / T)
%update configuration if accepted
%}
%}/*end for loop*/
------------- matlab code start from here -----------------------
clear all;clc
M= 20;%M = number of moves to attempt
T = 25;%T=current temperature
e = exp(1);
for m = 1:M
randmove = randi(60,1);
DeltaE=randmove-T;
if DeltaE<0
moveaccepted = DeltaE;
else
prob = e^(-DeltaE/T);
configg = [DeltaE,(1-prob)*100];%100% acceptance ,(1-prob)*100
end
end
configg
------------- end matlab code start from here -----------------------
0 Comments
Answers (0)
See Also
Categories
Find more on Simulated Annealing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!