-
Notifications
You must be signed in to change notification settings - Fork 0
/
INDIVIDUAL.m
122 lines (111 loc) · 5.16 KB
/
INDIVIDUAL.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
classdef INDIVIDUAL < handle
%------------------------------- 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
dec;
obj;
nobj;
oriobj;
flag=0;
time;
fre;
end
methods
%%
function [obj, Global] = INDIVIDUAL(Decs, Global)
%INDIVIDUAL - Constructor of INDIVIDUAL class.
%
% H = INDIVIDUAL(Dec) creates an array of individuals (i.e., a
% population), where Dec is the matrix of decision variables of
% the population. The objective values and constraint violations
% are automatically calculated by the test problem functions.
% After creating the individuals, the number of evaluations will
% be increased by length(H).
%
% H = INDIVIDUAL(Dec,AddProper) creates the population with
% additional properties stored in AddProper, such as the velocity
% in particle swarm optimization.
%
% Example:
% H = INDIVIDUAL(rand(100,3))
% H = INDIVIDUAL(rand(100,10),randn(100,3))
if nargin > 0
% Create new objects
obj(1,size(Decs,1)) = INDIVIDUAL;
% Set the infeasible decision variables to boundary values
if ~isempty(Global.lower) && ~isempty(Global.upper)
Lower = repmat(Global.lower,length(obj),1);
Upper = repmat(Global.upper,length(obj),1);
Decs = max(min(Decs,Upper),Lower);
end
% Calculte the objective values and constraint violations
Objs = fitness (Decs,Global);
OriObjs = fitness (Decs,Global);
% Assign the decision variables, objective values,
% constraint violations, and additional properties
for i = 1 : length(obj)
obj(i).dec = Decs(i,:);
obj(i).obj = Objs(i,:);
obj(i).oriobj = OriObjs(i,:);
obj(i).fre = 1;
end
% Increase the number of evaluated individuals
Global.evaluated = Global.evaluated + length(obj);
end
end
%% Get the matrix of decision variables of the population
function value = decs(obj)
%decs - Get the matrix of decision variables of the population.
%
% A = obj.decs returns the matrix of decision variables of the
% population obj, where obj is an array of INDIVIDUAL objects.
value = cat(1,obj.dec);
end
%% Get the matrix of with noise on objective values of the population
function value = objs(obj)
%objs - Get the matrix of objective values of the population.
%
% A = obj.objs returns the matrix of objective values of the
% population obj, where obj is an array of INDIVIDUAL objects.
value = cat(1,obj.obj);
end
%% Get the matrix without noise on objective values of the population
function value = oriobjs(obj)
%objs - Get the matrix of objective values of the population.
%
% A = obj.objs returns the matrix of objective values of the
% population obj, where obj is an array of INDIVIDUAL objects.
value = cat(1,obj.oriobj);
end
%% Get the matrix of flag of the population
function value = flags(obj)
%objs - Get the matrix of objective values of the population.
%
% A = obj.objs returns the matrix of objective values of the
% population obj, where obj is an array of INDIVIDUAL objects.
value = cat(1,obj.flag);
end
%% Get the matrix of flag of the population
function value = times(obj)
%objs - Get the matrix of objective values of the population.
%
% A = obj.objs returns the matrix of objective values of the
% population obj, where obj is an array of INDIVIDUAL objects.
value = cat(1,obj.time);
end
%% Get the matrix of Frequency of the population
function value = fres(obj)
%objs - Get the matrix of objective values of the population.
%
% A = obj.objs returns the matrix of objective values of the
% population obj, where obj is an array of INDIVIDUAL objects.
value = cat(1,obj.fre);
end
end
end