-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from DestinyMy/master
Add four new algorithms and fix some minor bugs
- Loading branch information
Showing
45 changed files
with
541 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
function CCMO(Global) | ||
% <algorithm> <C> | ||
% Coevolutionary constrained multi-objective optimization framework | ||
% type --- 1 --- Type of operator (1. GA 2. DE) | ||
|
||
%------------------------------- Reference -------------------------------- | ||
% Y. Tian, T. Zhang, J. Xiao, X. Zhang, and Y. Jin, A coevolutionary | ||
% framework for constrained multi-objective optimization problems, IEEE | ||
% Transactions on Evolutionary Computation, 2020. | ||
%------------------------------- Copyright -------------------------------- | ||
% Copyright (c) 2018-2019 BIMK Group. You are free to use the PlatEMO for | ||
% research purposes. All publications which use this platform or any code | ||
% in the platform should acknowledge the use of "PlatEMO" and reference "Ye | ||
% Tian, Ran Cheng, Xingyi Zhang, and Yaochu Jin, PlatEMO: A MATLAB platform | ||
% for evolutionary multi-objective optimization [educational forum], IEEE | ||
% Computational Intelligence Magazine, 2017, 12(4): 73-87". | ||
%-------------------------------------------------------------------------- | ||
|
||
%% Parameter setting | ||
type = Global.ParameterSet(1); | ||
|
||
%% Generate random population | ||
Population1 = Global.Initialization(); | ||
Population2 = Global.Initialization(); | ||
Fitness1 = CalFitness(Population1.objs,Population1.cons); | ||
Fitness2 = CalFitness(Population2.objs); | ||
|
||
%% Optimization | ||
while Global.NotTermination(Population1) | ||
if type == 1 | ||
MatingPool1 = TournamentSelection(2,Global.N,Fitness1); | ||
MatingPool2 = TournamentSelection(2,Global.N,Fitness2); | ||
Offspring1 = GAhalf(Population1(MatingPool1)); | ||
Offspring2 = GAhalf(Population2(MatingPool2)); | ||
elseif type == 2 | ||
MatingPool1 = TournamentSelection(2,2*Global.N,Fitness1); | ||
MatingPool2 = TournamentSelection(2,2*Global.N,Fitness2); | ||
Offspring1 = DE(Population1,Population1(MatingPool1(1:end/2)),Population1(MatingPool1(end/2+1:end))); | ||
Offspring2 = DE(Population2,Population2(MatingPool2(1:end/2)),Population2(MatingPool2(end/2+1:end))); | ||
end | ||
[Population1,Fitness1] = EnvironmentalSelection([Population1,Offspring1,Offspring2],Global.N,true); | ||
[Population2,Fitness2] = EnvironmentalSelection([Population2,Offspring1,Offspring2],Global.N,false); | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
function Fitness = CalFitness(PopObj,PopCon) | ||
% Calculate the fitness of each solution | ||
|
||
%------------------------------- Copyright -------------------------------- | ||
% Copyright (c) 2018-2019 BIMK Group. You are free to use the PlatEMO for | ||
% research purposes. All publications which use this platform or any code | ||
% in the platform should acknowledge the use of "PlatEMO" and reference "Ye | ||
% Tian, Ran Cheng, Xingyi Zhang, and Yaochu Jin, PlatEMO: A MATLAB platform | ||
% for evolutionary multi-objective optimization [educational forum], IEEE | ||
% Computational Intelligence Magazine, 2017, 12(4): 73-87". | ||
%-------------------------------------------------------------------------- | ||
|
||
N = size(PopObj,1); | ||
if nargin == 1 | ||
CV = zeros(N,1); | ||
else | ||
CV = sum(max(0,PopCon),2); | ||
end | ||
|
||
%% Detect the dominance relation between each two solutions | ||
Dominate = false(N); | ||
for i = 1 : N-1 | ||
for j = i+1 : N | ||
if CV(i) < CV(j) | ||
Dominate(i,j) = true; | ||
elseif CV(i) > CV(j) | ||
Dominate(j,i) = true; | ||
else | ||
k = any(PopObj(i,:)<PopObj(j,:)) - any(PopObj(i,:)>PopObj(j,:)); | ||
if k == 1 | ||
Dominate(i,j) = true; | ||
elseif k == -1 | ||
Dominate(j,i) = true; | ||
end | ||
end | ||
end | ||
end | ||
|
||
%% Calculate S(i) | ||
S = sum(Dominate,2); | ||
|
||
%% Calculate R(i) | ||
R = zeros(1,N); | ||
for i = 1 : N | ||
R(i) = sum(S(Dominate(:,i))); | ||
end | ||
|
||
%% Calculate D(i) | ||
Distance = pdist2(PopObj,PopObj); | ||
Distance(logical(eye(length(Distance)))) = inf; | ||
Distance = sort(Distance,2); | ||
D = 1./(Distance(:,floor(sqrt(N)))+2); | ||
|
||
%% Calculate the fitnesses | ||
Fitness = R + D'; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
function [Population,Fitness] = EnvironmentalSelection(Population,N,isOrigin) | ||
% The environmental selection of SPEA2 | ||
|
||
%------------------------------- Copyright -------------------------------- | ||
% Copyright (c) 2018-2019 BIMK Group. You are free to use the PlatEMO for | ||
% research purposes. All publications which use this platform or any code | ||
% in the platform should acknowledge the use of "PlatEMO" and reference "Ye | ||
% Tian, Ran Cheng, Xingyi Zhang, and Yaochu Jin, PlatEMO: A MATLAB platform | ||
% for evolutionary multi-objective optimization [educational forum], IEEE | ||
% Computational Intelligence Magazine, 2017, 12(4): 73-87". | ||
%-------------------------------------------------------------------------- | ||
|
||
%% Calculate the fitness of each solution | ||
if isOrigin | ||
Fitness = CalFitness(Population.objs,Population.cons); | ||
else | ||
Fitness = CalFitness(Population.objs); | ||
end | ||
|
||
%% Environmental selection | ||
Next = Fitness < 1; | ||
if sum(Next) < N | ||
[~,Rank] = sort(Fitness); | ||
Next(Rank(1:N)) = true; | ||
elseif sum(Next) > N | ||
Del = Truncation(Population(Next).objs,sum(Next)-N); | ||
Temp = find(Next); | ||
Next(Temp(Del)) = false; | ||
end | ||
% Population for next generation | ||
Population = Population(Next); | ||
Fitness = Fitness(Next); | ||
% Sort the population | ||
[Fitness,rank] = sort(Fitness); | ||
Population = Population(rank); | ||
end | ||
|
||
function Del = Truncation(PopObj,K) | ||
% Select part of the solutions by truncation | ||
|
||
%% Truncation | ||
Distance = pdist2(PopObj,PopObj); | ||
Distance(logical(eye(length(Distance)))) = inf; | ||
Del = false(1,size(PopObj,1)); | ||
while sum(Del) < K | ||
Remain = find(~Del); | ||
Temp = sort(Distance(Remain,Remain),2); | ||
[~,Rank] = sortrows(Temp); | ||
Del(Remain(Rank(1))) = true; | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
function Population = ArchiveUpdate(Population,N) | ||
% Update archive | ||
|
||
%------------------------------- Copyright -------------------------------- | ||
% Copyright (c) 2018-2019 BIMK Group. You are free to use the PlatEMO for | ||
% research purposes. All publications which use this platform or any code | ||
% in the platform should acknowledge the use of "PlatEMO" and reference "Ye | ||
% Tian, Ran Cheng, Xingyi Zhang, and Yaochu Jin, PlatEMO: A MATLAB platform | ||
% for evolutionary multi-objective optimization [educational forum], IEEE | ||
% Computational Intelligence Magazine, 2017, 12(4): 73-87". | ||
%-------------------------------------------------------------------------- | ||
|
||
%% Select feasible solutions | ||
fIndex = all(Population.cons <= 0,2); | ||
Population = Population(fIndex); | ||
if isempty(Population) | ||
return | ||
else | ||
if size(Population.objs,2)==2 | ||
%% Non-dominated sorting | ||
[FrontNo,~] = NDSort(Population.objs,1); | ||
Next = (FrontNo == 1); | ||
Population = Population(Next); | ||
if sum(Next) > N | ||
%% Calculate the crowding distance of each solution | ||
CrowdDis = CrowdingDistance(Population.objs); | ||
[~,Rank] = sort(CrowdDis,'descend'); | ||
Population = Population(Rank(1:N)); | ||
end | ||
else | ||
Population = Population(NDSort(Population.objs,1)==1); | ||
Population = Population(randperm(length(Population))); | ||
PCObj = Population.objs; | ||
nND = length(Population); | ||
%% Population maintenance | ||
if length(Population) > N | ||
% Normalization | ||
fmax = max(PCObj,[],1); | ||
fmin = min(PCObj,[],1); | ||
PCObj = (PCObj-repmat(fmin,nND,1))./repmat(fmax-fmin,nND,1); | ||
% Determine the radius of the niche | ||
d = pdist2(PCObj,PCObj); | ||
d(logical(eye(length(d)))) = inf; | ||
sd = sort(d,2); | ||
r = mean(sd(:,min(3,size(sd,2)))); | ||
R = min(d./r,1); | ||
% Delete solution one by one | ||
while length(Population) > N | ||
[~,worst] = max(1-prod(R,2)); | ||
Population(worst) = []; | ||
R(worst,:) = []; | ||
R(:,worst) = []; | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
function CrowdDis = CrowdingDistance(PopObj) | ||
% Calculate the crowding distance of each solution | ||
|
||
[N,M] = size(PopObj); | ||
CrowdDis = zeros(1,N); | ||
Fmax = max(PopObj,[],1); | ||
Fmin = min(PopObj,[],1); | ||
for i = 1 : M | ||
[~,Rank] = sortrows(PopObj(:,i)); | ||
CrowdDis(Rank(1)) = inf; | ||
CrowdDis(Rank(end)) = inf; | ||
for j = 2 : (N - 1) | ||
CrowdDis(Rank(j)) = CrowdDis(Rank(j))+(PopObj(Rank(j+1),i)-PopObj(Rank(j-1),i))/(Fmax(i)-Fmin(i)); | ||
end | ||
end | ||
end |
Oops, something went wrong.