⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 untitled.m

📁 免疫算法实现多峰、多极值函数平面曲面拟合
💻 M
字号:
clear('all');
clc;
load('matlabhia31.mat');
% record how many times have the parameters been changed
dynamic_counter=1;
max_change_time=100;
per_evo_time=20;
result3=result2;
% -------------------------------------
proo=zeros(per_evo_time+2,max_change_time);
% main loop
% -------------------------------------
% caculate the importance of each neuron
importance=judge(result2,t_x,t_y);
% find out the global-fix neurons
ss=20;
global_neuron_idx=find(importance>ss);
global_neuron_num=length(global_neuron_idx);
while(global_neuron_num<10||global_neuron_num>20)
if(global_neuron_num<10)
ss=ss-1;
end
if(global_neuron_num>20)
ss=ss+1;
end
global_neuron_idx=find(importance>ss);
global_neuron_num=length(global_neuron_idx);
end
% the number of subtle-fix neurons
subtle_neuron_num=size(result2,1)-global_neuron_num;
subtle_neuron_idx=1:size(result2,1);
% remove the global neurons from the individual
subtle_neuron_idx(global_neuron_idx)=[];
% generate the dynamic training sets
[t_x,t_y,te_x,te_y]=drosen;
winner_fitness=fitness(result2,t_x,t_y);
pro(per_evo_time+1,dynamic_counter)=winner_fitness;
% calculate the fitness value of the static individual
winner_fitness=fitness(result3,t_x,t_y);
proo(per_evo_time+1,dynamic_counter)=winner_fitness;
fprintf('dynamic counter: %d\ncurrent fitness: %f\n',dynamic_counter,winner_fitness);
% re-modify if the error exceed the tolerance
% ---------------------------------
tic;
% find the samples that need further modification
ss=0.0001;
err_idx=find_error(result2,t_x,t_y,ss);
while(length(err_idx)>40)
ss=ss+0.0001;
err_idx=find_error(result2,t_x,t_y,ss);
end
err_x=t_x(:,err_idx);
plot(err_x(1,:),err_x(2,:),'*');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -