📄 fitness.m
字号:
function [fit] = fitness(x1, x2, x3, x4, x5, x6, x7,itera)
g1 = gcon1(x1, x2, x3)-1;
g2 = gcon2(x1, x2, x3)-1;
g3 = gcon3(x2, x3, x4, x6)-1;
g4 = gcon4(x2, x3, x5, x7)-1;
g5 = gcon5(x2, x3, x4, x6)-1;
g6 = gcon6(x2, x3, x5, x7)-1;
g7 = gcon7(x2, x4)-1;
g8 = gcon8(x1, x2)-1;
g9 = gcon9(x1, x2)-1;
g10 = gcon10(x4, x6)-1;
g11 = gcon11(x5, x7)-1;
Npop = 25;
fit = zeros(Npop,1);
for k = 1: Npop
% for j = 1:11
% eval(['q' int2str(j) '=max(1,g' int2str(j) '(k));']);
% eval(['gamma' int2str(j) '= 1;']);
% eval(['if q' int2str(j) '< 1.001'...
% 'theta' int2str(j) ' = 10;'...
% 'elseif q' int2str(j) '>=1.001 & q' int2str(j) '< 1.1'...
% 'theta' int2str(j) ' =20;'...
% 'elseif q' int2str(j) '>=1.1 & q' int2str(j) '<2'...
% 'theta' int2str(j) '=100;'...
% 'else'...
% 'theta' int2str(j) '=300;'...
% 'gamma' int2str(j) '=2;'...
% 'end'
% 'lamda' int2str(j) '= theta' int2str(j) ' * q' int2str(j) '^gamma' int2str(j) ';']);
% end
punishment1 = 100;
punishment2 = 200;
punishment3 = 1000;
punishment4 = 3000;
q1 = max(0,g1(k));
gamma1 = 1;
if q1 <= 1e-9
theta1 = 0;
elseif q1 > 1e-9 & q1 < 0.001
theta1 = punishment1 ;
elseif q1 >= 0.001 & q1 < 0.1
theta1 = punishment2;
elseif q1 >= 0.1 & q1 < 1
theta1 = punishment3;
else
theta1 = punishment4;
gamma1 = 2;
end
lamda1 = theta1 * (q1+1)^gamma1;
q2 = max(0,g2(k));
gamma2 = 1;
if q2 <= 1e-9
theta2 = 0;
elseif q2 > 1e-9 & q2 < 0.001
theta2 = punishment1 ;
elseif q2 >= 0.001 & q2 < 0.1
theta2 = punishment2;
elseif q2 >= 0.1 & q2 < 1
theta2 = punishment3;
else
theta2 = punishment4;
gamma2 = 2;
end
lamda2 = theta2 * (q2+1)^gamma2;
q3 = max(0,g3(k));
gamma3 = 1;
if q3 <= 1e-9
theta3 = 0;
elseif q3 > 1e-9 & q3 < 0.001
theta3 = punishment1 ;
elseif q3 >= 0.001 & q3 < 0.1
theta3 = punishment2;
elseif q3 >= 0.1 & q3 < 1
theta3 = punishment3;
else
theta3 = punishment4;
gamma3 = 2;
end
lamda3 = theta3 * (q3+1)^gamma3;
q4 = max(0,g4(k));
gamma4 = 1;
if q4 <= 1e-9
theta4 = 0;
elseif q4 > 1e-9 & q4 < 0.001
theta4 = punishment1 ;
elseif q4 >= 0.001 & q4 < 0.1
theta4 = punishment2;
elseif q4 >= 0.1 & q4 < 1
theta4 = punishment3;
else
theta4 = punishment4;
gamma4 = 2;
end
lamda4 = theta4 * (q4+1)^gamma4;
q5 = max(0,g5(k));
gamma5 = 1;
if q5 <= 1e-9
theta5 = 0;
elseif q5 > 1e-9 & q5 < 0.001
theta5 = punishment1 ;
elseif q5 >= 0.001 & q5 < 0.1
theta5 = punishment2;
elseif q5 >= 0.1 & q5 < 1
theta5 = punishment3;
else
theta5 = punishment4;
gamma5 = 2;
end
lamda5 = theta5 * (q5+1)^gamma5;
q6 = max(0,g6(k));
gamma6 = 1;
if q6 <= 1e-9
theta6 = 0;
elseif q6 > 1e-9 & q6 < 0.001
theta6 = punishment1 ;
elseif q6 >= 0.001 & q6 < 0.1
theta6 = punishment2;
elseif q6 >= 0.1 & q6 < 1
theta6 = punishment3;
else
theta6 = punishment4;
gamma6 = 2;
end
lamda6 = theta6 * (q6+1)^gamma6;
q7 = max(0,g7(k));
gamma7 = 1;
if q7 <= 1e-9
theta7 = 0;
elseif q7 > 1e-9 & q7 < 0.001
theta7 = punishment1 ;
elseif q7 >= 0.001 & q7 < 0.1
theta7 = punishment2;
elseif q7 >= 0.1 & q7 < 1
theta7 = punishment3;
else
theta7 = punishment4;
gamma7 = 2;
end
lamda7 = theta7 * (q7+1)^gamma7;
q8 = max(0,g8(k));
gamma8 = 1;
if q8 <= 1e-9
theta8 = 0;
elseif q8 > 1e-9 & q8 < 0.001
theta8 = punishment1 ;
elseif q8 >= 0.001 & q8 < 0.1
theta8 = punishment2;
elseif q8 >= 0.1 & q8 < 1
theta8 = punishment3;
else
theta8 = punishment4;
gamma8 = 2;
end
lamda8 = theta8 * (q8+1)^gamma8;
q9 = max(0,g9(k));
gamma9 = 1;
if q9 <= 1e-9
theta9 = 0;
elseif q9 > 1e-9 & q9 < 0.001
theta9 = punishment1 ;
elseif q9 >= 0.001 & q9 < 0.1
theta9 = punishment2;
elseif q9 >= 0.1 & q9 < 1
theta9 = punishment3;
else
theta9 = punishment4;
gamma9 = 2;
end
lamda9 = theta9 * (q9+1)^gamma9;
q10 = max(0,g10(k));
gamma10 = 1;
if q10 <= 1e-9
theta10 = 0;
elseif q10 > 1e-9 & q10 < 0.001
theta10 = punishment1 ;
elseif q10 >= 0.001 & q10 < 0.1
theta10 = punishment2;
elseif q10 >= 0.1 & q10 < 1
theta10 = punishment3;
else
theta10 = punishment4;
gamma10 = 2;
end
lamda10 = theta10 * (q10+1)^gamma10;
q11 = max(0,g11(k));
gamma11 = 1;
if q11 <= 1e-9
theta11 = 0;
elseif q11 > 1e-9 & q11 < 0.001
theta11 = punishment1 ;
elseif q11 >= 0.001 & q11 < 0.1
theta11 = punishment2;
elseif q11 >= 0.1 & q11 < 1
theta11 = punishment3;
else
theta11 = punishment4;
gamma11 = 2;
end
lamda11 = theta11 * (q1+1)^gamma11;
fit(k) = 0.7854*x1(k)*x2(k)^2 *(3.3333*x3(k)^2 + 14.9334*x3(k) - 43.0934)...
- 1.5079 * x1(k) * ( x6(k)^2 + x7(k)^2 ) + 7.477 * (x6(k)^3 + x7(k)^3)...
+ 0.7854 * (x4(k) * x6(k)^2 + x5(k) * x7(k)^2 )...
+ sqrt(sqrt(itera)) *( lamda1 + lamda2 + lamda3 + lamda4 + lamda5 + lamda6...
+ lamda7 + lamda8 + lamda9 + lamda10 + lamda11);
end
%if itera < 700;
% w = 0.9 - (itera/700)*0.2;
%else
% w = 0.2;
%end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -