-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateVelocities.m
36 lines (35 loc) · 1.7 KB
/
updateVelocities.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
% COPYRIGHT
% This file is part of TSSA: https://github.com/ayrna/tssa
% Original authors: Antonio M. Duran Rosal, Pedro A. Gutierrez
% Copyright:
% This software is released under the The GNU General Public License v3.0 licence
% available at http://www.gnu.org/licenses/gpl-3.0.html
% Citation: If you use this code, please cite the following paper:
% [1] A.M. Durán-Rosal, P.A. Gutiérrez, Á. Carmona-Poyato and C. Hervás-Martínez.
% "A hybrid dynamic exploitation barebones particle swarm optimisation
% algorithm for time series segmentation", Neurocomputing,
% Vol. 353, August, 2019, pp. 45-55.
%
%% updateVelocities
% Function: update the velocities of a particle swarm
%
% Input:
% velocities: current velocities of the particles
% currentPopulationInt: population
% bestLocalPopulationInt: best local positions
% bestIndividualInt: best global position
% nPobl: population size
% sizeChromosomeInt: integer chromosome length
% W: weight param
% C1,C2: acceleration constants
%
% Output:
% newVelocities: new velocities of the particles
function [newVelocities] = updateVelocities(velocities,currentPopulationInt,bestLocalPopulationInt,bestIndividualInt,nPobl,sizeChromosomeInt,W,C1,C2)
newVelocities = velocities;
ro1 = unifrnd(0,1,[1 sizeChromosomeInt]);
ro2 = unifrnd(0,1,[1 sizeChromosomeInt]);
for i=1:nPobl,
newVelocities(i,:) = W * velocities(i,:) + C1 * ro1 .* (bestLocalPopulationInt(i,:) - currentPopulationInt(i,:)) + C2 * ro2 .* (bestIndividualInt(1,:) - currentPopulationInt(i,:));
end
end