diff --git a/PlatEMO/Algorithms/Multi-objective optimization/AdaW/WeightUpdate.m b/PlatEMO/Algorithms/Multi-objective optimization/AdaW/WeightUpdate.m index 77589008..85c03642 100644 --- a/PlatEMO/Algorithms/Multi-objective optimization/AdaW/WeightUpdate.m +++ b/PlatEMO/Algorithms/Multi-objective optimization/AdaW/WeightUpdate.m @@ -24,7 +24,13 @@ dis2 = pdist2(Archiveobjs,Archiveobjs); dis2 = sort(dis2,2); % Calculate the niche size(median of the distances from their closest solution in the archive ) - niche_size = median(dis2(:,2)); + if size(dis2, 2) >= 2 + niche_size = median(dis2(:,2)); + else + warning('dis2 只有一列数据,无法访问第二列。'); + % If there is only one column for dis2, use the first column + niche_size = median(dis2(:,1)); + end % Find undeveloped Archive_und = Archive(dis1(:,1) >= niche_size); N_und = length(Archive_und); @@ -97,4 +103,4 @@ B = pdist2(W,W); [~,B] = sort(B,2); B = B(:,1:T); -end \ No newline at end of file +end