from
Multi-Objective Optimizaion using Evolutionary Algorithm
by Aravind Seshadri
Examples of Multi-Objective Optimization using evolutionary algorithm - NSGA-II
|
| function f = crowding_distance(x,problem) |
function f = crowding_distance(x,problem)
[N,M] = size(x);
switch problem
case 1
M = 2;
V = 6;
case 2
M = 3;
V = 12;
end
for i = 1 : length(F(front).f)
y(i,:) = x(F(front).f(i),:);
end
for i = 1 : M
[sorted(i).individual,sorted(i).index] = sort(y(:,V + i));
distance(sorted(i).index(1)).individual = Inf;
distance(sorted(i).index(length(sorted(i).index))).individual = Inf;
end
[num,len] = size(y);
for i = 1 : M
for j = 2 : num - 1
distance(j).individual = 0;
end
objective(i).range = ...
sorted(i).individual(length(sorted(i).individual)) - ...
sorted(i).individual(1);
end
for i = 1 : M
for j = 2 : num - 1
distance(j).individual = distance(j).individual + ...
(sorted(i).individual(j + 1) - sorted(i).individual(j - 1))/...
objective(i).range;
y(sorted(i).index(j),M + V + 2) = distance(j).individual;
end
end
Published with MATLAB® 7.0
|
|
Contact us at files@mathworks.com