資源簡介
和聲搜索(Harmony Search, HS)算法是一種新穎的智能優化算法。類似于遺傳算法對生物進化的模仿、模擬退火算法對物理退火的模擬以及粒子群優化算法對鳥群的模仿等,和聲算法模擬了音樂演奏的原理。
代碼片段和文件信息
%?Harmony?Search?Algorithm
%By?Sajjad?Yazdani
%
%?base?on:
%?[1]:
clc;clear?all;close?all
%%?Problem?Prametters
Dim=2;?%?problem?Dimention
Low=[-10?-10];?%?Low?Boundry?of?Problem
High=[10?10];?%?High?Boundry?of?Problem
Min=1;?%?Minimaization?or?maximaiz?of?Fun??if?Min=1?it?will?be?minimaze?the?function?and?if?Min=0?it?will?be?maximized?the?function.
%%?Harmony?Search?Parametters
HMS=100;%Harmony?Memory?Size?(Population?Number)
bw=0.2;
HMCR=0.95;%[1]?Harmony?Memory?Considering?Rate
PAR=0.3;%[1]?Pitch?Adjustment?Rate
MaxItr=10000;%?Maximum?number?of?Iteration
%%?Initialization
HM=zeros(HMSDim);
HF=zeros(HMS1);
for?i=1:HMS
????HM(i:)=Low+(High-Low).*rand(1Dim);
????HF(i1)=MyFun(HM(i:));
end
if?Min==1
????[WorstFitWorstLoc]=max(HF);
else
????[WorstFitWorstLoc]=min(HF);
end
%%?Iteration?Loop
for?Itr=1:MaxItr
????HarmonyIndex=fix(rand(1Dim)*HMS)+1;%?Random?Selection?of?Ha
評論
共有 條評論