.
, , , . . . .
, , , . . , .
. , . . , , , .
, Rank, . : 1, 2 . , :
20 , .
.
, . , , , , , 20, 32.
.
, , , . , , . .
20 32 .
, , . .
. , . Stochastic uniform , , . , . , .
Remainder, :
. :
. , , :
. . , , , . , .
.
:
, Population size 20, Elite count 2 Crossover fraction 0.8 :
Mutation function. , mutation, . , , , . Scale Shrink :
. , , . , , . . , .
Distance Range Shrink 0.5.
Shrink 0,5, ½ . , .
Crossover fraction Reproduction , , . 1 , , , , 0 , . , .
, . ,
, Fitness function
@(x)sum(abs(x))
:
0,8 Crossover fraction. 0,2 .
, , Crossover fraction 1.0 Start. 1,3 .
. , - . , 8, . , , . 17 , , . 0. 8 , 50 , Stall generations 50.
, , Crossover fraction 0 Start. 3,5 .
- . , , . , 50.
deterministicstudy.m Crossover fraction 0, .2, .4, .6, .8 1. 10 . Crossover fraction.
deterministicstudy
MATLAB. .
10 . .
Crossover fraction 0,8 . , Crossover fraction .
, .. , . , , .. , , , . .
:
, x = 0, - 1, = 21, 1 - 1/e. , = 21.
:
function y = two_min(x) if x<20 y = -exp(-(x/20).^2); else y = -exp(-1)+(x-20)*(x-22); end
x = 0.
, . .
, -2 2.5. Initial range [0;1], , , x = 21.
, .. , Initial range. Initial range x = 21, , 21. Initial range [0;15], .
Start. 21.
. 21 12 , 21.
, . . Hybrid function.
fminunc, . , fminunc.
,
.
- dejong2fcn.m.
hybriddemo
MATLAB.
, gatool :
Start. Status and results .
(1, 1). Hybrid function fminunc.
fminunc , Status and results.
Generations Stopping criteria , . Generations, , .
:
300 Stop. Best fitness 300 .
, 170 - , 170 . Stall generations 50, 230. Generations, Generations Stall generations. , , .
. Mutation function Gaussian, Generations . , , Generations. , Generations .
, . , . , . .
- , , . ,
- :
z =x(:,1).^2 - 2*x(:,1).*x(:,2) + 6*x(:,1) + x(:,2).^2 - 6*x(:,2);
, x(:, 1) . .^ .*
Vectorize On.
. Vectorize , .
, , , Vectorize.
tic;ga(@rastriginsfcn,20);toc elapsed_time = 4.3660 options=gaoptimset('Vectorize','on'); tic;ga(@rastriginsfcn,20,options);toc elapsed_time = 0.5810
Generations Stopping criteria , . Generations, , .
:
@rastriginsfcn
.
10
.
Inf
.
Inf
.
Inf
300 Stop. Best fitness 300 .
, 170 - , 170 . Stall generations 50, 230. Generations, Generations Stall generations. , , .
. Mutation function Gaussian, Generations . , , Generations. , Generations .
, . , . , . .
- , , . , .
- :
z =x(:,1).^2 - 2*x(:,1).*x(:,2) + 6*x(:,1) + x(:,2).^2 - 6*x(:,2);
, x (:, 1) . .^ .* .
Vectorize On
.
. Vectorize , .
, , , Vectorize.
tic;ga(@rastriginsfcn,20);toc elapsed_time = 4.3660 options=gaoptimset('Vectorize','on'); tic;ga(@rastriginsfcn,20,options);toc elapsed_time = 0.5810
x1 and x2
. , - simple_fitness.m
function y = simple_fitness(x) y = 100 * (x(1)^2 - x(2)) ^2 + (1 - x(1))^2;
, ga, , x, x , . y.
- simple_fitness.m,
function [c, ceq] = simple_constraint(x) c = [1.5 + x(1)*x(2) + x(1) - x(2); -x(1)*x(2) + 10]; ceq = [];
, ga x, x , . , ceq c, .
, ga, . LB UB . , .
ObjectiveFunction = @simple_fitness; nvars = 2; % Number of variables LB = [0 0]; % Lower bound UB = [1 13]; % Upper bound ConstraintFunction = @simple_constraint; [x,fval] = ga(ObjectiveFunction,nvars,[],[],[],[],LB,UB,ConstraintFunction) Warning: 'mutationgaussian' mutation function is for unconstrained minimization only; using @mutationadaptfeasible mutation function. Set @mutationadaptfeasible as MutationFcn options using GAOPTIMSET. Optimization terminated: current tolerance on f(x) 1e-007 is less than options.TolFun and constraint violation is less than options.TolCon. x = 0.8122 12.3122 fval = 1.3578e+004
ga @mutationadaptfeasible. @mutationgaussian
. . ga . ga , .
ga . ga , . , ga, mutationguassian , , mutationadaptfeasible. , , . , crossoverheuristic.
gaoptimset mutationadaptfeasible
options = gaoptimset('MutationFcn',@mutationadaptfeasible);
ga.
[x,fval] = ga(ObjectiveFunction,nvars,[],[],[],[],LB,UB,ConstraintFunction,options) Optimization terminated: current tolerance on f(x) 1e-007 is less than options.TolFun and constraint violation is less than options.TolCon. x = 0.8122 12.3122 fval = 1.3578e+004
gaoptimset , . gaplotbestf, . gaplotmaxconstr, . 'Display' .
options = gaoptimset(options,'PlotFcns',{@gaplotbestf,@gaplotmaxconstr},'Display','iter');
ga, :
[x,fval] = ga(ObjectiveFunction,nvars,[],[],[],[],LB,UB,ConstraintFunction,options) Best max Stall Generation f-count f(x) constraint Generations 1 849 14915.8 0 0 2 1567 13578.3 0 0 3 2334 13578.3 0 1 4 3043 13578.3 0 2 5 3752 13578.3 0 3 Optimization terminated: current tolerance on f(x) 1e-009 is less than options.TolFun and constraint violation is less than options.TolCon. x = 0.8122 12.3123 fval = 1.3578e+004
InitialPopulation ga. , ga InitialPopulation .
X0 = [0.5 0.5]; % Start point (row vector) options = gaoptimset(options,'InitialPopulation',X0); ga. [x,fval] = ga(ObjectiveFunction,nvars,[],[],[],[],LB,UB,ConstraintFunction,options) Best max Stall Generation f-count f(x) constraint Generations 1 965 13579.6 0 0 2 1728 13578.2 1.776e-015 0 3 2422 13578.2 0 0 Optimization terminated: current tolerance on f(x) 1e-007 is less than options.TolFun and constraint violation is less than options.TolCon. x = 0.8122 12.3122 fval = 1.3578e+004
ga . , , :
a, b, c. ga , ga a, b c. :
, . , patternsearch ga, patternsearch ga.
- :
function y = parameterfun(x,a,b,c) y = (a - b*x(1)^2 + x(1)^4/3)*x(1)^2 + x(1)*x(2) + ... (-c + c*x(2)^2)*x(2)^2;
- MATLAB parameterfun.m
a = 4, b =2.1, c = 4. MATLAB .
a = 4; b = 2.1; c = 4; % Define parameter values fitfun = @(x) parameterfun(x,a,b,c); NVARS = 3;
,
a = 3.6; b = 2.4; c = 5; % Define parameter values fitfun = @(x) parameterfun(x,a,b,c);
-, :
-.
function [x fval] = runga(a,b,c,NVARS) [x, fval] = ga(@nestedfun,NVARS); % function y = nestedfun(x) y = (a - b*x(1)^2 + x(1)^4/3)*x(1)^2 + x(1)*x(2) + ... (-c + c*x(2)^2)*x(2)^2; end end
, nestedfun, a, b c.
[x fval] = runga(a,b,c,NVARS)
Optimization terminated: average change in the fitness value less than options.TolFun. x = -0.1302 0.7170 0.2272 fval = -1.0254
10.11.2021 - 12:37: - Personalias -> WHO IS WHO - - _. 10.11.2021 - 12:36: - Conscience -> . ? - _. 10.11.2021 - 12:36: , , - Upbringing, Inlightening, Education -> ... - _. 10.11.2021 - 12:35: - Ecology -> - _. 10.11.2021 - 12:34: , - War, Politics and Science -> - _. 10.11.2021 - 12:34: , - War, Politics and Science -> . - _. 10.11.2021 - 12:34: , , - Upbringing, Inlightening, Education -> , - _. 10.11.2021 - 09:18: - New Technologies -> , 5G- - _. 10.11.2021 - 09:18: - Ecology -> - _. 10.11.2021 - 09:16: - Ecology -> - _. 10.11.2021 - 09:15: , , - Upbringing, Inlightening, Education -> - _. 10.11.2021 - 09:13: , , - Upbringing, Inlightening, Education -> - _. |