matlab 案例 订单分配,案例28 基于灰色神经网络的预测算法研究—订单需求预测...

%% 清空环境变量

clc

clear

X=[18.9        993        662        6.7        1.92                411        438

16.6        952        702        6.7        2                279        278

20.9        926        658        6.9        2.08                378        439

17        966        674        6.6        2                335        314

18.1        1108        689        7.1        1.6                243        209

18.4        883        637        6.6        2                379        371

18.3        1012        685        6.4        2                391        395

20.7        1119        684        6.5        1.68                383        411

18.9        929        719        6.3        1.76                383        358

18.8        1071        681        6.4        1.84                381        383

18.1        940        722        6.8        1.8                386        396

18.9        984        655        6.5        1.6                375        385

18.8        999        717        6.3        1.68                368        365

18.6        926        681        6.6        1.68                356        338

18.9        927        699        6.3        1.8                373        367

18.7        872        730        6.5        1.2                355        321

11.4        444        698        1.7        0                175        115

11.3        896        590        7.1        1.44                71        52

17        981        655        7.2        1.68                152        181

17        1133        733        7.2        1.75                332        341

18.7        1138        711        6.8        1.92                341        341

18.9        993        662        6.7        1.92                411        438

16.6        952        702        6.7        2                279        278

18.9        926        658        6.9        2.08                378        439

20.7        1084        694        6.4        2                346        364

18.9        1040        668        6.6        2                365        351

18.7        1067        727        6.9        2.04                401        360

18.8        1048        732        7.1        2.08                332        270

19.1        1177        680        6.5        1.92                372        370

19.1        1130        735        5.8        1.76                362        298

18.4        1111        700        6.7        1.68                385        369

18.9        1157        714        6.4        1.84                374        348

17.7        1112        687        7.2        2                355        301

19.3        1162        713        6.8        2.04                358        352

20.6        1090        729        6.9        2.16                314        326

20.7        1060        552        6.5        2                369        387

17.1        1135        691        6.6        1.92                370        355

20.6        1087        702        6.7        1.93                395        408

20.7        1141        722        6.7        2                393        427

19        1131        677        6.7        1.88                396        362

20.6        1123        710        5.8        2                379        388

20.1        1150        690        7        2.04                379        363

19.4        1023        714        6.6        1.92                398        328

17.1        1062        729        5.3        1.96                324        324

20.6        1140        712        6.4        2.06                312        415

19.7        1049        711        6.7        1.44                401        310

17.1        1074        645        6.6        2                347        324

17.3        1059        702        6.4        1.6                346        372

];

%% 数据累加作为网络输入

[n,m]=size(X);

for i=1:n

y(i,1)=sum(X(1:i,1));

y(i,2)=sum(X(1:i,2));

y(i,3)=sum(X(1:i,3));

y(i,4)=sum(X(1:i,4));

y(i,5)=sum(X(1:i,5));

y(i,6)=sum(X(1:i,6));

y(i,7)=sum(X(1:i,7));

end

%% 网络参数初始化

a=0.3+rand(1)/4;

b1=0.3+rand(1)/4;

b2=0.3+rand(1)/4;

b3=0.3+rand(1)/4;

b4=0.3+rand(1)/4;

b5=0.3+rand(1)/4;

b6=0.3+rand(1)/4;

%% 学习速率初始化

u1=0.0015;

u2=0.0015;

u3=0.0015;

u4=0.0015;

u5=0.0015;

u6=0.0015;

%% 权值阀值初始化

t=1;

w11=a;

w21=-y(1,1);

w22=2*b1/a;

w23=2*b2/a;

w24=2*b3/a;

w25=2*b4/a;

w26=2*b5/a;

w27=2*b6/a;

w31=1+exp(-a*t);

w32=1+exp(-a*t);

w33=1+exp(-a*t);

w34=1+exp(-a*t);

w35=1+exp(-a*t);

w36=1+exp(-a*t);

w37=1+exp(-a*t);

theta=(1+exp(-a*t))*(b1*y(1,2)/a+b2*y(1,3)/a+b3*y(1,4)/a+b4*y(1,5)/a+b5*y(1,6)/a+b6*y(1,7)/a-y(1,1));

