Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Fantasy-Dzx committed Sep 3, 2024
1 parent 1274e25 commit 9b24b71
Show file tree
Hide file tree
Showing 110 changed files with 6,293 additions and 512 deletions.
Binary file added PlatEMO/Algorithms/Blocks/BLOCK.p
Binary file not shown.
35 changes: 35 additions & 0 deletions PlatEMO/Algorithms/Blocks/BlockEA.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
classdef BlockEA < ALGORITHM

%------------------------------- Copyright --------------------------------
% Copyright (c) 2024 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".
%--------------------------------------------------------------------------

methods
function main(Algorithm,Problem)
%% Parameter setting
[Blocks,Graph] = Algorithm.ParameterSet({},{});

%% Generate random population
isPop = arrayfun(@(s)isa(s,'Block_Population'),Blocks(:)');
Blocks(isPop).Initialization(Problem.Initialization());

%% Optimization
while Algorithm.NotTerminated(Blocks(1).output)
activated = false(1,length(Blocks));
while ~all(activated(isPop))
for i = find(~activated)
if all(activated(logical(Graph(:,i)))|isPop(logical(Graph(:,i))))
Blocks(i).Main(Problem,Blocks(logical(Graph(:,i))),Graph(:,i));
activated(i) = true;
end
end
end
end
end
end
end
13 changes: 13 additions & 0 deletions PlatEMO/Algorithms/Blocks/Block_Crossover.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
% classdef Block_Crossover < BLOCK
% Unified crossover for real variables
% nParents --- 2 --- Number of parents generating one offspring
% nSets --- 5 --- Number of parameter sets

%------------------------------- Copyright --------------------------------
% Copyright (c) 2024 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".
%--------------------------------------------------------------------------
Binary file added PlatEMO/Algorithms/Blocks/Block_Crossover.p
Binary file not shown.
12 changes: 12 additions & 0 deletions PlatEMO/Algorithms/Blocks/Block_Exchange.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
% classdef Block_Exchange < BLOCK
% Exchange of parents
% nParents --- 2 --- Number of parents generating one offspring

%------------------------------- Copyright --------------------------------
% Copyright (c) 2024 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".
%--------------------------------------------------------------------------
Binary file added PlatEMO/Algorithms/Blocks/Block_Exchange.p
Binary file not shown.
12 changes: 12 additions & 0 deletions PlatEMO/Algorithms/Blocks/Block_Kopt.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
% classdef Block_Kopt < BLOCK
% k-opt
% k --- 4 --- Max number of k for k-opt

%------------------------------- Copyright --------------------------------
% Copyright (c) 2024 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".
%--------------------------------------------------------------------------
Binary file added PlatEMO/Algorithms/Blocks/Block_Kopt.p
Binary file not shown.
12 changes: 12 additions & 0 deletions PlatEMO/Algorithms/Blocks/Block_Mutation.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
% classdef Block_Mutation < BLOCK
% Unified mutation for real variables
% nSets --- 5 --- Number of parameter sets

%------------------------------- Copyright --------------------------------
% Copyright (c) 2024 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".
%--------------------------------------------------------------------------
Binary file added PlatEMO/Algorithms/Blocks/Block_Mutation.p
Binary file not shown.
11 changes: 11 additions & 0 deletions PlatEMO/Algorithms/Blocks/Block_Population.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
% classdef Block_Population < BLOCK
% A population

%------------------------------- Copyright --------------------------------
% Copyright (c) 2024 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".
%--------------------------------------------------------------------------
Binary file added PlatEMO/Algorithms/Blocks/Block_Population.p
Binary file not shown.
12 changes: 12 additions & 0 deletions PlatEMO/Algorithms/Blocks/Block_Selection.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
% classdef Block_Selection < BLOCK
% Environmental selection
% nSolutions --- 100 --- Number of retained solutions

%------------------------------- Copyright --------------------------------
% Copyright (c) 2024 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".
%--------------------------------------------------------------------------
Binary file added PlatEMO/Algorithms/Blocks/Block_Selection.p
Binary file not shown.
13 changes: 13 additions & 0 deletions PlatEMO/Algorithms/Blocks/Block_Tournament.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
% classdef Block_Tournament < BLOCK
% Tournament selection
% nParents --- 100 --- Number of parents generated
% upper --- 2 --- Max number of k for k-tournament

%------------------------------- Copyright --------------------------------
% Copyright (c) 2024 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".
%--------------------------------------------------------------------------
Binary file added PlatEMO/Algorithms/Blocks/Block_Tournament.p
Binary file not shown.
121 changes: 121 additions & 0 deletions PlatEMO/Algorithms/Multi-objective optimization/AC-MMEA/ACMMEA.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
classdef ACMMEA < ALGORITHM
% <multi> <real/integer> <large/none> <multimodal> <sparse>
% Adaptive merging and coordinated offspring generation based multi-modal multi-objective evolutionary algorithm

%------------------------------- Reference --------------------------------
% X. Wang, T. Zheng, and Y. Jin, Adaptive merging and coordinated offspring
% generation in multi-population evolutionary multi-modal multi-objective
% optimization, Proceedings of the International Conference on Data-driven
% Optimization of Complex Systems, 2023.
%------------------------------- Copyright --------------------------------
% Copyright (c) 2024 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".
%--------------------------------------------------------------------------

% This function is written by Xiangyu Wang (email: [email protected])

methods
function main(Algorithm,Problem)
%% Population initialization
Dec = unifrnd(repmat(Problem.lower,Problem.N,1),repmat(Problem.upper,Problem.N,1));
Mask = zeros(Problem.N,Problem.D);
GV = ones(1,Problem.D);
for i = 1 : Problem.N
Mask(i,TournamentSelection(2,ceil(rand*Problem.D),GV)) = 1;
GV(Mask(i,:)==1) = GV(Mask(i,:)==1)+1;
end
Population = Problem.Evaluation(Dec.*Mask);
[slst] = Clustering(Population.decs, 20, [Problem.lower,Problem.upper], Problem.D);
K=size(slst,2);
Masks = cell(1,K);
Decs = cell(1,K);
Populations = cell(1,K);
GV = cell(1,K);
FrontNo = cell(1,K);
CrowdDis = cell(1,K);
Fitness = cell(1,K);
for i = 1 : K
Populations{i} = Population(slst{i});
Masks{i} = Mask(slst{i},:);
Decs{i} = Dec(slst{i},:);
[Populations{i},Decs{i},Masks{i},FrontNo{i},CrowdDis{i}] = EnvironmentalSelection(Populations{i},Decs{i},Masks{i},length(Populations{i}));
GV{i} = UpdateGV(zeros(1,Problem.D),Masks{i},FrontNo{i});
end
StageIFlag = 1;
Timea = 0;

%% Optimization
while Algorithm.NotTerminated(Population)
if Problem.FE < 0.3 * Problem.maxFE
[~,rank] = sort(SubPopRank(Populations));
for i = 1 : K
GV{rank(i)} = UpdateGV(GV{rank(i)},Masks{rank(i)},FrontNo{rank(i)});
Mating = TournamentSelection(2,2*length(Populations{rank(i)}),FrontNo{rank(i)},-CrowdDis{rank(i)});
[OffDec,OffMask] = Operator(Problem,Decs{rank(i)}(Mating,:),Masks{rank(i)}(Mating,:),GV{rank(i)}, StageIFlag);
Offspring = Problem.Evaluation(OffDec.*OffMask);
Populations{rank(i)} = [Populations{rank(i)},Offspring];
Decs{rank(i)} = [Decs{rank(i)};OffDec];
Masks{rank(i)} = [Masks{rank(i)};OffMask];
if i > 1
for j = 1 : i-1
[~,fs(rank(j))] = min(mean(Populations{rank(j)}.objs,2));
end
R = zeros(1,Problem.D);
for j = 1 : i-1
R = R + Masks{rank(j)}(fs(rank(j)),:);
end
R(R>0) = 1;
dis = sum(repmat(R,length(Populations{rank(i)}),1)&Masks{rank(i)},2);
[Populations{rank(i)},Decs{rank(i)},Masks{rank(i)},FrontNo{rank(i)},CrowdDis{rank(i)}] = EnvironmentalSelection(Populations{rank(i)},Decs{rank(i)},Masks{rank(i)},floor(Problem.N/K),dis);
else
[Populations{rank(i)},Decs{rank(i)},Masks{rank(i)},FrontNo{rank(i)},CrowdDis{rank(i)}] = EnvironmentalSelection(Populations{rank(i)},Decs{rank(i)},Masks{rank(i)},floor(Problem.N/K));
end
end
if mod(ceil(Problem.FE/Problem.N),50)==0
[Populations,Masks,Decs,GV,K]=SubPopSimility(Populations,Masks,Decs,GV);
FrontNo = cell(1,K);
CrowdDis = cell(1,K);
for i = 1 : K
[Populations{i},Decs{i},Masks{i},FrontNo{i},CrowdDis{i}] = EnvironmentalSelection(Populations{i},Decs{i},Masks{i},floor(Problem.N/K));
end
end
else
if Timea == 0
for i = 1 : K
[Populations{rank(i)},Decs{rank(i)},Masks{rank(i)},FrontNo{rank(i)},Fitness{rank(i)}] = EnvironmentalSelectionS(Populations{rank(i)},Decs{rank(i)},Masks{rank(i)},length(Populations{rank(i)}));
GV{rank(i)} = UpdateGV(zeros(1,Problem.D),Masks{rank(i)},FrontNo{rank(i)});
end
end
Timea = Timea + 1;
StageIFlag = 0;
for i=1:K
GV{rank(i)} = UpdateGV(GV{rank(i)},Masks{rank(i)},FrontNo{rank(i)});
Mating = TournamentSelection(2,2*length(Populations{rank(i)}),FrontNo{rank(i)},Fitness{rank(i)});
[OffDec,OffMask] = Operator(Problem,Decs{rank(i)}(Mating,:),Masks{rank(i)}(Mating,:),GV{rank(i)}, StageIFlag);
Offspring = Problem.Evaluation(OffDec.*OffMask);
Populations{rank(i)} = [Populations{rank(i)},Offspring];
Decs{rank(i)} = [Decs{rank(i)};OffDec];
Masks{rank(i)} = [Masks{rank(i)};OffMask];
[Populations{rank(i)},Decs{rank(i)},Masks{rank(i)},FrontNo{rank(i)},Fitness{rank(i)}] = EnvironmentalSelectionS(Populations{rank(i)},Decs{rank(i)},Masks{rank(i)},floor(Problem.N/K));

end
if mod(ceil(Problem.FE/Problem.N),50)==0
[Populations,Masks,Decs,GV,K]=SubPopSimility(Populations,Masks,Decs,GV);
FrontNo = cell(1,K);
CrowdDis = cell(1,K);
for i = 1 : K
[Populations{i},Decs{i},Masks{i},FrontNo{i},CrowdDis{i}] = EnvironmentalSelection(Populations{i},Decs{i},Masks{i},floor(Problem.N/K));
end
Timea = 0;
[~,rank] = sort(SubPopRank(Populations));
end
end
Population = [Populations{:}];
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
function Fitness = CalFitness(PopObj)
% Calculate the fitness of each solution

%------------------------------- Copyright --------------------------------
% Copyright (c) 2024 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".
%--------------------------------------------------------------------------

% This function is written by Xiangyu Wang (email: [email protected])

N = size(PopObj,1);

%% Detect the dominance relation between each two solutions
Dominate = false(N);
for i = 1 : N-1
for j = i+1 : N
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

%% 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
function slst = Clustering(X, n, bound, dim)

%------------------------------- Copyright --------------------------------
% Copyright (c) 2024 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".
%--------------------------------------------------------------------------

% This function is written by Xiangyu Wang (email: [email protected])

a = size(X,1);
p = X;
p(:,dim+1) = [1:a];
for i = 1 : a
G{i} = i;
end
M = [];
for j = 1 : a
M(j,:) = ((sum((repmat(X(j,:),size(X,1),1) - X).^2,2)).^0.5)';%M(i, j) reprents the distance of i-th cluster to the j-th cluster
end
found = 1;
while found == 1
found = 0;
min_dist = (dim*((bound(2) - bound(1)).^2)).^0.5;
for i = 1:size(G,2)-1
for j = i + 1 :size(G,2)
if size(G{i},2) + size(G{j},2) < n+1
if min_dist >= M(i, j)
min_dist = M(i, j);
r = i;
s = j;
found = 1;
end
end
end

end
if ~isempty(r) && ~isempty(s)
G{r} = [G{r}, G{s}]; % merge clusters r and s;
for k = 1 : size(G{s},2)
p(p(:,dim+1)==G{s}(k),:) = [];
end
G(s) = []; % delete cluster s;
M(:,s) = []; % update the M
M(s,:) = []; % update the M
h = p(:,1:dim);
for k = 1 : size(G{r},2)
D(k,:) = ((sum((repmat(X(G{r}(k),:),size(h,1),1) - h).^2,2)).^0.5)';
end
D = min(D,[],1);
M(:,r) = D';M(r,:) = D;
D = [];
s = [];
r = [];
c = 0;
for i = 1 : size(G,2)
if size(G{i},2) == 1
c = c + 1;
end
end
if c == 0
found = 0;
end
end
end
slst = G;
end
Loading

0 comments on commit 9b24b71

Please sign in to comment.