diff --git a/PlatEMO/Algorithms/MOEA-D-DE/MOEADDE.m b/PlatEMO/Algorithms/MOEA-D-DE/MOEADDE.m index 7626a0815..096bb15cc 100644 --- a/PlatEMO/Algorithms/MOEA-D-DE/MOEADDE.m +++ b/PlatEMO/Algorithms/MOEA-D-DE/MOEADDE.m @@ -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 diff --git a/PlatEMO/Algorithms/MOEA-D-DRA/MOEADDRA.m b/PlatEMO/Algorithms/MOEA-D-DRA/MOEADDRA.m index 835891fa8..a92d30bfa 100644 --- a/PlatEMO/Algorithms/MOEA-D-DRA/MOEADDRA.m +++ b/PlatEMO/Algorithms/MOEA-D-DRA/MOEADDRA.m @@ -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 diff --git a/PlatEMO/Algorithms/SparseEA/EnvironmentalSelection.m b/PlatEMO/Algorithms/SparseEA/EnvironmentalSelection.m new file mode 100644 index 000000000..f42b8b2d8 --- /dev/null +++ b/PlatEMO/Algorithms/SparseEA/EnvironmentalSelection.m @@ -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 \ No newline at end of file diff --git a/PlatEMO/Algorithms/SparseEA/Operator.m b/PlatEMO/Algorithms/SparseEA/Operator.m new file mode 100644 index 000000000..20ffcf9c3 --- /dev/null +++ b/PlatEMO/Algorithms/SparseEA/Operator.m @@ -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 \ No newline at end of file diff --git a/PlatEMO/Algorithms/SparseEA/SparseEA.m b/PlatEMO/Algorithms/SparseEA/SparseEA.m new file mode 100644 index 000000000..3d91d9683 --- /dev/null +++ b/PlatEMO/Algorithms/SparseEA/SparseEA.m @@ -0,0 +1,58 @@ +function SparseEA(Global) +% +% 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 \ No newline at end of file diff --git a/PlatEMO/GUI/Controls/newAxes.m b/PlatEMO/GUI/Controls/newAxes.m index fa06ad918..c8048c377 100644 --- a/PlatEMO/GUI/Controls/newAxes.m +++ b/PlatEMO/GUI/Controls/newAxes.m @@ -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'); diff --git a/PlatEMO/GUI/Controls/newButtonT.m b/PlatEMO/GUI/Controls/newButtonT.m index e6371a5b9..0a3ec7cfd 100644 --- a/PlatEMO/GUI/Controls/newButtonT.m +++ b/PlatEMO/GUI/Controls/newButtonT.m @@ -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(); diff --git a/PlatEMO/GUI/Modules/GUI.m b/PlatEMO/GUI/Modules/GUI.m index 981dddf83..3d0c6cdce 100644 --- a/PlatEMO/GUI/Modules/GUI.m +++ b/PlatEMO/GUI/Modules/GUI.m @@ -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; diff --git a/PlatEMO/GUI/Modules/module_experiment.m b/PlatEMO/GUI/Modules/module_experiment.m index aed6cd38b..de20e942f 100644 --- a/PlatEMO/GUI/Modules/module_experiment.m +++ b/PlatEMO/GUI/Modules/module_experiment.m @@ -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([],''); diff --git a/PlatEMO/GUI/Modules/module_test.m b/PlatEMO/GUI/Modules/module_test.m index e10f1f479..cd9b322c1 100644 --- a/PlatEMO/GUI/Modules/module_test.m +++ b/PlatEMO/GUI/Modules/module_test.m @@ -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); diff --git a/PlatEMO/Metrics/CPF.m b/PlatEMO/Metrics/CPF.m index 02929acdb..deb4f9ee0 100644 --- a/PlatEMO/Metrics/CPF.m +++ b/PlatEMO/Metrics/CPF.m @@ -1,6 +1,6 @@ function Score = CPF(PopObj,PF) % -% Coverage of Pareto front +% Coverage over Pareto front %------------------------------- Reference -------------------------------- % Y. Tian, R. Cheng, X. Zhang, M. Li, and Y. Jin, Diversity assessment of diff --git a/PlatEMO/Problems/Sparse MOPs/Dataset_CN.mat b/PlatEMO/Problems/Sparse MOPs/Dataset_CN.mat new file mode 100644 index 000000000..e2d4210a8 Binary files /dev/null and b/PlatEMO/Problems/Sparse MOPs/Dataset_CN.mat differ diff --git a/PlatEMO/Problems/Sparse MOPs/Dataset_FS_NN.mat b/PlatEMO/Problems/Sparse MOPs/Dataset_FS_NN.mat new file mode 100644 index 000000000..c67a0e4d7 Binary files /dev/null and b/PlatEMO/Problems/Sparse MOPs/Dataset_FS_NN.mat differ diff --git a/PlatEMO/Problems/Sparse MOPs/SMOP1.m b/PlatEMO/Problems/Sparse MOPs/SMOP1.m new file mode 100644 index 000000000..48e451928 --- /dev/null +++ b/PlatEMO/Problems/Sparse MOPs/SMOP1.m @@ -0,0 +1,57 @@ +classdef SMOP1 < PROBLEM +% +% 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 \ No newline at end of file diff --git a/PlatEMO/Problems/Sparse MOPs/SMOP2.m b/PlatEMO/Problems/Sparse MOPs/SMOP2.m new file mode 100644 index 000000000..8dc8640c4 --- /dev/null +++ b/PlatEMO/Problems/Sparse MOPs/SMOP2.m @@ -0,0 +1,57 @@ +classdef SMOP2 < PROBLEM +% +% 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 \ No newline at end of file diff --git a/PlatEMO/Problems/Sparse MOPs/SMOP3.m b/PlatEMO/Problems/Sparse MOPs/SMOP3.m new file mode 100644 index 000000000..0c2b1c0db --- /dev/null +++ b/PlatEMO/Problems/Sparse MOPs/SMOP3.m @@ -0,0 +1,57 @@ +classdef SMOP3 < PROBLEM +% +% 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 = SMOP3() + 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); + for i = 1 : ceil((D-M-K+1)/10) + temp = 50 - sum(g1(X(:,M+K+(i-1)*10:min(M+K+i*10-1,end)),0),2); + g(temp<50) = g(temp<50) + temp(temp<50); + end + 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 \ No newline at end of file diff --git a/PlatEMO/Problems/Sparse MOPs/SMOP4.m b/PlatEMO/Problems/Sparse MOPs/SMOP4.m new file mode 100644 index 000000000..86dcf5160 --- /dev/null +++ b/PlatEMO/Problems/Sparse MOPs/SMOP4.m @@ -0,0 +1,64 @@ +classdef SMOP4 < PROBLEM +% +% 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 = SMOP4() + 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 = sort(g3(X(:,M:end),0),2); + g = sum(g(:,1:D-M-K+1),2); + PopObj = repmat(1+g/(D-M+1),1,M).*fliplr(cumprod([ones(N,1),1-cos(X(:,1:M-1)*pi/2)],2)).*[ones(N,1),1-sin(X(:,M-1:-1:1)*pi/2)]; + end + %% Sample reference points on Pareto front + function P = PF(obj,N) + M = obj.Global.M; + P = UniformPoint(N,M); + c = ones(size(P,1),M); + for i = 1 : size(P,1) + for j = 2 : M + temp = P(i,j)/P(i,1)*prod(1-c(i,M-j+2:M-1)); + c(i,M-j+1) = (temp^2-temp+sqrt(2*temp))/(temp^2+1); + end + end + x = acos(c)*2/pi; + P = fliplr(cumprod([ones(size(x,1),1),1-cos(x(:,1:end-1)*pi/2)],2)).*[ones(size(x,1),1),1-sin(x(:,end-1:-1:1)*pi/2)]; + end + end +end + +function g = g3(x,t) + g = 4-(x-t)-4./exp(100*(x-t).^2); +end \ No newline at end of file diff --git a/PlatEMO/Problems/Sparse MOPs/SMOP5.m b/PlatEMO/Problems/Sparse MOPs/SMOP5.m new file mode 100644 index 000000000..d237bfb3b --- /dev/null +++ b/PlatEMO/Problems/Sparse MOPs/SMOP5.m @@ -0,0 +1,67 @@ +classdef SMOP5 < PROBLEM +% +% 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 = SMOP5() + 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:end),pi/3).*g2(X(:,M:end),0),2) + abs(K-sum(X(:,M:end)~=0,2)); + PopObj = repmat(1+g/(D-M+1),1,M).*fliplr(cumprod([ones(N,1),1-cos(X(:,1:M-1)*pi/2)],2)).*[ones(N,1),1-sin(X(:,M-1:-1:1)*pi/2)]; + end + %% Sample reference points on Pareto front + function P = PF(obj,N) + M = obj.Global.M; + P = UniformPoint(N,M); + c = ones(size(P,1),M); + for i = 1 : size(P,1) + for j = 2 : M + temp = P(i,j)/P(i,1)*prod(1-c(i,M-j+2:M-1)); + c(i,M-j+1) = (temp^2-temp+sqrt(2*temp))/(temp^2+1); + end + end + x = acos(c)*2/pi; + P = fliplr(cumprod([ones(size(x,1),1),1-cos(x(:,1:end-1)*pi/2)],2)).*[ones(size(x,1),1),1-sin(x(:,end-1:-1:1)*pi/2)]; + 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 \ No newline at end of file diff --git a/PlatEMO/Problems/Sparse MOPs/SMOP6.m b/PlatEMO/Problems/Sparse MOPs/SMOP6.m new file mode 100644 index 000000000..64dd9080a --- /dev/null +++ b/PlatEMO/Problems/Sparse MOPs/SMOP6.m @@ -0,0 +1,71 @@ +classdef SMOP6 < PROBLEM +% +% 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 = SMOP6() + 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 = g4(X(:,M:end),repmat(linspace(0,1,D-M+1),N,1)); + [g,rank] = sort(g,2); + temp = false(size(rank)); + for i = 1 : size(rank,1) + temp(i,X(i,M-1+rank(i,:))==0) = true; + end + temp(:,1:K) = false; + g(temp) = 0; + g = sum(g,2); + PopObj = repmat(1+g/(D-M+1),1,M).*fliplr(cumprod([ones(N,1),1-cos(X(:,1:M-1)*pi/2)],2)).*[ones(N,1),1-sin(X(:,M-1:-1:1)*pi/2)]; + end + %% Sample reference points on Pareto front + function P = PF(obj,N) + M = obj.Global.M; + P = UniformPoint(N,M); + c = ones(size(P,1),M); + for i = 1 : size(P,1) + for j = 2 : M + temp = P(i,j)/P(i,1)*prod(1-c(i,M-j+2:M-1)); + c(i,M-j+1) = (temp^2-temp+sqrt(2*temp))/(temp^2+1); + end + end + x = acos(c)*2/pi; + P = fliplr(cumprod([ones(size(x,1),1),1-cos(x(:,1:end-1)*pi/2)],2)).*[ones(size(x,1),1),1-sin(x(:,end-1:-1:1)*pi/2)]; + end + end +end + +function g = g4(x,t) + g = (x-pi/3).^2 + t.*sin(6*pi*(x-pi/3)).^2; +end \ No newline at end of file diff --git a/PlatEMO/Problems/Sparse MOPs/SMOP7.m b/PlatEMO/Problems/Sparse MOPs/SMOP7.m new file mode 100644 index 000000000..f987b1920 --- /dev/null +++ b/PlatEMO/Problems/Sparse MOPs/SMOP7.m @@ -0,0 +1,54 @@ +classdef SMOP7 < PROBLEM +% +% 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 = SMOP7() + 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(g2(X(:,M+K:end),X(:,[M+K+1:end,M+K])*0.9),2); + PopObj = repmat(1+g/(D-M+1),1,M).*fliplr(cumprod([ones(N,1),cos(X(:,1:M-1)*pi/2)],2)).*[ones(N,1),sin(X(:,M-1:-1:1)*pi/2)]; + end + %% Sample reference points on Pareto front + function P = PF(obj,N) + P = UniformPoint(N,obj.Global.M); + P = P./repmat(sqrt(sum(P.^2,2)),1,obj.Global.M); + end + end +end + +function g = g2(x,t) + g = 2*(x-t).^2 + sin(2*pi*(x-t)).^2; +end \ No newline at end of file diff --git a/PlatEMO/Problems/Sparse MOPs/SMOP8.m b/PlatEMO/Problems/Sparse MOPs/SMOP8.m new file mode 100644 index 000000000..cacc1f221 --- /dev/null +++ b/PlatEMO/Problems/Sparse MOPs/SMOP8.m @@ -0,0 +1,54 @@ +classdef SMOP8 < PROBLEM +% +% 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 = SMOP8() + 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(g3(X(:,M:M+K-1),mod(X(:,M+1:M+K)+pi,2)),2) + sum(g3(X(:,M+K:end-1),X(:,M+K+1:end)*0.9),2); + PopObj = repmat(1+g/(D-M+1),1,M).*fliplr(cumprod([ones(N,1),cos(X(:,1:M-1)*pi/2)],2)).*[ones(N,1),sin(X(:,M-1:-1:1)*pi/2)]; + end + %% Sample reference points on Pareto front + function P = PF(obj,N) + P = UniformPoint(N,obj.Global.M); + P = P./repmat(sqrt(sum(P.^2,2)),1,obj.Global.M); + end + end +end + +function g = g3(x,t) + g = 4-(x-t)-4./exp(100*(x-t).^2); +end \ No newline at end of file diff --git a/PlatEMO/Problems/Sparse MOPs/Sparse_CN.m b/PlatEMO/Problems/Sparse MOPs/Sparse_CN.m new file mode 100644 index 000000000..e261bfe5d --- /dev/null +++ b/PlatEMO/Problems/Sparse MOPs/Sparse_CN.m @@ -0,0 +1,74 @@ +classdef Sparse_CN < PROBLEM +% +% The critical node detection problem +% dataNo --- 1 --- Number of dataset + +%------------------------------- 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". +%-------------------------------------------------------------------------- + +% The datasets are taken from the Pajek datasets in +% http://vlado.fmf.uni-lj.si/pub/networks/data/default.htm +% No. Name Nodes Edges +% 1 Movies 102 192 +% 2 GD99 234 154 +% 3 GD01 311 640 +% 4 GD97 452 460 + + properties(Access = private) + G; % Adjacency matrix of the graph + end + methods + %% Initialization + function obj = Sparse_CN() + % Load data + dataNo = obj.Global.ParameterSet(1); + str = {'Movies','GD99','GD01','GD97'}; + CallStack = dbstack('-completenames'); + load(fullfile(fileparts(CallStack(1).file),'Dataset_CN.mat'),'Dataset'); + obj.G = Dataset.(str{dataNo}); + % Parameter setting + obj.Global.M = 2; + obj.Global.D = length(obj.G); + obj.Global.encoding = 'binary'; + end + %% Calculate objective values + function PopObj = CalObj(obj,PopDec) + PopDec = logical(PopDec); + PopObj = zeros(size(PopDec,1),2); + for i = 1 : size(PopDec,1) + PopObj(i,1) = mean(PopDec(i,:)); + PopObj(i,2) = PairwiseConnectivity(obj.G(~PopDec(i,:),~PopDec(i,:))); + end + PopObj(:,2) = PopObj(:,2)/PairwiseConnectivity(obj.G); + end + end +end + +function f = PairwiseConnectivity(G) + f = 0; + remain = true(1,length(G)); + while any(remain) + c = false(1,length(G)); + c(find(remain,1)) = true; + while true + c1 = any(G(c,:),1) & remain; + if all(c==c1) + break; + else + c = c1; + end + end + remain = remain & ~c; + f = f + sum(c)*(sum(c)-1)/2; + end +end \ No newline at end of file diff --git a/PlatEMO/Problems/Sparse MOPs/Sparse_FS.m b/PlatEMO/Problems/Sparse MOPs/Sparse_FS.m new file mode 100644 index 000000000..481c9b5d5 --- /dev/null +++ b/PlatEMO/Problems/Sparse MOPs/Sparse_FS.m @@ -0,0 +1,81 @@ +classdef Sparse_FS < PROBLEM +% +% The feature selection problem +% dataNo --- 1 --- Number of dataset + +%------------------------------- 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". +%-------------------------------------------------------------------------- + +% The datasets are taken from the UCI machine learning repository in +% http://archive.ics.uci.edu/ml/index.php +% No. Name Samples Features Classes +% 1 Wine 178 13 3 +% 2 Statlog_Australian 690 14 2 +% 3 Climate 540 18 2 +% 4 Parkinsons 195 22 2 +% 5 Statlog_German 1000 24 2 +% 6 Breast_cancer_Wisconsin_Diagnostic 569 30 2 +% 7 Ionosphere 351 34 2 +% 8 SPECTF_Heart 267 44 2 +% 9 Lung_cancer 32 56 3 +% 10 Connectionist_bench_Sonar 208 60 2 +% 11 Libras_movement 360 90 15 +% 12 Hill_Valley 606 100 2 +% 13 MUSK1 476 166 2 +% 14 Semeion_handwritten_digit 1593 256 10 +% 15 LSVT_voice_rehabilitation 126 310 2 +% 16 Madelon 2600 500 2 +% 17 ISOLET 1557 617 26 +% 18 Multiple_features 2000 649 10 +% 19 CNAE9 1080 857 9 + + properties(Access = private) + TrainIn; % Input of training set + TrainOut; % Output of training set + ValidIn; % Input of validation set + ValidOut; % Output of validation set + end + methods + %% Initialization + function obj = Sparse_FS() + % Load data + dataNo = obj.Global.ParameterSet(1); + str = {'Wine','Statlog_Australian','Climate','Parkinsons','Statlog_German','Breast_cancer_Wisconsin_Diagnostic',... + 'Ionosphere','SPECTF_Heart','Lung_cancer','Connectionist_bench_Sonar','Libras_movement','Hill_Valley',... + 'MUSK1','Semeion_handwritten_digit','LSVT_voice_rehabilitation','Madelon','ISOLET','Multiple_features','CNAE9'}; + CallStack = dbstack('-completenames'); + load(fullfile(fileparts(CallStack(1).file),'Dataset_FS_NN.mat'),'Dataset'); + Data = Dataset.(str{dataNo}); + Fmin = min(Data(:,1:end-1),[],1); + Fmax = max(Data(:,1:end-1),[],1); + Data(:,1:end-1) = (Data(:,1:end-1)-repmat(Fmin,size(Data,1),1))./repmat(Fmax-Fmin,size(Data,1),1); + obj.TrainIn = Data(1:ceil(end*0.8),1:end-1); + obj.TrainOut = Data(1:ceil(end*0.8),end); + obj.ValidIn = Data(ceil(end*0.8)+1:end,1:end-1); + obj.ValidOut = Data(ceil(end*0.8)+1:end,end); + % Parameter setting + obj.Global.M = 2; + obj.Global.D = size(obj.TrainIn,2); + obj.Global.encoding = 'binary'; + end + %% Calculate objective values + function PopObj = CalObj(obj,PopDec) + PopDec = logical(PopDec); + PopObj = zeros(size(PopDec,1),2); + Category = unique(obj.TrainOut); + for i = 1 : size(PopObj,1) + [~,Rank] = sort(pdist2(obj.ValidIn(:,PopDec(i,:)),obj.TrainIn(:,PopDec(i,:))),2); + [~,Out] = max(hist(obj.TrainOut(Rank(:,1:3))',Category),[],1); + Out = Category(Out); + PopObj(i,1) = mean(PopDec(i,:)); + PopObj(i,2) = mean(Out~=obj.ValidOut); + end + end + end +end \ No newline at end of file diff --git a/PlatEMO/Problems/Sparse MOPs/Sparse_NN.m b/PlatEMO/Problems/Sparse MOPs/Sparse_NN.m new file mode 100644 index 000000000..ebbfed61c --- /dev/null +++ b/PlatEMO/Problems/Sparse MOPs/Sparse_NN.m @@ -0,0 +1,134 @@ +classdef Sparse_NN < PROBLEM +% +% The neural network training problem (only for bi-category classification) +% dataNo --- 1 --- Number of dataset +% nHidden --- 20 --- Size of hidden layer + +%------------------------------- 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". +%-------------------------------------------------------------------------- + +% The datasets are taken from the UCI machine learning repository in +% http://archive.ics.uci.edu/ml/index.php +% No. Name Samples Features Classes +% 1 Wine 178 13 3 +% 2 Statlog_Australian 690 14 2 +% 3 Climate 540 18 2 +% 4 Parkinsons 195 22 2 +% 5 Statlog_German 1000 24 2 +% 6 Breast_cancer_Wisconsin_Diagnostic 569 30 2 +% 7 Ionosphere 351 34 2 +% 8 SPECTF_Heart 267 44 2 +% 9 Lung_cancer 32 56 3 +% 10 Connectionist_bench_Sonar 208 60 2 +% 11 Libras_movement 360 90 15 +% 12 Hill_Valley 606 100 2 +% 13 MUSK1 476 166 2 +% 14 Semeion_handwritten_digit 1593 256 10 +% 15 LSVT_voice_rehabilitation 126 310 2 +% 16 Madelon 2600 500 2 +% 17 ISOLET 1557 617 26 +% 18 Multiple_features 2000 649 10 +% 19 CNAE9 1080 857 9 + + properties(Access = private) + TrainIn; % Input of training set + TrainOut; % Output of training set + TestIn; % Input of validation set + TestOut; % Output of validation set + nHidden; % Size of hidden layer + end + methods + function obj = Sparse_NN() + % Load data + [dataNo,obj.nHidden] = obj.Global.ParameterSet(1,20); + str = {'Wine','Statlog_Australian','Climate','Parkinsons','Statlog_German','Breast_cancer_Wisconsin_Diagnostic',... + 'Ionosphere','SPECTF_Heart','Lung_cancer','Connectionist_bench_Sonar','Libras_movement','Hill_Valley',... + 'MUSK1','Semeion_handwritten_digit','LSVT_voice_rehabilitation','Madelon','ISOLET','Multiple_features','CNAE9'}; + CallStack = dbstack('-completenames'); + load(fullfile(fileparts(CallStack(1).file),'Dataset_FS_NN.mat'),'Dataset'); + Data = Dataset.(str{dataNo}); + Mean = mean(Data(:,1:end-1),1); + Std = std(Data(:,1:end-1),[],1); + Data(:,1:end-1) = (Data(:,1:end-1)-repmat(Mean,size(Data,1),1))./repmat(Std,size(Data,1),1); + Data(:,end) = Data(:,end) == Data(1,end); % Only for bi-category classification + obj.TrainIn = Data(1:ceil(end*0.8),1:end-1); + obj.TrainOut = Data(1:ceil(end*0.8),end); + obj.TestIn = Data(ceil(end*0.8)+1:end,1:end-1); + obj.TestOut = Data(ceil(end*0.8)+1:end,end); + % Parameter setting + obj.Global.M = 2; + obj.Global.D = (size(obj.TrainIn,2)+1)*obj.nHidden + (obj.nHidden+1)*size(obj.TrainOut,2); + obj.Global.lower = zeros(1,obj.Global.D) - 1; + obj.Global.upper = zeros(1,obj.Global.D) + 1; + obj.Global.encoding = 'real'; + end + %% Generate initial population + function PopDec = Init(obj,N) + PopDec = (rand(N,obj.Global.D)-0.5)*2.*randi([0 1],N,obj.Global.D); + end + %% Fine-tune solutions + function PopDec = CalDec(obj,PopDec) + for i = 1 : size(PopDec,1) + W1 = reshape(PopDec(i,1:(size(obj.TrainIn,2)+1)*obj.nHidden),size(obj.TrainIn,2)+1,obj.nHidden); + W2 = reshape(PopDec(i,(size(obj.TrainIn,2)+1)*obj.nHidden+1:end),obj.nHidden+1,size(obj.TrainOut,2)); + [W1,W2] = Train(obj.TrainIn,obj.TrainOut,W1,W2,1); + PopDec(i,:) = [W1(:)',W2(:)']; + end + end + %% Calculate objective values + function PopObj = CalObj(obj,PopDec) + PopObj = zeros(size(PopDec,1),2); + for i = 1 : size(PopDec,1) + W1 = reshape(PopDec(i,1:(size(obj.TrainIn,2)+1)*obj.nHidden),size(obj.TrainIn,2)+1,obj.nHidden); + W2 = reshape(PopDec(i,(size(obj.TrainIn,2)+1)*obj.nHidden+1:end),obj.nHidden+1,size(obj.TrainOut,2)); + Z = Predict(obj.TrainIn,W1,W2); + PopObj(i,1) = mean(PopDec(i,:)~=0); + PopObj(i,2) = mean(round(Z)~=obj.TrainOut); + end + end + %% Draw special figure + function Draw(obj,PopDec) + PopObj = zeros(size(PopDec,1),2); + for i = 1 : size(PopDec,1) + W1 = reshape(PopDec(i,1:(size(obj.TestIn,2)+1)*obj.nHidden),size(obj.TestIn,2)+1,obj.nHidden); + W2 = reshape(PopDec(i,(size(obj.TestIn,2)+1)*obj.nHidden+1:end),obj.nHidden+1,size(obj.TestOut,2)); + Z = Predict(obj.TestIn,W1,W2); + PopObj(i,1) = mean(PopDec(i,:)~=0); + PopObj(i,2) = mean(round(Z)~=obj.TestOut); + end + cla; Draw(PopObj); + xlabel('Complexity'); ylabel('Test error'); + end + end +end + +function [W1,W2] = Train(X,T,W1,W2,nEpoch) + for epoch = 1 : nEpoch + [Z,Y] = Predict(X,W1,W2); + P = (Z-T).*Z.*(1-Z); + Q = P*W2(2:end,:)'.*(1-Y.^2); + D1 = 0; + D2 = 0; + for i = 1 : size(X,1) + D2 = D2 + [0,Y(i,:)]'*P(i,:); + D1 = D1 + [0,X(i,:)]'*Q(i,:); + end + W1 = W1 - D1/size(X,1); + W2 = W2 - D2/size(X,1); + end +end + +function [Z,Y] = Predict(X,W1,W2) + Y = 1 - 2./(1+exp(2*[zeros(size(X,1),1),X]*W1)); + Z = 1./(1+exp(-[zeros(size(Y,1),1),Y]*W2)); +end \ No newline at end of file diff --git a/PlatEMO/Problems/Sparse MOPs/Sparse_PM.m b/PlatEMO/Problems/Sparse MOPs/Sparse_PM.m new file mode 100644 index 000000000..7304efac6 --- /dev/null +++ b/PlatEMO/Problems/Sparse MOPs/Sparse_PM.m @@ -0,0 +1,85 @@ +classdef Sparse_PM < PROBLEM +% +% The pattern mining problem +% numTran --- 10000 --- Number of transactions +% lenTran --- 50 --- Average length of transactions +% numPa --- 100 --- Number of patterns +% lenPa --- 5 --- Average length of patterns +% numItem --- 100 --- Number of items (decision variables) + +%------------------------------- 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) + Data; % Transaction dataset + end + methods + %% Initialization + function obj = Sparse_PM() + % Parameter setting + [numTran,lenTran,numPa,lenPa,numItem] = obj.Global.ParameterSet(10000,50,100,5,100); + obj.Global.M = 2; + obj.Global.D = numItem; + obj.Global.encoding = 'binary'; + % Randomly generate transaction dataset + fileName = fullfile(fileparts(mfilename('fullpath')),sprintf('Dataset_PM-D%d-T%d-L%d-I%d-N%d.mat',numTran,lenTran,numPa,lenPa,numItem)); + if exist(fileName,'file') == 2 + load(fileName,'Data'); + else + % Generate patterns + PaSet = cell(1,numPa); + RAND1 = min(numItem,max(1,random('Poisson',lenPa,1,numPa))); % Length of each pattern + RAND2 = min(1,max(0,random('Exponential',0.5,1,numPa))); % Fraction of items in each pattern chosen from previous pattern + PaSet{1} = randperm(numItem,RAND1(1)); + for i = 2 : numPa + PaSet{i} = [PaSet{i-1}(randperm(end,min(end,round(RAND2(i)*RAND1(i))))),... + randperm(numItem,round((1-RAND2(i))*RAND1(i)))]; + end + % Generate transactions + RAND3 = max(0,random('Exponential',1,1,numPa)); % Probability that each pattern will be picked + RAND3 = cumsum(RAND3)./sum(RAND3); + RAND4 = random('Normal',0.5,0.1,1,numPa); % Corruption level of each pattern + Data = false(numTran,numItem); + RAND5 = min(min(numItem,length(unique(cat(2,PaSet{:})))),max(1,random('Poisson',lenTran,1,numTran))); % Length of each transaction + Data = false(numTran,numItem); + for i = 1 : numTran + while sum(Data(i,:)) < RAND5(i) + current = find(rand<=RAND3,1); + Data(i,PaSet{current}(rand(1,end)>RAND4(current))) = true; + end + end + save(fileName,'Data'); + end + obj.Data = Data; + end + %% Generate initial population + function PopDec = Init(obj,N) + PopDec = rand(N,obj.Global.D) < 20/obj.Global.D; + end + %% Calculate objective values + function PopObj = CalObj(obj,PopDec) + PopDec = logical(PopDec); + PopObj = zeros(size(PopDec,1),2); + for i = 1 : size(PopDec,1) + x = PopDec(i,:); + Tx = all(obj.Data(:,x),2); + if ~any(Tx) + PopObj(i,:) = 1; + else + PopObj(i,1) = 1 - mean(Tx); + PopObj(i,2) = 1 - mean(sum(x)./sum(obj.Data(Tx,:),2)); + end + end + end + end +end \ No newline at end of file diff --git a/PlatEMO/Public/Draw.m b/PlatEMO/Public/Draw.m index 6334b1667..f67104bdb 100644 --- a/PlatEMO/Public/Draw.m +++ b/PlatEMO/Public/Draw.m @@ -50,12 +50,12 @@ function Draw(Data,varargin) set(gca,'NextPlot','add','Box','on','Fontname','Times New Roman','FontSize',Size(4)); if M == 2 plot(Data(:,1),Data(:,2),varargin{:}); - xlabel('\itf\rm_1'); ylabel('\itf\rm_2'); + xlabel('\it f\rm_1'); ylabel('\it f\rm_2'); set(gca,'XTickMode','auto','YTickMode','auto','View',[0 90]); axis tight; elseif M == 3 plot3(Data(:,1),Data(:,2),Data(:,3),varargin{:}); - 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'); set(gca,'XTickMode','auto','YTickMode','auto','ZTickMode','auto','View',[135 30]); axis tight; elseif M > 3