Effacer les filtres
Effacer les filtres

variable problem of GA

18 vues (au cours des 30 derniers jours)
HSUAN
HSUAN le 9 Avr 2024
Commenté : HSUAN le 9 Avr 2024
If I want to set Nv(1) and K(1) as variables that do not require numerical values, how should I modify my code?
I have tried directly setting x(1)=0, x(8)=0,but it's no use.
t=[0.015 0.01 0.009 0.012 0.016 0.014 0 0];
w=[0.005 0.004 0.003 0.004 0.006 0.004 0 0];
options = optimoptions( ...
'ga', ...
'PopulationSize', 30, ...
'MaxGenerations', 1000, ...
'MaxStallGenerations' ,500,...
'CrossoverFraction', 0.8, ...
'Display', 'iter');
nvars = 7 + 7 + 6;
lb = [ones(7,1);ones(7,1);w(1:6).'];
ub = [40*ones(7,1);40*ones(7,1);t(1:6).'];
intcon = 1:(7+7);
[x, fval] = ga(@FitnessFcn,nvars,[],[],[],[],lb,ub,[],intcon,options);
function Z = FitnessFcn(x)
Nv = x(1:7);
K = x(7+1:7+7);
m = x(7+7+1:7+7+6);
Tb=1.2;
Hb=[2.8 2.2 1.7 1.2 0.8 0.6 0 0];
Sb=[25 28 32 36 35 38 0 0];
F=[70 50 48 55 80 65 0 0];
Sv=[0 280 200 320 360 380 420 0];
Hv=[0 2.5 1.9 1.4 1 0.7 0.5 0];
D=[180000 200000 240000 300000 350000 400000 0 0];
P=[0 200000 240000 300000 350000 400000 450000 0];
q=[1 1 1 1 1 1 0 0];
u=[0.009 0.0064 0.0054 0.0072 0.01 0.008 0 0];
t=[0.015 0.01 0.009 0.012 0.016 0.014 0 0];
w=[0.005 0.004 0.003 0.004 0.006 0.004 0 0];
Se=[29 32 38 42 37 40 0 0];
n=[1 0.9 0.75 0.6 0.51 0.45];
p=[3.2 2.6 2.1 1.6 1.2 0.9 0 0];
Nb=[1 1 1 1 1 1 0 0];
idx = 1:6;
Nvc = cumprod(Nv(idx+1));
Nvb = cumprod(Nv(idx));
Z = sum(n(idx).*Tb.*Hb(idx).*D(idx).*(m(idx)-u(idx))+...
(n(idx)*Tb).^2./(Nvc.*K(idx+1)).* ...
(D(idx)/2.*(Hb(idx)+Hv(idx+1)-2*Hv(idx+1).*(1-D(idx)./P(idx+1))))+ ...
Nvc.*K(idx+1).*(Se(idx).*(t(idx)-m(idx)).^3.*(t(idx)+3*m(idx)-4*w(idx)) ...
./(t(idx)-w(idx)).^4 +(Hb(idx)+p(idx)).*D(idx).*(t(idx)-m(idx)).^5.*(2*t(idx)+3*m(idx)-5*w(idx)) ...
./(5*(t(idx)-w(idx)).^4)+F(idx))+Nvc.*Sv(idx+1)+...
(n(idx)*Tb).^2./Nvc.*(Hv(idx+1).*D(idx)/2.*(1-D(idx)./P(idx+1)))...
+ Nvb.*Nb(idx).*Sb(idx));
end

Réponse acceptée

Torsten
Torsten le 9 Avr 2024
Modifié(e) : Torsten le 9 Avr 2024
t=[0.015 0.01 0.009 0.012 0.016 0.014 0 0];
w=[0.005 0.004 0.003 0.004 0.006 0.004 0 0];
options = optimoptions( ...
'ga', ...
'PopulationSize', 30, ...
'MaxGenerations', 1000, ...
'MaxStallGenerations' ,500,...
'CrossoverFraction', 0.8, ...
'Display', 'iter');
nvars = 7-1 + 7-1 + 6;
lb = [ones(7-1,1);ones(7-1,1);w(1:6).'];
ub = [40*ones(7-1,1);40*ones(7-1,1);t(1:6).'];
intcon = 1:(7-1+7-1);
Nv1 = 1; % prescribe Nv(1)
K1 = 1; % prescribe K(1)
[x, fval] = ga(@(x)FitnessFcn(x,Nv1,K1),nvars,[],[],[],[],lb,ub,[],intcon,options);
Single objective optimization: 18 Variables 12 Integer variables Options: CreationFcn: @gacreationuniformint CrossoverFcn: @crossoverlaplace SelectionFcn: @selectiontournament MutationFcn: @mutationpower Best Mean Stall Generation Func-count Penalty Penalty Generations 1 60 1.68e+06 6.103e+10 0 2 85 1.68e+06 4.649e+10 1 3 110 1.68e+06 4.652e+10 2 4 135 1.68e+06 1.767e+10 3 5 160 1.68e+06 1.672e+10 4 6 185 1.39e+06 7.471e+09 0 7 210 8.695e+05 1.913e+09 0 8 235 8.695e+05 3.315e+10 1 9 260 8.695e+05 9.483e+08 2 10 285 8.106e+05 1.8e+08 0 11 310 3.235e+05 9.363e+08 0 12 335 3.235e+05 1.475e+10 1 13 360 1.968e+05 1.456e+10 0 14 385 1.439e+05 3.134e+09 0 15 410 1.439e+05 6.646e+09 1 16 435 1.439e+05 4.668e+06 2 17 460 1.439e+05 7.994e+09 3 18 485 1.389e+05 8.367e+05 0 19 510 1.389e+05 8.429e+08 1 20 535 1.376e+05 2.461e+09 0 21 560 1.34e+05 1.788e+09 0 22 585 1.34e+05 3.818e+05 1 23 610 1.302e+05 1.212e+09 0 24 635 1.292e+05 3.714e+08 0 25 660 1.28e+05 1.487e+09 0 26 685 1.257e+05 1.68e+05 0 27 710 1.257e+05 1.277e+09 1 28 735 1.252e+05 2.953e+05 0 29 760 1.222e+05 1.359e+05 0 Best Mean Stall Generation Func-count Penalty Penalty Generations 30 785 1.21e+05 1.603e+05 0 31 810 1.207e+05 9.333e+09 0 32 835 1.207e+05 1.679e+05 1 33 860 1.207e+05 1.429e+05 2 34 885 1.165e+05 1.484e+05 0 35 910 1.162e+05 2.653e+09 0 36 935 1.134e+05 2.347e+10 0 37 960 1.134e+05 3.013e+05 1 38 985 1.134e+05 1.202e+10 2 39 1010 1.134e+05 4.378e+06 0 40 1035 1.134e+05 5.417e+08 1 41 1060 1.13e+05 1.192e+05 0 42 1085 1.13e+05 1.232e+05 1 43 1110 1.13e+05 2.246e+09 2 44 1135 1.13e+05 1.21e+05 3 45 1160 1.129e+05 1.159e+05 0 46 1185 1.129e+05 1.198e+05 1 47 1210 1.128e+05 1.148e+05 0 48 1235 1.128e+05 2.798e+08 1 49 1260 1.128e+05 1.641e+10 2 50 1285 1.126e+05 1.177e+05 0 51 1310 1.126e+05 1.355e+05 0 52 1335 1.126e+05 2.878e+09 1 53 1360 1.126e+05 7.679e+09 2 54 1385 1.126e+05 7.158e+09 0 55 1410 1.126e+05 1.379e+05 0 56 1435 1.125e+05 2.772e+08 0 57 1460 1.125e+05 1.189e+05 0 58 1485 1.124e+05 1.603e+09 0 59 1510 1.124e+05 6.099e+09 1 Best Mean Stall Generation Func-count Penalty Penalty Generations 60 1535 1.124e+05 5.417e+09 0 61 1560 1.124e+05 2.542e+08 1 62 1585 1.124e+05 1.36e+10 0 63 1610 1.124e+05 2.36e+09 0 64 1635 1.124e+05 8.166e+09 0 65 1660 1.124e+05 1.155e+05 0 66 1685 1.123e+05 2.414e+10 0 67 1710 1.123e+05 1.165e+05 0 68 1735 1.123e+05 1.16e+05 1 69 1760 1.123e+05 1.184e+05 0 70 1785 1.123e+05 1.144e+05 0 71 1810 1.123e+05 2.186e+09 0 72 1835 1.123e+05 1.145e+05 0 73 1860 1.123e+05 1.151e+05 0 74 1885 1.123e+05 2.136e+08 0 75 1910 1.123e+05 1.132e+05 1 76 1935 1.123e+05 1.148e+05 2 77 1960 1.123e+05 2.632e+07 3 78 1985 1.123e+05 1.129e+05 0 79 2010 1.123e+05 1.212e+05 0 80 2035 1.12e+05 1.17e+05 0 81 2060 1.12e+05 1.006e+11 1 82 2085 1.12e+05 1.326e+08 0 83 2110 1.12e+05 1.131e+05 1 84 2135 1.119e+05 2.002e+09 0 85 2160 1.119e+05 1.132e+05 1 86 2185 1.119e+05 4.635e+09 2 87 2210 1.119e+05 1.124e+05 0 88 2235 1.118e+05 4.062e+10 0 89 2260 1.118e+05 1.652e+08 0 Best Mean Stall Generation Func-count Penalty Penalty Generations 90 2285 1.118e+05 6.113e+08 0 91 2310 1.118e+05 1.125e+05 1 92 2335 1.118e+05 9.523e+09 0 93 2360 1.118e+05 6.72e+09 0 94 2385 1.117e+05 4.373e+09 0 95 2410 1.116e+05 1.188e+05 0 96 2435 1.116e+05 1.147e+05 1 97 2460 1.116e+05 6.819e+08 2 98 2485 1.116e+05 9.722e+09 3 99 2510 1.116e+05 6.006e+08 4 100 2535 1.116e+05 7.966e+09 0 101 2560 1.113e+05 4.758e+09 0 102 2585 1.113e+05 2.624e+09 0 103 2610 1.112e+05 1.188e+05 0 104 2635 1.111e+05 5.879e+09 0 105 2660 1.111e+05 1.35e+09 0 106 2685 1.111e+05 1.872e+10 1 107 2710 1.111e+05 1.174e+08 2 108 2735 1.111e+05 7.038e+09 0 109 2760 1.11e+05 1.132e+05 0 110 2785 1.11e+05 7.489e+08 1 111 2810 1.11e+05 3.118e+08 2 112 2835 1.11e+05 1.139e+05 3 113 2860 1.11e+05 5.592e+09 4 114 2885 1.11e+05 2.182e+09 0 115 2910 1.109e+05 1.177e+10 0 116 2935 1.109e+05 6.268e+09 0 117 2960 1.109e+05 1.209e+05 0 118 2985 1.109e+05 1.126e+05 1 119 3010 1.109e+05 1.235e+05 2 Best Mean Stall Generation Func-count Penalty Penalty Generations 120 3035 1.109e+05 1.338e+09 3 121 3060 1.109e+05 2.333e+09 4 122 3085 1.109e+05 7.634e+09 5 123 3110 1.109e+05 4.297e+09 6 124 3135 1.109e+05 2.245e+10 0 125 3160 1.109e+05 2.165e+09 1 126 3185 1.109e+05 1.138e+05 2 127 3210 1.109e+05 8.013e+09 3 128 3235 1.109e+05 1.167e+09 4 129 3260 1.109e+05 8.282e+09 0 130 3285 1.109e+05 4.97e+07 1 131 3310 1.109e+05 2.81e+10 2 132 3335 1.109e+05 4.787e+08 0 133 3360 1.109e+05 8.668e+10 1 134 3385 1.109e+05 1.117e+05 2 135 3410 1.109e+05 1.123e+05 3 136 3435 1.109e+05 1.431e+08 4 137 3460 1.109e+05 3.153e+09 5 138 3485 1.109e+05 1.175e+05 6 139 3510 1.109e+05 2.917e+08 0 140 3535 1.109e+05 2.441e+10 0 141 3560 1.109e+05 1.454e+09 1 142 3585 1.109e+05 1.131e+05 0 143 3610 1.109e+05 7.223e+08 0 144 3635 1.109e+05 7.205e+09 1 145 3660 1.109e+05 1.487e+09 0 146 3685 1.109e+05 1.237e+05 0 147 3710 1.109e+05 1.116e+05 0 148 3735 1.109e+05 1.15e+05 0 149 3760 1.109e+05 1.116e+05 1 Best Mean Stall Generation Func-count Penalty Penalty Generations 150 3785 1.109e+05 1.312e+05 0 151 3810 1.109e+05 4.673e+08 0 152 3835 1.109e+05 2.881e+09 0 153 3860 1.109e+05 4.429e+08 0 154 3885 1.109e+05 2.449e+09 1 155 3910 1.109e+05 1.137e+05 0 156 3935 1.109e+05 3.807e+10 1 157 3960 1.109e+05 1.139e+05 2 158 3985 1.109e+05 2.036e+09 3 159 4010 1.109e+05 1.15e+05 4 160 4035 1.109e+05 5.665e+08 0 161 4060 1.109e+05 1.412e+10 0 162 4085 1.109e+05 4.045e+08 1 163 4110 1.109e+05 1.115e+05 2 164 4135 1.109e+05 1.133e+05 0 165 4160 1.109e+05 1.118e+05 0 166 4185 1.109e+05 2.441e+10 0 167 4210 1.109e+05 9.322e+08 0 168 4235 1.109e+05 1.693e+07 1 169 4260 1.109e+05 1.123e+05 0 170 4285 1.109e+05 1.178e+10 0 171 4310 1.109e+05 1.205e+05 0 172 4335 1.109e+05 5.04e+07 1 173 4360 1.109e+05 1.128e+05 2 174 4385 1.109e+05 1.164e+05 0 175 4410 1.109e+05 2.376e+09 1 176 4435 1.109e+05 6.592e+09 0 177 4460 1.109e+05 4.293e+08 1 178 4485 1.109e+05 1.151e+09 0 179 4510 1.109e+05 8.987e+09 0 Best Mean Stall Generation Func-count Penalty Penalty Generations 180 4535 1.109e+05 1.133e+05 1 181 4560 1.109e+05 1.144e+05 0 182 4585 1.109e+05 1.912e+09 1 183 4610 1.109e+05 3.294e+08 2 184 4635 1.109e+05 1.115e+05 0 185 4660 1.109e+05 1.131e+05 0 186 4685 1.109e+05 4.272e+09 0 187 4710 1.109e+05 9.277e+08 1 188 4735 1.109e+05 2.535e+09 0 189 4760 1.109e+05 5.573e+10 0 190 4785 1.109e+05 5.154e+09 0 191 4810 1.109e+05 1.02e+09 0 192 4835 1.109e+05 1.112e+05 0 193 4860 1.109e+05 2.889e+09 0 194 4885 1.109e+05 1.147e+05 0 195 4910 1.109e+05 1.127e+05 0 196 4935 1.109e+05 1.739e+08 1 197 4960 1.109e+05 2.462e+10 2 198 4985 1.109e+05 1.16e+10 0 199 5010 1.109e+05 1.166e+05 0 200 5035 1.109e+05 1.083e+10 1 201 5060 1.109e+05 1.618e+08 2 202 5085 1.109e+05 9.705e+10 0 203 5110 1.109e+05 9.978e+09 1 204 5135 1.109e+05 1.609e+08 0 205 5160 1.109e+05 3.508e+09 0 206 5185 1.109e+05 4.728e+10 1 207 5210 1.109e+05 3.298e+09 0 208 5235 1.109e+05 1.224e+10 1 209 5260 1.109e+05 1.41e+05 0 Best Mean Stall Generation Func-count Penalty Penalty Generations 210 5285 1.109e+05 1.114e+05 0 211 5310 1.109e+05 1.317e+09 0 212 5335 1.109e+05 1.117e+05 1 213 5360 1.109e+05 1.122e+05 0 214 5385 1.109e+05 1.112e+05 1 215 5410 1.109e+05 1.117e+05 0 216 5435 1.109e+05 4.787e+09 0 217 5460 1.109e+05 1.135e+05 0 218 5485 1.109e+05 1.215e+05 1 219 5510 1.109e+05 1.594e+09 0 220 5535 1.109e+05 1.155e+05 0 221 5560 1.109e+05 1.214e+05 0 222 5585 1.109e+05 1.122e+05 0 223 5610 1.109e+05 1.151e+05 1 224 5635 1.109e+05 1.139e+05 2 225 5660 1.109e+05 3.686e+09 3 226 5685 1.109e+05 1.478e+10 0 227 5710 1.109e+05 2.266e+08 0 228 5735 1.109e+05 1.255e+05 1 229 5760 1.109e+05 5.073e+09 0 230 5785 1.109e+05 3.501e+09 1 231 5810 1.109e+05 1.168e+05 0 232 5835 1.109e+05 5.137e+09 1 233 5860 1.109e+05 3.438e+09 0 234 5885 1.109e+05 1.11e+05 0 235 5910 1.109e+05 1.154e+05 0 236 5935 1.109e+05 1.057e+08 0 237 5960 1.109e+05 5.851e+09 0 238 5985 1.109e+05 1.149e+05 1 239 6010 1.109e+05 1.139e+05 0 Best Mean Stall Generation Func-count Penalty Penalty Generations 240 6035 1.109e+05 1.317e+05 1 241 6060 1.109e+05 1.842e+07 2 242 6085 1.109e+05 1.998e+10 0 243 6110 1.109e+05 1.121e+05 0 244 6135 1.109e+05 3.17e+09 0 245 6160 1.109e+05 1.157e+05 0 246 6185 1.109e+05 1.073e+10 0 247 6210 1.109e+05 6.103e+09 0 248 6235 1.109e+05 1.773e+10 0 249 6260 1.109e+05 2.438e+09 0 250 6285 1.109e+05 1.12e+05 0 251 6310 1.109e+05 6.851e+09 0 252 6335 1.109e+05 2.623e+10 0 253 6360 1.109e+05 3.028e+08 0 254 6385 1.109e+05 1.367e+10 0 255 6410 1.109e+05 1.126e+10 0 256 6435 1.109e+05 1.169e+09 0 257 6460 1.109e+05 7.613e+07 0 258 6485 1.109e+05 1.785e+08 0 259 6510 1.109e+05 1.125e+05 1 260 6535 1.109e+05 1.114e+05 0 261 6560 1.109e+05 6.595e+09 1 262 6585 1.109e+05 2.482e+09 2 263 6610 1.109e+05 1.114e+05 0 264 6635 1.109e+05 1.19e+05 1 265 6660 1.109e+05 8.909e+09 2 266 6685 1.109e+05 1.489e+09 0 267 6710 1.109e+05 3.107e+09 1 268 6735 1.109e+05 6.344e+08 2 269 6760 1.109e+05 3.684e+08 3 Best Mean Stall Generation Func-count Penalty Penalty Generations 270 6785 1.109e+05 2.141e+10 0 271 6810 1.109e+05 1.112e+05 0 272 6835 1.109e+05 3.837e+08 0 273 6860 1.109e+05 1.527e+10 0 274 6885 1.109e+05 9.143e+08 1 275 6910 1.109e+05 6.723e+10 0 276 6935 1.109e+05 1.119e+05 1 277 6960 1.109e+05 9.131e+07 0 278 6985 1.109e+05 1.115e+05 0 279 7010 1.109e+05 2.365e+10 0 280 7035 1.109e+05 2.392e+08 1 281 7060 1.109e+05 1.111e+05 0 282 7085 1.109e+05 1.255e+05 1 283 7110 1.109e+05 1.119e+05 0 284 7135 1.109e+05 2.468e+08 0 285 7160 1.109e+05 1.601e+10 1 286 7185 1.109e+05 3.89e+09 0 287 7210 1.109e+05 2.83e+08 0 288 7235 1.109e+05 5.519e+09 0 289 7260 1.109e+05 1.133e+05 0 290 7285 1.109e+05 3.094e+09 0 291 7310 1.109e+05 1.299e+05 0 292 7335 1.109e+05 2.233e+08 1 293 7360 1.109e+05 8.84e+08 0 294 7385 1.109e+05 5.626e+08 0 295 7410 1.109e+05 2.327e+06 0 296 7435 1.109e+05 2.532e+09 1 297 7460 1.109e+05 1.486e+10 2 298 7485 1.109e+05 1.149e+05 0 299 7510 1.109e+05 2.084e+08 0 Best Mean Stall Generation Func-count Penalty Penalty Generations 300 7535 1.109e+05 1.112e+05 1 301 7560 1.109e+05 3.502e+10 2 302 7585 1.109e+05 1.125e+05 0 303 7610 1.109e+05 8.379e+07 1 304 7635 1.109e+05 8.208e+09 2 305 7660 1.109e+05 1.118e+05 0 306 7685 1.109e+05 1.316e+05 1 307 7710 1.109e+05 3.225e+10 0 308 7735 1.109e+05 1.121e+05 0 309 7760 1.109e+05 1.117e+05 1 310 7785 1.109e+05 4.476e+09 0 311 7810 1.109e+05 1.665e+09 0 312 7835 1.109e+05 8.314e+08 0 313 7860 1.109e+05 1.118e+05 0 314 7885 1.109e+05 1.119e+05 0 315 7910 1.109e+05 1.141e+05 1 316 7935 1.109e+05 3.922e+08 0 317 7960 1.109e+05 6.98e+09 1 318 7985 1.109e+05 1.162e+05 2 319 8010 1.109e+05 1.207e+05 0 320 8035 1.109e+05 1.125e+05 1 321 8060 1.109e+05 5.967e+08 0 322 8085 1.109e+05 7.318e+09 1 323 8110 1.109e+05 9.452e+07 0 324 8135 1.109e+05 7.687e+08 1 325 8160 1.109e+05 1.261e+09 0 326 8185 1.109e+05 1.155e+05 0 327 8210 1.109e+05 1.137e+05 1 328 8235 1.109e+05 5.811e+10 2 329 8260 1.109e+05 6.665e+08 0 Best Mean Stall Generation Func-count Penalty Penalty Generations 330 8285 1.109e+05 5.38e+09 0 331 8310 1.109e+05 8.489e+08 0 332 8335 1.109e+05 1.125e+05 0 333 8360 1.109e+05 1.425e+10 0 334 8385 1.109e+05 1.136e+09 1 335 8410 1.109e+05 4.323e+06 0 336 8435 1.109e+05 5.771e+09 1 337 8460 1.109e+05 1.138e+05 2 338 8485 1.109e+05 1.16e+05 0 339 8510 1.109e+05 8.281e+09 0 340 8535 1.109e+05 1.123e+05 1 341 8560 1.109e+05 1.119e+05 2 342 8585 1.109e+05 4.076e+09 0 343 8610 1.109e+05 3.425e+07 0 344 8635 1.109e+05 1.97e+08 1 345 8660 1.109e+05 1.111e+05 0 346 8685 1.109e+05 1.08e+10 1 347 8710 1.109e+05 1.172e+05 0 348 8735 1.109e+05 1.169e+05 1 349 8760 1.109e+05 1.014e+10 2 350 8785 1.109e+05 5.88e+07 3 351 8810 1.109e+05 2.809e+10 0 352 8835 1.109e+05 1.122e+05 0 353 8860 1.109e+05 1.111e+05 0 354 8885 1.109e+05 7.505e+08 1 355 8910 1.109e+05 2.541e+09 0 356 8935 1.109e+05 2.967e+08 0 357 8960 1.109e+05 1.036e+10 0 358 8985 1.109e+05 1.11e+05 0 359 9010 1.109e+05 1.122e+05 0 Best Mean Stall Generation Func-count Penalty Penalty Generations 360 9035 1.109e+05 1.022e+10 1 361 9060 1.109e+05 1.12e+05 0 362 9085 1.109e+05 1.28e+09 1 363 9110 1.109e+05 1.12e+05 2 364 9135 1.109e+05 6.868e+09 0 365 9160 1.109e+05 1.515e+09 1 366 9185 1.109e+05 5.898e+08 2 367 9210 1.109e+05 1.797e+10 0 368 9235 1.109e+05 1.129e+05 0 369 9260 1.109e+05 1.108e+10 1 370 9285 1.109e+05 4.168e+10 0 371 9310 1.109e+05 1.384e+10 0 372 9335 1.109e+05 1.138e+05 0 373 9360 1.109e+05 2.998e+09 1 374 9385 1.109e+05 1.118e+05 0 375 9410 1.109e+05 1.078e+08 1 376 9435 1.109e+05 8.416e+08 0 377 9460 1.109e+05 1.169e+05 0 378 9485 1.109e+05 1.124e+05 1 379 9510 1.109e+05 6.441e+09 0 380 9535 1.109e+05 1.773e+08 0 381 9560 1.109e+05 1.868e+10 0 382 9585 1.109e+05 1.112e+05 0 383 9610 1.109e+05 5.599e+07 1 384 9635 1.109e+05 3.408e+10 2 385 9660 1.109e+05 1.017e+09 3 386 9685 1.109e+05 9.327e+07 0 387 9710 1.109e+05 9.82e+08 1 388 9735 1.109e+05 2.881e+10 0 389 9760 1.109e+05 1.046e+10 0 Best Mean Stall Generation Func-count Penalty Penalty Generations 390 9785 1.109e+05 1.495e+09 0 391 9810 1.109e+05 4.239e+09 0 392 9835 1.109e+05 3.068e+07 0 393 9860 1.109e+05 3.318e+10 0 394 9885 1.109e+05 1.151e+05 1 395 9910 1.109e+05 1.616e+07 2 396 9935 1.109e+05 3.652e+05 3 397 9960 1.109e+05 4.265e+09 0 398 9985 1.109e+05 1.172e+05 0 399 10010 1.109e+05 2.489e+09 0 400 10035 1.109e+05 9.212e+09 1 401 10060 1.109e+05 1.313e+05 0 402 10085 1.109e+05 1.757e+10 0 403 10110 1.109e+05 6.002e+09 0 404 10135 1.109e+05 1.217e+08 1 405 10160 1.109e+05 7.747e+09 0 406 10185 1.109e+05 9.128e+09 0 407 10210 1.109e+05 1.186e+05 0 408 10235 1.109e+05 5.388e+10 0 409 10260 1.109e+05 4.32e+09 0 410 10285 1.109e+05 1.061e+09 1 411 10310 1.109e+05 1.199e+05 0 412 10335 1.109e+05 1.331e+05 1 413 10360 1.109e+05 6.175e+08 2 414 10385 1.109e+05 1.139e+05 0 415 10410 1.109e+05 1.444e+05 0 416 10435 1.109e+05 2.321e+08 1 417 10460 1.109e+05 1.163e+05 0 418 10485 1.109e+05 1.112e+05 0 419 10510 1.109e+05 2.134e+10 0 Best Mean Stall Generation Func-count Penalty Penalty Generations 420 10535 1.109e+05 6.274e+08 1 421 10560 1.109e+05 1.116e+05 0 422 10585 1.109e+05 1.306e+05 0 423 10610 1.109e+05 1.954e+09 1 424 10635 1.109e+05 1.163e+05 0 425 10660 1.109e+05 1.117e+05 1 426 10685 1.109e+05 4.155e+09 0 427 10710 1.109e+05 1.125e+10 1 428 10735 1.109e+05 9.55e+09 0 429 10760 1.109e+05 1.123e+05 0 430 10785 1.109e+05 2.926e+09 1 431 10810 1.109e+05 6.408e+09 0 432 10835 1.109e+05 1.12e+05 1 433 10860 1.109e+05 1.133e+05 2 434 10885 1.109e+05 1.145e+05 3 435 10910 1.109e+05 7.4e+07 0 436 10935 1.109e+05 5.267e+09 1 437 10960 1.109e+05 3.403e+10 2 438 10985 1.109e+05 5.765e+09 3 439 11010 1.109e+05 1.64e+10 0 440 11035 1.109e+05 1.602e+08 0 441 11060 1.109e+05 1.315e+05 0 442 11085 1.109e+05 1.21e+05 0 443 11110 1.109e+05 5.981e+10 0 444 11135 1.109e+05 9.192e+07 0 445 11160 1.109e+05 7.423e+09 0 446 11185 1.109e+05 1.687e+08 1 447 11210 1.109e+05 1.166e+10 0 448 11235 1.109e+05 1.29e+09 0 449 11260 1.109e+05 3.025e+10 1 Best Mean Stall Generation Func-count Penalty Penalty Generations 450 11285 1.109e+05 4.537e+08 0 451 11310 1.109e+05 1.321e+05 0 452 11335 1.109e+05 9.301e+09 0 453 11360 1.109e+05 1.339e+05 0 454 11385 1.109e+05 1.106e+10 0 455 11410 1.109e+05 1.188e+05 0 456 11435 1.109e+05 1.151e+05 1 457 11460 1.109e+05 1.173e+05 0 458 11485 1.109e+05 1.112e+05 0 459 11510 1.109e+05 1.727e+09 0 460 11535 1.109e+05 1.111e+05 1 461 11560 1.109e+05 4.268e+09 0 462 11585 1.109e+05 8.568e+08 0 463 11610 1.109e+05 1.784e+08 0 464 11635 1.109e+05 3.634e+09 0 465 11660 1.109e+05 1.295e+10 0 466 11685 1.109e+05 6.012e+09 0 467 11710 1.109e+05 3.947e+08 0 468 11735 1.109e+05 1.129e+05 0 469 11760 1.109e+05 8.63e+08 0 470 11785 1.109e+05 1.119e+05 0 471 11810 1.109e+05 1.768e+10 0 472 11835 1.109e+05 8.364e+09 1 473 11860 1.109e+05 1.146e+05 0 474 11885 1.109e+05 1.419e+05 1 475 11910 1.109e+05 3.554e+09 0 476 11935 1.109e+05 1.658e+10 0 477 11960 1.109e+05 2.058e+09 1 478 11985 1.109e+05 3.714e+10 0 479 12010 1.109e+05 1.111e+05 0 Best Mean Stall Generation Func-count Penalty Penalty Generations 480 12035 1.109e+05 2.421e+08 1 481 12060 1.109e+05 1.113e+05 0 482 12085 1.109e+05 1.118e+05 0 483 12110 1.109e+05 1.116e+05 1 484 12135 1.109e+05 5.118e+09 0 485 12160 1.109e+05 4.843e+09 0 486 12185 1.109e+05 8.755e+09 0 487 12210 1.109e+05 6.559e+06 0 488 12235 1.109e+05 5.788e+08 0 489 12260 1.109e+05 1.988e+10 0 490 12285 1.109e+05 1.015e+09 1 491 12310 1.109e+05 7.71e+09 2 492 12335 1.109e+05 3.529e+09 3 493 12360 1.109e+05 1.303e+10 0 494 12385 1.109e+05 1.207e+05 1 495 12410 1.109e+05 1.184e+05 2 496 12435 1.109e+05 1.13e+05 0 497 12460 1.109e+05 1.029e+10 0 498 12485 1.109e+05 6.9e+09 0 499 12510 1.109e+05 1.116e+05 0 500 12535 1.109e+05 1.113e+05 0 501 12560 1.109e+05 1.531e+09 1 502 12585 1.109e+05 1.594e+09 2 503 12610 1.109e+05 1.274e+10 0 504 12635 1.109e+05 9.286e+09 0 505 12660 1.109e+05 1.131e+05 0 506 12685 1.109e+05 1.131e+05 0 507 12710 1.109e+05 4.227e+07 0 508 12735 1.109e+05 1.722e+09 0 509 12760 1.109e+05 7.935e+06 0 Best Mean Stall Generation Func-count Penalty Penalty Generations 510 12785 1.109e+05 1.42e+10 1 511 12810 1.109e+05 1.144e+05 0 512 12835 1.109e+05 1.774e+10 1 513 12860 1.109e+05 1.691e+10 0 514 12885 1.109e+05 1.38e+09 1 515 12910 1.109e+05 1.191e+05 0 516 12935 1.109e+05 9.77e+09 0 517 12960 1.109e+05 2.751e+09 1 518 12985 1.109e+05 2.757e+09 2 519 13010 1.109e+05 1.125e+05 3 520 13035 1.109e+05 1.131e+05 0 521 13060 1.109e+05 1.86e+09 1 522 13085 1.109e+05 3.484e+08 2 523 13110 1.109e+05 5.064e+08 3 524 13135 1.109e+05 1.118e+05 4 525 13160 1.109e+05 1.142e+05 5 526 13185 1.109e+05 2.449e+09 6 527 13210 1.109e+05 1.126e+05 0 528 13235 1.109e+05 1.745e+09 0 529 13260 1.109e+05 1.374e+05 0 530 13285 1.109e+05 1.788e+08 0 531 13310 1.109e+05 1.129e+05 0 532 13335 1.109e+05 2.963e+09 0 533 13360 1.109e+05 5.787e+09 0 534 13385 1.109e+05 4.926e+08 0 535 13410 1.109e+05 2.988e+07 0 536 13435 1.109e+05 1.164e+05 1 537 13460 1.109e+05 1.134e+05 2 538 13485 1.109e+05 1.211e+05 0 539 13510 1.109e+05 4.835e+09 1 Best Mean Stall Generation Func-count Penalty Penalty Generations 540 13535 1.109e+05 5.523e+08 0 541 13560 1.109e+05 1.288e+10 0 542 13585 1.109e+05 1.112e+05 1 543 13610 1.109e+05 1.121e+05 2 544 13635 1.109e+05 1.116e+05 3 545 13660 1.109e+05 1.181e+05 4 546 13685 1.109e+05 1.25e+10 0 547 13710 1.109e+05 5.683e+08 0 548 13735 1.109e+05 1.127e+05 1 549 13760 1.109e+05 3.736e+07 2 550 13785 1.109e+05 5.698e+09 0 551 13810 1.109e+05 1.11e+05 0 552 13835 1.109e+05 9.582e+09 0 553 13860 1.109e+05 1.902e+09 1 554 13885 1.109e+05 7.36e+10 2 555 13910 1.109e+05 5.144e+09 0 556 13935 1.109e+05 7.818e+08 1 557 13960 1.109e+05 1.205e+05 0 558 13985 1.109e+05 1.754e+10 0 559 14010 1.109e+05 1.157e+05 1 560 14035 1.109e+05 1.251e+05 2 561 14060 1.109e+05 3.835e+09 0 562 14085 1.109e+05 7.108e+09 0 563 14110 1.109e+05 3.776e+09 0 564 14135 1.109e+05 1.093e+09 0 565 14160 1.109e+05 1.242e+05 1 566 14185 1.109e+05 1.124e+05 0 567 14210 1.109e+05 1.599e+08 0 568 14235 1.109e+05 1.112e+05 0 569 14260 1.109e+05 1.119e+05 0 Best Mean Stall Generation Func-count Penalty Penalty Generations 570 14285 1.109e+05 1.124e+05 0 571 14310 1.109e+05 1.178e+05 1 572 14335 1.109e+05 2.62e+09 0 573 14360 1.109e+05 1.111e+05 0 574 14385 1.109e+05 1.936e+10 0 575 14410 1.109e+05 4.923e+09 1 576 14435 1.109e+05 1.113e+05 0 577 14460 1.109e+05 5.454e+09 1 578 14485 1.109e+05 3.911e+08 0 579 14510 1.109e+05 1.122e+05 0 580 14535 1.109e+05 1.166e+05 1 581 14560 1.109e+05 1.133e+05 0 582 14585 1.109e+05 1.119e+09 0 583 14610 1.109e+05 1.154e+05 1 584 14635 1.109e+05 1.133e+05 2 585 14660 1.109e+05 6.301e+07 0 586 14685 1.109e+05 1.274e+10 0 587 14710 1.109e+05 5.186e+09 1 588 14735 1.109e+05 4.83e+09 0 589 14760 1.109e+05 1.539e+10 1 590 14785 1.109e+05 2.431e+07 2 591 14810 1.109e+05 1.127e+05 3 592 14835 1.109e+05 1.133e+05 0 593 14860 1.109e+05 4.746e+09 0 594 14885 1.109e+05 1.134e+05 1 595 14910 1.109e+05 2.8e+09 0 596 14935 1.109e+05 3.687e+08 0 597 14960 1.109e+05 1.113e+05 1 598 14985 1.109e+05 1.164e+05 2 599 15010 1.109e+05 1.115e+05 0 Best Mean Stall Generation Func-count Penalty Penalty Generations 600 15035 1.109e+05 1.143e+05 1 601 15060 1.109e+05 1.275e+05 2 602 15085 1.109e+05 1.493e+10 0 603 15110 1.109e+05 7.873e+09 1 604 15135 1.109e+05 1.136e+05 0 605 15160 1.109e+05 6.079e+09 0 606 15185 1.109e+05 4.985e+08 0 607 15210 1.109e+05 1.237e+05 0 608 15235 1.109e+05 1.197e+05 0 609 15260 1.109e+05 1.733e+10 1 ga stopped because the average change in the penalty function value is less than options.FunctionTolerance and the constraint violation is less than options.ConstraintTolerance.
Nv = [Nv1,x(1:7-1)]
Nv = 1x7
1 1 7 1 1 1 1
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
K = [K1,x(7-1+1:7-1+7-1)]
K = 1x7
1 40 12 10 7 5 4
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
m = x(7-1+7-1+1:7-1+7-1+6)
m = 1x6
0.0062 0.0078 0.0071 0.0092 0.0120 0.0103
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
function Z = FitnessFcn(x,Nv1,K1)
Nv(1) = Nv1;
Nv(2:7) = x(1:7-1);
K(1) = K1;
K(2:7) = x(7-1+1:7-1+7-1);
m = x(7-1+7-1+1:7-1+7-1+6);
Tb=1.2;
Hb=[2.8 2.2 1.7 1.2 0.8 0.6 0 0];
Sb=[25 28 32 36 35 38 0 0];
F=[70 50 48 55 80 65 0 0];
Sv=[0 280 200 320 360 380 420 0];
Hv=[0 2.5 1.9 1.4 1 0.7 0.5 0];
D=[180000 200000 240000 300000 350000 400000 0 0];
P=[0 200000 240000 300000 350000 400000 450000 0];
q=[1 1 1 1 1 1 0 0];
u=[0.009 0.0064 0.0054 0.0072 0.01 0.008 0 0];
t=[0.015 0.01 0.009 0.012 0.016 0.014 0 0];
w=[0.005 0.004 0.003 0.004 0.006 0.004 0 0];
Se=[29 32 38 42 37 40 0 0];
n=[1 0.9 0.75 0.6 0.51 0.45];
p=[3.2 2.6 2.1 1.6 1.2 0.9 0 0];
Nb=[1 1 1 1 1 1 0 0];
idx = 1:6;
Nvc = cumprod(Nv(idx+1));
Nvb = cumprod(Nv(idx));
Z = sum(n(idx).*Tb.*Hb(idx).*D(idx).*(m(idx)-u(idx))+...
(n(idx)*Tb).^2./(Nvc.*K(idx+1)).* ...
(D(idx)/2.*(Hb(idx)+Hv(idx+1)-2*Hv(idx+1).*(1-D(idx)./P(idx+1))))+ ...
Nvc.*K(idx+1).*(Se(idx).*(t(idx)-m(idx)).^3.*(t(idx)+3*m(idx)-4*w(idx)) ...
./(t(idx)-w(idx)).^4 +(Hb(idx)+p(idx)).*D(idx).*(t(idx)-m(idx)).^5.*(2*t(idx)+3*m(idx)-5*w(idx)) ...
./(5*(t(idx)-w(idx)).^4)+F(idx))+Nvc.*Sv(idx+1)+...
(n(idx)*Tb).^2./Nvc.*(Hv(idx+1).*D(idx)/2.*(1-D(idx)./P(idx+1)))...
+ Nvb.*Nb(idx).*Sb(idx));
end
  5 commentaires
Torsten
Torsten le 9 Avr 2024
Modifié(e) : Torsten le 9 Avr 2024
You set Nv(1) and K(1) to values of your choice, and the values you get from ga are Nv(2:7), K(2:7) and m(1:6).
I changed the code from above a bit - maybe it's easier for you to understand what's going on this way.
HSUAN
HSUAN le 9 Avr 2024
I roughly understand it. Thank you for your patience in explaining.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Simulink dans Help Center et File Exchange

Tags

Produits


Version

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by