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

📄 da_gan.m

📁 收集的GA的一些源程序
💻 M
字号:
%
% da_gan.m
%
% Genetic dynamic neural netowork
%

global stop;
stop=0;
da_front;
drawnow;
set(w1,'NumberTitle','off','Name','GA trained dynamic neural network');

%
% Print title
%

text1=da_text(w1,135,410,350,15,'Using previously select variables and I/Os for model building',[1 1 1],[1 0 0]);


%
% Genetic Algorithm Parameters
%
box1=uicontrol(w1,...
	'style','frame',...
	'position',[50 200 520 200],...
	'foregroundColor',[1 1 1],...
	'backgroundcolor',[0 0 1]);

text2=da_text(w1,55,380,200,15,'Genetic Algorithm parameters',[1 1 1],[1 0 0]);

%
% Stuff for popultaion size
%
text3=da_text(w1,60,350,100,15,'Population size:',[1 1 1],[0 0 1]);
sl1=uicontrol(w1,...
	'style','slider',...
	'position',[220,350,150,20],...
	'min',5,...
	'max',50,...
	'value',20,...
	'callback','set(sl1_current,''String'',[''Size = '' num2str(ceil(get(sl1,''value'')))]);');

sl1_current=da_text(w1,280,370,90,15,['Size = 20'],[1 1 1],[0 0 1]);
sl1_min=da_text(w1,200,350,15,15,'5',[1 1 1],[0 0 1]);
sl1_max=da_text(w1,375,350,20,15,'50',[1 1 1],[0 0 1]);

%
% Mutation probability
%
text4=da_text(w1,60,305,120,15,'Mutation probability:',[1 1 1],[0 0 1]);
sl2=uicontrol(w1,...
	'style','slider',...
	'position',[220 305 150 20],...
	'min',0,...
	'max',1,...
	'value',0.1,...
	'callback','set(sl2_current,''String'',[''Probability = '' num2str(get(sl2,''value''))]);');

sl2_current=da_text(w1,250,325,120,15,'Probability = 0.1',[1 1 1],[0 0 1]);
sl2_min=da_text(w1,200,305,15,15,'0',[1 1 1],[0 0 1]);
sl2_max=da_text(w1,375,305,20,15,'1',[1 1 1],[0 0 1]);

%
% Cross over probability
%
text5=da_text(w1,60,260,130,15,'Cross over probability:',[1 1 1],[0 0 1]);
sl3=uicontrol(w1,...
	'style','slider',...
	'position',[220 260 150 20],...
	'min',0,...
	'max',1,...
	'value',0.2,...
	'callback','set(sl3_current,''string'',[''Probability = '' num2str(get(sl3,''value''))]);');

sl3_current=da_text(w1,250,280,120,15,'Probability = 0.2',[1 1 1],[0 0 1]);
sl3_min=da_text(w1,200,260,15,15,'0',[1 1 1],[0 0 1]);
sl3_max=da_text(w1,375,260,20,15,'1',[1 1 1],[0 0 1]);

%
% Maximum number of generations
%
text6=da_text(w1,60,215,130,15,'Max generations',[1 1 1],[0 0 1]);
sl4=uicontrol(w1,...
	'style','slider',...
	'position',[220 215 150 20],...
	'min',1,...
	'max',10000,...
	'value',250,...
	'callback','set(sl4_current,''string'',[''Max = '' num2str(ceil(get(sl4,''value'')))]);');

sl4_current=da_text(w1,250,235,120,15,'Max = 250',[1 1 1],[0 0 1]);
sl4_min=da_text(w1,200,215,15,15,'1',[1 1 1],[0 0 1]);
sl4_max=da_text(w1,375,215,40,15,'10000',[1 1 1],[0 0 1]);


%
% When to plot results
%
text7=da_text(w1,50,160,150,15,'Plot results every:',[1 1 1],[0 0 1]);
text9=da_text(w1,250,160,80,15,'generations',[1 1 1],[0 0 1]);
text8=uicontrol(w1,...
	'style','edit',...
	'position',[205 160 30 15],...
	'string','1',...
	'Backgroundcolor',[1 0 0],...
	'foregroundcolor',[1 1 1],...
	'callback',[
		'a=get(text8,''string'');',...
		'a=str2num(a);',...
		'if a ~= [];',...
			'set(text8,''string'',num2str(a));',...
		'else;',...
			'set(text8,''string'',''2'');',...
		'end']);
