返回   MATLAB中国论坛|MATLAB爱好者之家—不仅仅是MATLAB! > 人工智能|模式识别|机器学习|数字图像处理|SAR图像处理-不仅仅是MATLAB! > 遗传算法(GA)


遗传算法(GA) A discussion board for Genetic Algorithm(GA)



回复
 
LinkBack 主题工具 显示模式
旧 2012-04-05, 08:39 PM   #1
初级会员
 
注册日期: 2011-12-04
帖子: 2
感谢他人: 0
有 0 帖获得 0 感谢
声望力: 0
zhongyubin190 正向着好的方向发展
默认 问问这个程序中预测部分是什么意思?尤其是i前面的系数

%This program is useful to forecaste the ridership of Beijing
%public transportation


% Get the input sampledata from the .txt file "sample.txt"
fid=fopen('sample.txt','rt');
%fopend 打开文件函数
originalData=fscanf(fid,'%f', [20,14]);
%fscanf 将文件转成矩阵
status=fclose(fid);
%fclose 关闭文件函数
% transport sampledata into input training sampledata
inputSampledata=originalData';
%'矩阵转置

% Get the output sampledata from the .txt file "goal.txt"
fid=fopen('goal.txt','rt');
outputData=fscanf(fid,'%f');
status=fclose(fid);
% transport sampledata into input training sampledata
outputSampledata=outputData';

% creating neural network and setting trainging parameters
gwwnet=newff(minmax(inputSampledata),[4,1],{'tansig','purelin'},'traingdm');
%newff 建立神经网络函数
%minmax 得到最小值和最大值
%traingdm 下降法

gwwnet.trainParam.show = 50;
%每50循环显示一次
gwwnet.trainParam.lr = 0.05;
%步长
gwwnet.trainParam.epochs = 50000;
%50000次停止学习
gwwnet.trainParam.goal = 1e-3;
%le-3停止学习

%data scaling (converting the network input and output data to the intervel [-1,1])
[input,mininput,maxinput,output,minoutput,maxoutput] = premnmx(inputSampledata,outputSampledata);
%premnmx -1到1之间的数

%training
[gwwnet,tr]=train(gwwnet,input,output);
%训练
y=sim(gwwnet,input);
%仿真

%data offset (converting the network output data to it original unit)
nnoutput = postmnmx(y,minoutput,maxoutput);
%postmnmx 从-1到1返回实际值

%plot 画图
time=1978:1:1997;
plot(time,outputSampledata,'-',time,nnoutput,'o');
%legend('actual output','NN output');
xlabel('time');ylabel('Learning fitting curve');


%scenario1 forecasting process 预测输入
column=10;
for i=1:column;
SceInput(1,i)=inputSampledata(1,20)*(1.0464^i);
SceInput(2,i)=inputSampledata(2,20)*(1.0631^i);
SceInput(3,i)=inputSampledata(3,20)*(1.0872^i);
SceInput(4,i)=inputSampledata(4,20)*(1.2044^i);
SceInput(5,i)=inputSampledata(5,20)*(1.2326^i);
SceInput(6,i)=inputSampledata(6,20)*(1.0605^i);
SceInput(7,i)=2*(1.01^i);
SceInput(8,i)=42*(1.02^i);
SceInput(9,i)=inputSampledata(9,20)*(1.1426^i);
SceInput(10,i)=inputSampledata(10,20)*(1.017^i);
SceInput(11,i)=inputSampledata(11,20)*(1.0205^i);
SceInput(12,i)=inputSampledata(12,20)*(1.1336^i);
SceInput(13,i)=inputSampledata(13,20)*(1.1599^i);
SceInput(14,i)=inputSampledata(14,20)*(1.1783^i);
end

for j=1:20;
for i=1:14;
recalldata(i,j)=inputSampledata(i,j);
end
end

for j=21:30;
for i=1:14;
recalldata(i,j)=SceInput(i,j-20)
end
end

[alterinput,mininput,maxinput] = premnmx(recalldata);

%alterinput和input发生变化
%可以制定一个最大值和最小值


%training
fvalue=sim(gwwnet,alterinput);

%data offset (converting the network output data to it original unit)
forecastvalue = postmnmx(fvalue,minoutput,maxoutput);

%plot

waitforbuttonpress;
clf;
time=1978:1:2007;
time1=1978:1:1997;
plot(time,forecastvalue,'o',time1,outputSampledata,'-');
%legend('预测曲线','实际曲线');
title('客运量曲线');
xlabel('时间');ylabel('公交客运量');
zhongyubin190 当前离线   回复时引用此帖
回复

书签

主题工具
显示模式

发帖规则
不可以发表新主题
可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码
Trackbacks are 禁用
Pingbacks are 禁用
Refbacks are 启用



所有时间均为北京时间。现在的时间是 01:52 AM


Powered by vBulletin
版权所有 ©2000 - 2017,Jelsoft Enterprises Ltd.
陕ICP备07001583号

SEO by vBSEO ©2009, Crawlability, Inc.