Skip to content

Commit

Permalink
1. Optimize the GUI and fix bugs.
Browse files Browse the repository at this point in the history
2. add New Algorithms and Problems
  • Loading branch information
anonymone committed May 18, 2019
1 parent c8694b7 commit 74b11fd
Show file tree
Hide file tree
Showing 26 changed files with 1,023 additions and 11 deletions.
2 changes: 1 addition & 1 deletion PlatEMO/Algorithms/MOEA-D-DE/MOEADDE.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function MOEADDE(Global)
for i = 1 : Global.N
% Choose the parents
if rand < delta
P = B(i,randperm(size(B,2)));
P = B(i,randperm(end));
else
P = randperm(Global.N);
end
Expand Down
2 changes: 1 addition & 1 deletion PlatEMO/Algorithms/MOEA-D-DRA/MOEADDRA.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function MOEADDRA(Global)
for i = I
% Choose the parents
if rand < 0.9
P = B(i,randperm(size(B,2)));
P = B(i,randperm(end));
else
P = randperm(Global.N);
end
Expand Down
38 changes: 38 additions & 0 deletions PlatEMO/Algorithms/SparseEA/EnvironmentalSelection.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
function [Population,Dec,Mask,FrontNo,CrowdDis] = EnvironmentalSelection(Population,Dec,Mask,N)
% The environmental selection of SparseEA

%------------------------------- 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".
%--------------------------------------------------------------------------

%% Delete duplicated solutions
[~,uni] = unique(Population.objs,'rows');
Population = Population(uni);
Dec = Dec(uni,:);
Mask = Mask(uni,:);
N = min(N,length(Population));

%% Non-dominated sorting
[FrontNo,MaxFNo] = NDSort(Population.objs,Population.cons,N);
Next = FrontNo < MaxFNo;

%% Calculate the crowding distance of each solution
CrowdDis = CrowdingDistance(Population.objs,FrontNo);

%% Select the solutions in the last front based on their crowding distances
Last = find(FrontNo==MaxFNo);
[~,Rank] = sort(CrowdDis(Last),'descend');
Next(Last(Rank(1:N-sum(Next)))) = true;

%% Population for next generation
Population = Population(Next);
FrontNo = FrontNo(Next);
CrowdDis = CrowdDis(Next);
Dec = Dec(Next,:);
Mask = Mask(Next,:);
end
61 changes: 61 additions & 0 deletions PlatEMO/Algorithms/SparseEA/Operator.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
function [OffDec,OffMask] = Operator(ParentDec,ParentMask,Fitness,REAL)
% The operator of SparseEA

%------------------------------- 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
[N,D] = size(ParentDec);
Parent1Mask = ParentMask(1:N/2,:);
Parent2Mask = ParentMask(N/2+1:end,:);

%% Crossover for mask
OffMask = Parent1Mask;
for i = 1 : N/2
if rand < 0.5
index = find(Parent1Mask(i,:)&~Parent2Mask(i,:));
index = index(TS(-Fitness(index)));
OffMask(i,index) = 0;
else
index = find(~Parent1Mask(i,:)&Parent2Mask(i,:));
index = index(TS(Fitness(index)));
OffMask(i,index) = Parent2Mask(i,index);
end
end

%% Mutation for mask
for i = 1 : N/2
if rand < 0.5
index = find(OffMask(i,:));
index = index(TS(-Fitness(index)));
OffMask(i,index) = 0;
else
index = find(~OffMask(i,:));
index = index(TS(Fitness(index)));
OffMask(i,index) = 1;
end
end

%% Crossover and mutation for dec
if REAL
OffDec = GAhalf(ParentDec);
else
OffDec = ones(N/2,D);
end
end

function index = TS(Fitness)
% Binary tournament selection

if isempty(Fitness)
index = [];
else
index = TournamentSelection(2,1,Fitness);
end
end
58 changes: 58 additions & 0 deletions PlatEMO/Algorithms/SparseEA/SparseEA.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
function SparseEA(Global)
% <algorithm> <S>
% Evolutionary algorithm for sparse multi-objective optimization problems

