Effacer les filtres
Effacer les filtres

Accept a solution in a simple program

1 vue (au cours des 30 derniers jours)
sami
sami le 17 Mai 2013
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 -----------------------

Réponses (0)

Catégories

En savoir plus sur Optimization Toolbox dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by