function [objF, conV]=fitness(P, problem)
%%
% the matlab code of the cec2010 benchmark is converted from the C code
% more details about the C code of the benchmark can be referred to http://www3.ntu.edu.sg/home/epnsugan/
%% input parameters
% P -- the evaluating population/the target vectors
% problem -- the index of the tested function
%% output parameters
% objF -- the objective function value of the new evaluating population
% conV -- the degree of constraint violation of the new evaluating population
%%
% calculate the size of the population p(popsize) and the number of dimensions(n) of
% the tested function
[popsize,n] = size(P);
%the tolerance value for the equality constraints
delta=0.0001;
%initialize the set of degree of equality constraint violations
g = zeros(popsize,1);
%initialize the set of degree of inequality constraint violations
h=zeros(popsize,1);
% choose the problem
switch problem
case 1
O=[0.030858718087483, -0.078632292353156, 0.048651146638038, -0.069089831066354, -0.087918542941928, 0.088982639811141, 0.074143235639847, -0.086527593580149, -0.020616531903907, 0.055586106499231, 0.059285954883598, -0.040671485554685, -0.087399911887693, -0.01842585125741, -0.005184912793062, -0.039892037937026, 0.036509229387458, 0.026046414854433, -0.067133862936029, 0.082780189144943, -0.049336722577062, 0.018503188080959, 0.051610619131255, 0.018613117768432, 0.093448598181657, -0.071208840780873, -0.036535677894572, -0.03126128526933, 0.099243805247963, 0.053872445945574];
o=O(1:n);
p=P-repmat(o,popsize,1);
g(:, 1) = 0.75 - prod(p, 2);
g(:, 2) = sum(p')' - 7.5 * size(p, 2);
f = -abs(sum((cos(p).^4), 2) - 2 * prod((cos(p).^2), 2)) ./ sqrt( sum(repmat(1 : size(p, 2), popsize, 1) .* (p.^2), 2));
case 2
O = [-0.066939099286697, 0.470966419894494, -0.490528349401176, -0.312203454689423, -0.124759576300523, -0.247823908806285, -0.448077079941866, 0.326494954650117, 0.493435908752668, 0.061699778818925, -0.30251101183711, -0.274045146932175, -0.432969960330318, 0.062239193145781, -0.188163731545079, -0.100709842052095, -0.333528971180922, -0.496627672944882, -0.288650116941944, 0.435648113198148, -0.348261107144255, 0.456550427329479, -0.286843419772511, 0.145639015401174, -0.038656025783381, 0.333291935226012, -0.293687524888766, -0.347859473554797, -0.089300971656411, 0.142027393193559];
o=O(1:n);
z=P-repmat(o,popsize,1);
y=z-0.5;
f=max(z,[],2);
g(:,1)=10-1/n*sum((z.^2-10*cos(2*pi*z)+10),2);
g(:,2)=1/n*sum((z.^2-10*cos(2*pi*z)+10),2)-15;
h(:,1)=abs(1/n*sum((y.^2-10*cos(2*pi*y)+10),2)-20)-delta;
case 3
O = [111.17633500088529, 92.07880492633424, 417.9818592609036, 253.16188128024302, 363.5279986597767, 314.334093889305, 187.32739056163342, 240.4363027535162, 422.60090880560665, 327.63042902581515, 62.04762897064405, 25.435663968682125, 360.56773191905114, 154.9226721156832, 33.161292034425806, 177.8091733067186, 262.58198940407755, 436.9800562237075, 476.6400624069227, 331.2167787340325, 75.205948242522, 484.33624811710115, 258.4696246506982, 419.8919566566751, 357.51468895930395, 166.3771729386268, 47.59455935830133, 188.20606700809785, 184.7964918401363, 267.9201349178807];
o=O(1:n);
z=P-repmat(o,popsize,1);
z_D_1=z(:,1:n-1);
z_2_D=z(:,2:n);
f=sum((100*(z_D_1.^2-z_2_D).^2+(z_D_1-1).^2),2);
h(:,1)=abs(sum((z_D_1-z_2_D).^2,2))-delta;
case 4
O = [0.820202353727904, 5.260154140335203, -1.694610371739177, -5.589298730330406, -0.141736605495543, 9.454675508078164, 8.795744608532939, 9.687346331423548, -3.246522827444976, 6.647399971577617, 1.434490229836026, -0.506531215086801, 0.558594225280784, 7.919942423520642, 1.383716002673571, -1.520153615528276, -2.266737465474915, 6.48052999726508, -8.893207968949003, -3.528743044935322, 6.063486037065154, -4.51585211274229, 7.320477892009357, -8.990263774675665, 9.446412007392851, -6.41068985463494, -9.135251626491991, 2.07763837492787, 8.051026378030816, -1.002691032064544];
o=O(1:n);
z=P-repmat(o,popsize,1);
f=max(z,[],2);
h(:,1)=abs(1/n*sum((z.*cos(sqrt(abs(z)))),2))-delta;
h(:,2)=abs(sum((z(:,1:n/2-1)-z(:,2:n/2)).^2,2))-delta;
h(:,3)=abs(sum((z(:,n/2+1:n-1).^2-z(:,n/2+2:n)).^2,2))-delta;
h(:,4)=abs(sum(z,2))-0.0001;
case 5
O = [72.10900225247575, 9.007673762322495, 51.86632637302316, 41.365704820161, 93.18768763916974, 74.53341902482204, 63.745479932407655, 7.496986033468282, 56.16729598807964, 17.71630810614085, 28.009655663065143, 29.36357615570272, 26.966653374740996, 6.892189514516317, 44.29071160734624, 84.35803966449319, 81.16906730972529, 92.76919270133271, 3.826058034047476, 7.231864548985054, 14.446069444832405, 46.49943418775763, 22.155722253817412, 69.11723738661682, 88.99628570349459, 58.74823912291344, 52.265369214509846, 47.030120955005074, 53.23321779503931, 5.778976086909701];
o=O(1:n);
z=P-repmat(o,popsize,1);
f=max(z,[],2);
h(:,1)=abs(1/n*sum((-z.*sin(sqrt(abs(z)))),2))-delta;
h(:,2)=abs(1/n*sum((-z.*cos(0.5*sqrt(abs(z)))),2))-delta;
case 6
O = [-1.595515627742907, 7.633467047559741, -5.764100483472472, 8.103197246263033, -0.059515969417191, -0.737189363693078, -9.190862358160823, 4.22087353933443, -1.745435308213725, 9.499044614342985, 3.82068618551277, 2.569334886907409, 9.354368119489862, -0.852114934846258, 4.714177466874696, 6.775420647884232, -9.074204717422479, -3.760650327490145, -0.77805530989772, -7.487007842931314, 4.435061566086135, -6.952711886757461, -8.752326993212105, -2.411334215593357, -6.149894283287328, 1.049303005795593, -6.049093253116644, 0.950328133373404, 1.443084229017085, -0.163829799788475];
M1 = [-0.427907650939441, 0.33300277992222, 0.158498600541243, 0.278765719516325, 0.222299060911893, -0.29474502069992, 0.370057970680927, -0.501453646373309, -0.280145449898877, -0.000651265117346;...
0.224165315142979, -0.261710409707008, 0.461868247797853, 0.088426027905637, 0.181816871315433, 0.373896699539441, 0.129585371011854, -0.381595698048136, 0.299800543352535, 0.48473910987024;...
0.53537800271001, -0.346919032183315, -0.245187528106815, 0.616142955927466, 0.041841873460541, -0.159575037377286, 0.105947745849249, -0.048303985087219, -0.328079281746379, -0.069709134117085;...
-0.416970506616096, -0.38848171660274, -0.094221759803838, -0.004397275883214, -0.237544237428415, -0.087984765871128, 0.123623297192573, 0.287283813863898, -0.330878858096249, 0.62837597392732;...
-0.173113815964007, -0.41172550558533, -0.499430088608083, -0.219823423370544, -0.134153464975979, 0.107615420480369, 0.438598883104602, -0.36754189637868, 0.291862561306911, -0.24605477533745;...
-0.238828717007495, -0.377132503962298, -0.036565581442029, -0.115315158370499, 0.298745579814478, 0.119889740767446, -0.652016881734357, -0.358800646641909, -0.326697807053803, -0.147917018157104;...
-0.430957521699839, -0.225924726595994, 0.119112314369716, 0.573035485004016, 0.085368416951095, -0.090379611695263, -0.158290455997733, 0.252439376164776, 0.529634351567821, -0.189541361218442;...
0.038944335110613, 0.082059986739041, -0.407974613233548, -0.116148517661389, 0.807124465614906, -0.104709855101281, 0.075051783295566, 0.217165356560047, 0.152079302286292, 0.271071947907043;...
0.158807462159919, -0.014816097582468, -0.081504338504322, -0.114995329704289, -0.203139388356386, -0.726380618422525, -0.310128975831262, -0.313282470241953, 0.332760870420427, 0.284154344591495;...
-0.081746794746219, 0.423796877332073, -0.504499564436954, 0.34367868531852, -0.
没有合适的资源?快使用搜索试试~ 我知道了~
C2oDE算法的完整代码
共14个文件
m:12个
asv:2个
需积分: 0 1 下载量 64 浏览量
2024-01-12
13:14:11
上传
评论
收藏 59KB RAR 举报
温馨提示
C2oDE算法的完整代码
资源推荐
资源详情
资源评论
收起资源包目录
C2oDE.rar (14个子文件)
C2oDE-code
C2oDE for IEEE CEC2006 benchmark
DEgenerator.m 5KB
diversity.m 317B
main.m 9KB
epsSelect.m 674B
fitness.m 19KB
preSelect.m 639B
C2oDE for IEEE CEC2010 benchmark
DEgenerator.m 7KB
diversity.m 313B
main.m 7KB
DEgenerator.asv 6KB
main.asv 6KB
epsSelect.m 674B
fitness.m 116KB
preSelect.m 639B
共 14 条
- 1
资源评论
W__Wjin
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功