%------------------------------- Reference --------------------------------
% Y. Tian, X. Zhang, C. Wang, and Y. Jin, An evolutionary algorithm for
% large-scale sparse multi-objective optimization problems, IEEE
% Transactions on Evolutionary Computation, 2019.
%------------------------------- 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".
%--------------------------------------------------------------------------

%% Population initialization
% Calculate the fitness of each decision variable
TDec = [];
TMask = [];
TempPop = [];
Fitness = zeros(1,Global.D);
REAL = ~strcmp(Global.encoding,'binary');
for i = 1 : 1+4*REAL
if REAL
Dec = unifrnd(repmat(Global.lower,Global.D,1),repmat(Global.upper,Global.D,1));
else
Dec = ones(Global.D,Global.D);
end
Mask = eye(Global.D);
Population = INDIVIDUAL(Dec.*Mask);
TDec = [TDec;Dec];
TMask = [TMask;Mask];
TempPop = [TempPop,Population];
Fitness = Fitness + NDSort([Population.objs,Population.cons],inf);
end
% Generate initial population
if REAL
Dec = unifrnd(repmat(Global.lower,Global.N,1),repmat(Global.upper,Global.N,1));
else
Dec = ones(Global.N,Global.D);
end
Mask = zeros(Global.N,Global.D);
for i = 1 : Global.N
Mask(i,TournamentSelection(2,ceil(rand*Global.D),Fitness)) = 1;
end
Population = INDIVIDUAL(Dec.*Mask);
[Population,Dec,Mask,FrontNo,CrowdDis] = EnvironmentalSelection([Population,TempPop],[Dec;TDec],[Mask;TMask],Global.N);

