-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindGridIndex.m
36 lines (27 loc) · 934 Bytes
/
FindGridIndex.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 (c) 2015, Yarpiz (www.yarpiz.com)
% All rights reserved. Please read the "license.txt" for license terms.
%
% Project Code: YPEA121
% Project Title: Multi-Objective Particle Swarm Optimization (MOPSO)
% Publisher: Yarpiz (www.yarpiz.com)
%
% Developer: S. Mostapha Kalami Heris (Member of Yarpiz Team)
%
% Contact Info: [email protected], [email protected]
%
function particle=FindGridIndex(particle,Grid)
nObj=numel(particle.Cost);
nGrid=numel(Grid(1).LB);
particle.GridSubIndex=zeros(1,nObj);
for j=1:nObj
particle.GridSubIndex(j)=...
find(particle.Cost(j)<Grid(j).UB,1,'first');
end
particle.GridIndex=particle.GridSubIndex(1);
for j=2:nObj
particle.GridIndex=particle.GridIndex-1;
particle.GridIndex=nGrid*particle.GridIndex;
particle.GridIndex=particle.GridIndex+particle.GridSubIndex(j);
end
end