kk=1;

%% 循环迭代

for j=1:7

%循环迭代

E(j)=0;

for i=1:48

%% 网络输出计算

t=i;

LB_b=1/(1+exp(-w11*t));   %LB层输出

LC_c1=LB_b*w21;           %LC层输出

LC_c2=y(i,2)*LB_b*w22;    %LC层输出

LC_c3=y(i,3)*LB_b*w23;    %LC层输出

LC_c4=y(i,4)*LB_b*w24;    %LC层输出

LC_c5=y(i,5)*LB_b*w25;    %LC层输出

LC_c6=y(i,6)*LB_b*w26;

LC_c7=y(i,7)*LB_b*w27;%LC层输出

LD_d=w31*LC_c1+w32*LC_c2+w33*LC_c3+w34*LC_c4+w35*LC_c5+w36*LC_c6+w37*LC_c7;    %LD层输出

theta=(1+exp(-w11*t))*(w22*y(i,2)/2+w23*y(i,3)/2+w24*y(i,4)/2+w25*y(i,5)/2+w26*y(i,6)/2+w27*y(i,7)/2-y(1,1));   %阀值

ym=LD_d-theta;   %网络输出值

yc(i)=ym;

%% 权值修正

error=ym-y(i,1);      %计算误差

E(j)=E(j)+abs(error);    %误差求和

error1=error*(1+exp(-w11*t));     %计算误差

error2=error*(1+exp(-w11*t));     %计算误差

error3=error*(1+exp(-w11*t));

error4=error*(1+exp(-w11*t));

error5=error*(1+exp(-w11*t));

error6=error*(1+exp(-w11*t));

error7=error*(1+exp(-w11*t));

error8=(1/(1+exp(-w11*t)))*(1-1/(1+exp(-w11*t)))*(w21*error1+w22*error2+w23*error3+w24*error4+w25*error5+w26*error6+w27*error7);

%修改权值

w22=w22-u1*error2*LB_b;

w23=w23-u2*error3*LB_b;

w24=w24-u3*error4*LB_b;

w25=w25-u4*error5*LB_b;

w26=w26-u5*error6*LB_b;

w27=w27-u6*error7*LB_b;

w11=w11+a*t*error8;

end

end

%画误差随进化次数变化趋势

figure(1)

plot(E)

title('训练误差','fontsize',8);

xlabel('进化次数','fontsize',8);

ylabel('误差','fontsize',8);

%print -dtiff -r600 28-3

%根据训出的灰色神经网络进行预测

for i=41:48

t=i;

LB_b=1/(1+exp(-w11*t));   %LB层输出

LC_c1=LB_b*w21;           %LC层输出

LC_c2=y(i,2)*LB_b*w22;    %LC层输出

LC_c3=y(i,3)*LB_b*w23;    %LC层输出

LC_c4=y(i,4)*LB_b*w24;    %LC层输出

LC_c5=y(i,5)*LB_b*w25;

LC_c6=y(i,6)*LB_b*w26;

LC_c7=y(i,7)*LB_b*w27;

LD_d=w31*LC_c1+w32*LC_c2+w33*LC_c3+w34*LC_c4+w35*LC_c5+w36*LC_c6+w37*LC_c7;    %LD层输出

theta=(1+exp(-w11*t))*(w22*y(i,2)/2+w23*y(i,3)/2+w24*y(i,4)/2+w25*y(i,5)/2+w26*y(i,6)/2+w27*y(i,7)/2-y(1,1));   %阀值

ym=LD_d-theta;   %网络输出值

yc(i)=ym;

end

yc=yc;

y(:,1)=y(:,1);

%计算预测的每月需求量

for j=48:-1:2

ys(j)=(yc(j)-yc(j-1))/10;

end

figure(2)

plot(ys(41:48),'-*');

hold on

plot(X(41:48,1),'r

af5d80d43c9b6e247a4fd2033f52f198.gif');

legend('灰色神经网络','烧结终点')

title('灰色系统预测','fontsize',8)

xlabel('月份','fontsize',8)

ylabel('销量','fontsize',8)

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值