📄 sele_genet.m
字号:
function x=sele_genet(dir);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% OP钦ES DO ALGORITMO GEN蒚ICO
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Popsize=30;
tam_cro=20;
rand('twister' ,110);
randn('state' ,110);
options = gaoptimset;
Mat =uint8(logical(0.5 > rand(Popsize,tam_cro))); %initial population
options = gaoptimset(options,'PopulationSize',Popsize);
options = gaoptimset(options,'InitialPopulation',Mat); %define the initial population
options = gaoptimset(options,'Generations',50);
options = gaoptimset(options,'StallGenLimit' ,50);
%options = gaoptimset(options,'FitnessScalingFcn',@fitscalingtop);
options = gaoptimset(options,'PopulationType' ,'bitString');
options = gaoptimset(options,'SelectionFcn' ,@selectionroulette);
%options = gaoptimset(options,'SelectionFcn' ,{@selectiontournament 4});
%options = gaoptimset(options,'CrossoverFcn' , @crossovertwopoint);
options = gaoptimset(options,'CrossoverFcn' , @crossoversinglepoint);
options = gaoptimset(options,'CrossoverFraction',0.8);
options = gaoptimset(options,'MutationFcn' ,{@mutationuniform 0.2 });
options = gaoptimset(options,'EliteCount' ,1);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% IMPORTA O VETOR DE CARACTER蚐TICAS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
rawData1 = importdata(dir);
C=rawData1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EXECUTA O ALGORITMO GEN蒚ICO
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Fitness_Function = @(x) fun_custo_nn(x,C);
[x,fval,reason,output,population,scores] = ga(Fitness_Function,tam_cro,[],[],[],[],[],[],[],options)
fid = fopen('coor_res.txt', 'wt');
fprintf(fid, '%d ', x);
fclose(fid)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -