harmony search algorithm

Transkrypt

harmony search algorithm
HARMONY SEARCH
ALGORITHM
PRZYGOTOWALI:
DZIARSKI JAROSŁAW
KOZIARSKI MICHAŁ
HARMONIA
Harmonia – nauka
o łączeniu akordów
Akord – współbrzmienie
co najmniej trzech dźwięków
o różnej wysokości i nazwie
Etapy algorytmu :

sformułowanie problemu

ustalenie parametrów

losowe strojenie do inicjalizacji pamięci

improwizację harmonii (wybieranie losowe,
uwzględnienie pamięci i regulacja tonów)

aktualizowanie pamięci

dokonanie zakończenia

cadenza

function [xbest,fbest] = harmony(f,xL,xU,HSparams)

% HARMONY basic Harmony Search minimization for continuous variables


% Unpack the parameter vector

HMS

MaxImp = HSparams.MaxImp;

HMCR
= HSparams.HMCR;

PAR
= HSparams.PAR;

b
= HSparams.b;

% Dimension arrays

N
= length(xL);

HM
= zeros(HMS,N);

F
= zeros(HMS,1);

xnew = zeros(1,N);
= HSparams.HMS;
% Number of decision variables


% Randomly initialize HM, taking care to keep each variable within bounds.

% Evaluate the corresponding objective function values.

for j = 1:HMS

HM(j,:) = xL + (xU-xL).*rand(1,N);

F(j)

end
= f(HM(j,:));

% Loop through MaxImp improvisations

for j = 1:MaxImp


% Improvise a new harmony: loop though each variable

for i = 1:N

% Randomly perform one of the three HS operations

if rand < HMCR

% Memory considering: randomly select a note stored in HM

xnew(i) = HM(ceil(rand*HMS),i);

if rand < PAR

% Pitch adjusting: randomly adjust the pitch slightly

% within +/- b(i), and ensure bounds are satisfied

xnew(i) = xnew(i) + (2*rand-1)*b(i);

xnew(i) = min(max(xnew(i),xL(i)),xU(i));
end


else

% Random playing: randomly select any pitch within bounds

xnew(i) = xL(i) + rand*(xU(i)-xL(i));



end
end % Finished improvising a new harmony

% HM update: check whether the new harmony is better than the worst

% harmony currently in HM

fnew = f(xnew);

[fworst,idxworst] = max(F);

if fnew < fworst

HM(idxworst,:) = xnew;

F(idxworst)

= fnew;
end

end % Maximum number of improvisations reached

% Return the best harmony found

[fbest,idxbest] = min(F);

xbest = HM(idxbest,:);

-------------------------------------------------------------------------------------------

% Set HS algorithm parameters HSparams.HMS = 10;

% harmony memory size; ilosc wektorow rozwiazan rownoczesnie rozpatrywanych przez algorytm
HSparams.MaxImp = 10000;

% maksymalna ilosc improwizacji (iteracji) HSparams.HMCR = 0.8;

% harmony memory considering rate; prawdopodobienstwo wybrania losowej wartosci z juz wygenerowanych
(w przeciwnym razie losowana nowa); zakres <0; 1> HSparams.PAR = 0.4;

% prawdopodobienstwo wystapienia dostrajania ('mutacji'); zakres <0; 1> HSparams.b = (xU-xL)/1000;

% zmiana wartosci podczas dostrajania ('mutacji')
Dziękujemy za uwagę
PRZYGOTOWALI:
DZIARSKI JAROSŁAW
KOZIARSKI MICHAŁ

Podobne dokumenty