%% Optimization
while Global.NotTermination(Population)
MatingPool = TournamentSelection(2,2*Global.N,FrontNo,-CrowdDis);
[OffDec,OffMask] = Operator(Dec(MatingPool,:),Mask(MatingPool,:),Fitness,REAL);
Offspring = INDIVIDUAL(OffDec.*OffMask);
[Population,Dec,Mask,FrontNo,CrowdDis] = EnvironmentalSelection([Population,Offspring],[Dec;OffDec],[Mask;OffMask],Global.N);
end
end
4 changes: 2 additions & 2 deletions PlatEMO/GUI/Controls/newAxes.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ function draw(obj,Data,varargin)
if ~obj.viewFix
if M == 2
view(0,90);
xlabel('\itf\rm_1'); ylabel('\itf\rm_2');
xlabel('\it f\rm_1'); ylabel('\it f\rm_2');
elseif M == 3
view(135,30);
xlabel('\itf\rm_1'); ylabel('\itf\rm_2'); zlabel('\itf\rm_3');
xlabel('\it f\rm_1'); ylabel('\it f\rm_2'); zlabel('\it f\rm_3');
elseif M > 3
view(0,90);
xlabel('Dimension No.'); ylabel('Value');
Expand Down
2 changes: 1 addition & 1 deletion PlatEMO/GUI/Controls/newButtonT.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
end
obj@newButton(parent,pos,str,varargin{:});
obj.icon = icon;
tiplabel = uicontrol('Parent',obj.figure.handle,'Style','text','Units','pixels','Position',[0 0 1 1],'FontSize',10,'String',tip,'BackgroundColor',[1 1 .9]);
tiplabel = uicontrol('Parent',obj.figure.handle,'Style','text','Units','pixels','Position',[0 0 1 1],'FontSize',9,'String',tip,'BackgroundColor',[1 1 .9]);
obj.tip = uipanel('Parent',obj.figure.handle,'Units','pixels','Position',[tiplabel.Extent(1:3),16],'HighlightColor',[.5 .5 .5],'BorderType','line','Visible','off');
set(tiplabel,'Parent',obj.tip,'Position',[0 3 tiplabel.Extent(3) 13]);
obj.updateCData();
Expand Down
2 changes: 1 addition & 1 deletion PlatEMO/GUI/Modules/GUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
% Read the function lists
obj.readList();
% Create the figure
obj.figure = newFigure([0 0 1200 650],'PlatEMO v2.0');
obj.figure = newFigure([0 0 1200 650],'PlatEMO v2.1');
% Create the menu
obj.menu = newTab(obj.figure,[0 551 1202 100,1 1 0 1],{'Modules','Help'});
obj.figure.busy = false;
Expand Down
2 changes: 1 addition & 1 deletion PlatEMO/GUI/Modules/module_experiment.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
obj.control.showButton = newPopmenu3(obj.control.tableToolBar,[681 1 105 25,0 1 1 0],[{obj.GUI.icons.runTimes,[],obj.GUI.icons.runtime,[]},cell(1,length(obj.GUI.metList{1,2})+length(obj.GUI.metList{2,2}))],...
[{'Run times','','runtime',''},obj.GUI.metList{2,2}',obj.GUI.metList{1,2}'],'callback',@(~,~)obj.flushTable);
obj.control.table = newTable(panel,[24 90 788 390,1 1 1 1],'Fontname','Times New Roman','Fontsize',9,'ButtonDownFcn',@obj.cb_table);
obj.control.tableMenu = newMenu(panel,[1 1 245 20]);
obj.control.tableMenu = newMenu(panel,[1 1 250 20]);
obj.control.tableMenu.add(obj.GUI.icons.showPF,'PF with median metric value','callback',@(~,~)obj.cb_tableMenu(1));
obj.control.tableMenu.add([],'PF with best metric value','callback',@(~,~)obj.cb_tableMenu(2));
obj.control.tableMenu.add([],'');
Expand Down
2 changes: 1 addition & 1 deletion PlatEMO/GUI/Modules/module_test.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
obj.control.figureMenu = newMenu(panel,[1 1 155 20]);
obj.control.figureMenu.add([],'Show in new figure','callback',@obj.cb_figureMenu);
newTip(obj.control.axesToolBar,[1 1 12 25,1 0 1 0],x,'callback',@obj.cb_figureMenuButton);
obj.control.showButton = newPopmenu3(obj.control.axesToolBar,[453 1 105 25,0 1 1 0],[{obj.GUI.icons.showPF,obj.GUI.icons.showPS,[],obj.GUI.icons.showTPF,[]},cell(1,length(obj.GUI.metList{1,2})+length(obj.GUI.metList{2,2}))],...
obj.control.showButton = newPopmenu3(obj.control.axesToolBar,[443 1 115 25,0 1 1 0],[{obj.GUI.icons.showPF,obj.GUI.icons.showPS,[],obj.GUI.icons.showTPF,[]},cell(1,length(obj.GUI.metList{1,2})+length(obj.GUI.metList{2,2}))],...
[{'Pareto Front','Pareto Set','','True PF',''},obj.GUI.metList{2,2}',obj.GUI.metList{1,2}'],'callback',@obj.cb_showbutton);
obj.control.axes = newAxes(panel,[82 108 452 360,1 1 1 1]);
obj.control.playbar = newPlay(panel,[20 32 570 27,1 1 1 0],'callback',@obj.cb_playbar);
Expand Down
2 changes: 1 addition & 1 deletion PlatEMO/Metrics/CPF.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function Score = CPF(PopObj,PF)
% <metric> <max>
% Coverage of Pareto front
% Coverage over Pareto front

%------------------------------- Reference --------------------------------
% Y. Tian, R. Cheng, X. Zhang, M. Li, and Y. Jin, Diversity assessment of
Expand Down
Binary file added PlatEMO/Problems/Sparse MOPs/Dataset_CN.mat
Binary file not shown.
Binary file added PlatEMO/Problems/Sparse MOPs/Dataset_FS_NN.mat
Binary file not shown.
57 changes: 57 additions & 0 deletions PlatEMO/Problems/Sparse MOPs/SMOP1.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
classdef SMOP1 < PROBLEM
% <problem> <Sparse MOP>
% Benchmark MOP with sparse Pareto optimal solutions
% theta --- 0.1 --- Sparsity of the Pareto set

%------------------------------- Reference --------------------------------
% Y. Tian, X. Zhang, C. Wang, and Y. Jin, An evolutionary algorithm for
% large-scale sparse multi-objective optimization problems, IEEE
% Transactions on Evolutionary Computation, 2019.
%------------------------------- 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".
%--------------------------------------------------------------------------

properties(Access = private)
theta = 0.1; % Sparsity of the Pareto set
end
methods
%% Initialization
function obj = SMOP1()
obj.theta = obj.Global.ParameterSet(0.1);
if isempty(obj.Global.M)
obj.Global.M = 2;
end
if isempty(obj.Global.D)
obj.Global.D = 100;
end
obj.Global.lower = [zeros(1,obj.Global.M-1)+0,zeros(1,obj.Global.D-obj.Global.M+1)-1];
obj.Global.upper = [zeros(1,obj.Global.M-1)+1,zeros(1,obj.Global.D-obj.Global.M+1)+2];
obj.Global.encoding = 'real';
end
%% Calculate objective values
function PopObj = CalObj(obj,X)
[N,D] = size(X);
M = obj.Global.M;
K = ceil(obj.theta*(D-M+1));
g = sum(g1(X(:,M:M+K-1),pi/3),2) + sum(g2(X(:,M+K:end),0),2);
PopObj = repmat(1+g/(D-M+1),1,M).*fliplr(cumprod([ones(N,1),X(:,1:M-1)],2)).*[ones(N,1),1-X(:,M-1:-1:1)];
end
%% Sample reference points on Pareto front
function P = PF(obj,N)
P = UniformPoint(N,obj.Global.M);
end
end
end

function g = g1(x,t)
g = (x-t).^2;
end

function g = g2(x,t)
g = 2*(x-t).^2 + sin(2*pi*(x-t)).^2;
end
57 changes: 57 additions & 0 deletions PlatEMO/Problems/Sparse MOPs/SMOP2.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
classdef SMOP2 < PROBLEM
% <problem> <Sparse MOP>
% Benchmark MOP with sparse Pareto optimal solutions
% theta --- 0.1 --- Sparsity of the Pareto set

%------------------------------- Reference --------------------------------
% Y. Tian, X. Zhang, C. Wang, and Y. Jin, An evolutionary algorithm for
% large-scale sparse multi-objective optimization problems, IEEE
% Transactions on Evolutionary Computation, 2019.
%------------------------------- 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".
%--------------------------------------------------------------------------

properties(Access = private)
theta = 0.1; % Sparsity of the Pareto set
end
methods
%% Initialization
function obj = SMOP2()
obj.theta = obj.Global.ParameterSet(0.1);
if isempty(obj.Global.M)
obj.Global.M = 2;
end
if isempty(obj.Global.D)
obj.Global.D = 100;
end
obj.Global.lower = [zeros(1,obj.Global.M-1)+0,zeros(1,obj.Global.D-obj.Global.M+1)-1];
obj.Global.upper = [zeros(1,obj.Global.M-1)+1,zeros(1,obj.Global.D-obj.Global.M+1)+2];
obj.Global.encoding = 'real';
end
%% Calculate objective values
function PopObj = CalObj(obj,X)
[N,D] = size(X);
M = obj.Global.M;
K = ceil(obj.theta*(D-M+1));
g = sum(g2(X(:,M:M+K-1),pi/3),2) + sum(g3(X(:,M+K:end),0),2);
PopObj = repmat(1+g/(D-M+1),1,M).*fliplr(cumprod([ones(N,1),X(:,1:M-1)],2)).*[ones(N,1),1-X(:,M-1:-1:1)];
end
%% Sample reference points on Pareto front
function P = PF(obj,N)
P = UniformPoint(N,obj.Global.M);
end
end
end

function g = g2(x,t)
g = 2*(x-t).^2 + sin(2*pi*(x-t)).^2;
end

function g = g3(x,t)
g = 4-(x-t)-4./exp(100*(x-t).^2);
end
Loading

0 comments on commit 74b11fd

Please sign in to comment.