%
% Regression options
%
text10=da_text(w1,50,130,150,15,'Weight values - Min:',[1 1 1],[0 0 1]);
text11=uicontrol(w1,...
	'style','edit',...
	'position',[205 130 30 15],...
	'string','-2',...
	'backgroundcolor',[1 0 0],...
	'foregroundcolor',[1 1 1],...
	'callback',[
		'a=get(text11,''string'');',...
		'a=str2num(a);',...
		'if a ~= [];',...
			'set(text11,''string'',num2str(a));',...
		'else;',...
			'set(text11,''string'',''1'');',...
		'end']);
text12=da_text(w1,250,130,80,15,'Resolution:',[1 1 1],[0 0 1]);
text13=uicontrol(w1,...
	'style','edit',...
	'position',[340 130 50 15],...
	'string','0.01',...
	'backgroundcolor',[1 0 0],...
	'foregroundcolor',[1 1 1],...
	'callback',[
		'a=get(text13,''string'');',...
		'a=str2num(a);',...
		'if a ~= [];',...
			'set(text13,''string'',num2str(a));',...
		'else;',...
			'set(text13,''string'',''0.01'');',...
		'end']);

text14=da_text(w1,420,130,30,15,'Max:',[1 1 1],[0 0 1]);
text15=uicontrol(w1,...
	'style','edit',...
	'position',[455 130 30 15],...
	'string','2',...
	'backgroundcolor',[1 0 0],...
	'foregroundcolor',[1 1 1],...
	'callback',[
		'a=get(text15,''string'');',...
		'a=str2num(a);',...
		'if a ~= [];',...
			'set(text15,''string'',num2str(a));',...
		'else;',...
			'set(text15,''string'',''3'');',...
		'end']);

%
% Filter options
%
text16=da_text(w1,50,100,150,15,'Filter coefficients - Min:',[1 1 1],[0 0 1]);
text17=uicontrol(w1,...
	'style','edit',...
	'position',[205 100 30 15],...
	'string','0',...
	'backgroundcolor',[1 0 0],...
	'foregroundcolor',[1 1 1],...
	'callback',[
		'a=get(text17,''string'');',...
		'a=str2num(a);',...
		'if a ~= [];',...
			'set(text17,''string'',num2str(a));',...
		'else;',...
			'set(text17,''string'',''0'');',...
		'end']);
text18=da_text(w1,250,100,80,15,'Resolution:',[1 1 1],[0 0 1]);
text19=uicontrol(w1,...
	'style','edit',...
	'position',[340 100 50 15],...
	'string','0.01',...
	'backgroundcolor',[1 0 0],...
	'foregroundcolor',[1 1 1],...
	'callback',[
		'a=get(text19,''string'');',...
		'a=str2num(a);',...
		'if a ~= [];',...
			'set(text19,''string'',num2str(a));',...
		'else;',...
			'set(text19,''string'',''0.01'');',...
		'end']);

text20=da_text(w1,420,100,30,15,'Max:',[1 1 1],[0 0 1]);
text21=uicontrol(w1,...
	'style','edit',...
	'position',[455 100 30 15],...
	'string','1',...
	'backgroundcolor',[1 0 0],...
	'foregroundcolor',[1 1 1],...
	'callback',[
		'a=get(text21,''string'');',...
		'a=str2num(a);',...
		'if a ~= [];',...
			'set(text21,''string'',num2str(a));',...
		'else;',...
			'set(text21,''string'',''1'');',...
		'end']);
%
% Begin button
%
but1=uicontrol(w1,...
	'style','push',...
	'position',[450 290 80 40],...
	'string','START !',...
	'callback','ganeural;');

%
% Box for the number of input nodes
%
text22=da_text(w1,50,70,150,15,'Hidden nodes:',[1 1 1],[0 0 1]);

text23=uicontrol(w1,...
	'style','edit',...
	'position',[205 70 30 15],...
	'string','5',...
	'backgroundcolor',[1 0 0],...
	'foregroundcolor',[1 1 1],...
	'callback',[
		'a=get(text23,''string'');',...
		'a=str2num(a);',...
		'if a ~= [];',...
			'set(text23,''string'',num2str(a));',...
		'else;',...
			'set(text23,''string'',''1'');',...
		'end']);           

%
% Train/test split
%
text24=da_text(w1,50,40,150,15,'Train/Test split (%):',[1 1 1],[0 0 1]);
text25=uicontrol(w1,...
	'style','edit',...
	'position',[205 40 30 15],...
	'string','75',...
	'backgroundcolor',[1 0 0],...
	'foregroundcolor',[1 1 1],...
	'callback',[
		'a=get(text25,''string'');',...
		'a=str2num(a);',...
		'if a ~= [];',...
			'set(text25,''string'',num2str(a));',...
		'else;',...
			'set(text25,''string'',''1'');',...
		'end']);           

⌨️ 快捷键说明

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