?? sa.asv
字號:
% ME6352
% Global Optimization: Heuristic Method
% Simulated Annealing Project
%Date: Feb. 25th,2008
%Author: Jin Zhao
function [Xstar, fstar]=SA(tini,kb)
%parameter statment
%af=0.98;
%t=af*t
t=tini+1;
beta=-kb/t; %boltzmann constant kb
done=0;
gobacktostep1=-1;
p=0;
r=rand();
testf=0;
testX=0;
[X,f1]=DeJong8; % step1 Choose starting design X,
fmin=f1;
Xmin=X;
while ~done
t=t-1;
if t<=0.1 %stopping criteria
Xstar=Xmin;
fstar=fmin;
done=1;
break;
else
[testX,testf]=DeJong8; %choose a random point
if f1<testf
p=1;
else
p=(-beta)*exp(f1-testf);
end
r=rand(); %creat a random number
if r<=p
gobacktostep1=0; %the step is accepted and the design vector is update
else
gobacktostep1=1;
end
end
if gobacktostep1==0
X=testX;
f1=testf;
if f1<=fmin
Xmin=X;
fmin=f1;
end
else
gobacktostep1==1;
end
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -