Skip to content

Commit

Permalink
Merge pull request #61 from DestinyMy/master
Browse files Browse the repository at this point in the history
Add four new algorithms and fix some minor bugs
  • Loading branch information
anonymone authored Jul 1, 2020
2 parents 8c821fa + 7ebb82a commit c0a7781
Show file tree
Hide file tree
Showing 45 changed files with 541 additions and 23 deletions.
8 changes: 7 additions & 1 deletion Doc/releasenote.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Release Highlights of PlatEMO 2.8

* Add three algorithms for constrained optimization (i.e., CCMO, MOEA/D-DAE, and TiGE-2) and an algorithm for many-objective optimization (i.e., PREA). There are currently 118 algorithms in the platform.
* Fix some minor bugs in the Pareto front sampling methods in LIR-CMOP and MW problems.

# Release Highlights of PlatEMO 2.6

* Add two algorithms: MOEA/PSL and DWU. There are currently 112 algorithms in the platform.

# Release Highlights of PlatEMO 2.5
Expand Down Expand Up @@ -29,4 +35,4 @@
# Release Highlights of PlatEMO 2.0
* __Lighter framework.__ The architecture of PlatEMO is simplified, which leads to lower learning cost and higher efficiency. The result file size is also reduced.
* __Higher efficiency.__ The runtime of Pareto dominance based algorithms is reduced by using a more efficient non-dominated sorting algorithm. The runtime of decomposition based algorithms is reduced due to the new architecture of PlatEMO. The runtime of hypervolume calculation is reduced by new logic and GPU acceleration. In experimental module, the algorithms can be executed in parallel.
* __More conveniences.__ The populations obtained during the evolutionary process can be saved in result files. The references of each algorithm, problem, operator, and metric are given in the comments of the function. The codes of GUI are now open source.
* __More conveniences.__ The populations obtained during the evolutionary process can be saved in result files. The references of each algorithm, problem, operator, and metric are given in the comments of the function. The codes of GUI are now open source.
44 changes: 44 additions & 0 deletions PlatEMO/Algorithms/CCMO/CCMO.m
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
56 changes: 56 additions & 0 deletions PlatEMO/Algorithms/CCMO/CalFitness.m
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
51 changes: 51 additions & 0 deletions PlatEMO/Algorithms/CCMO/EnvironmentalSelection.m
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
8 changes: 4 additions & 4 deletions PlatEMO/Algorithms/EIM-EGO/InfillSamplingEIM.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
end
s = sqrt(max(0,mse));
% the EI matrix (three dimensional matrix)
f_matrix = f .* ones(1,1,GAPopulationSize);
u_matrix = reshape(u', 1, M, GAPopulationSize).* ones(p,1);
s_matrix = reshape(s', 1, M, GAPopulationSize).* ones(p,1);
EI_matrix=(f_matrix-u_matrix).*Gaussian_CDF((f_matrix-u_matrix)./s_matrix)+s_matrix.*Gaussian_PDF((f_matrix-u_matrix)./s_matrix);
f_matrix = f .* ones(1,1,GAPopulationSize);
u_matrix = reshape(u', 1, M, GAPopulationSize).* ones(p,1);
s_matrix = reshape(s', 1, M, GAPopulationSize).* ones(p,1);
EI_matrix = (f_matrix-u_matrix).*Gaussian_CDF((f_matrix-u_matrix)./s_matrix)+s_matrix.*Gaussian_PDF((f_matrix-u_matrix)./s_matrix);
switch InfillCriterionIndex
case 1
% the Euclidean distance-based EI matrix criterion
Expand Down
12 changes: 6 additions & 6 deletions PlatEMO/Algorithms/LSMOF/WeightOptimization.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
% This function is written by Cheng He

%% Choose NF solutions as the reference solutions
Reference = max(Population.objs,[],1);
Reference = max(Population.objs,[],1);
[RefPop,~,~] = EnvironmentalSelection(Population,wD);

%% Calculate the reference directions
lower = Global.lower;upper = Global.upper;
Direction = [sum((RefPop.decs-repmat(lower,wD,1)).^2,2).^(0.5);sum((repmat(upper,wD,1)-RefPop.decs).^2,2).^(0.5)];
Direct = [(RefPop.decs-repmat(lower,wD,1));(repmat(upper,wD,1)-RefPop.decs)]./repmat(Direction,1,Global.D);
wmax = sum((upper-lower).^2)^(0.5)*0.5;
lower = Global.lower;upper = Global.upper;
Direction = [sum((RefPop.decs-repmat(lower,wD,1)).^2,2).^(0.5);sum((repmat(upper,wD,1)-RefPop.decs).^2,2).^(0.5)];
Direct = [(RefPop.decs-repmat(lower,wD,1));(repmat(upper,wD,1)-RefPop.decs)]./repmat(Direction,1,Global.D);
wmax = sum((upper-lower).^2)^(0.5)*0.5;

%% Optimize the weight variables by DE
w0 = rand(N,2*wD).*wmax; % Initialize the population
Expand Down Expand Up @@ -85,7 +85,7 @@
PopDec = [repmat(w0(i,1:WD)',1,Global.D).*direct(1:WD,:)+repmat(Global.lower,WD,1);
repmat(Global.upper,WD,1) - repmat(w0(i,WD+1:end)',1,Global.D).*direct(WD+1:end,:)];
OffWPop = INDIVIDUAL(PopDec);
OffSpring = [OffSpring,OffWPop];
OffSpring = [OffSpring,OffWPop];
Obj(i) = -HV(OffWPop.objs,Reference);
end
end
74 changes: 74 additions & 0 deletions PlatEMO/Algorithms/MOEA-D-DAE/ArchiveUpdate.m
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
Loading

0 comments on commit c0a7781

Please sign in to comment.