数学建模源程序.docx
- 文档编号:25406790
- 上传时间:2023-06-08
- 格式:DOCX
- 页数:42
- 大小:20.37KB
数学建模源程序.docx
《数学建模源程序.docx》由会员分享,可在线阅读,更多相关《数学建模源程序.docx(42页珍藏版)》请在冰豆网上搜索。
数学建模源程序
2014南京理工大学大学生数学建模竞赛
参赛队员:
1.陈敏
2.王婧铭
3.孙玉娟
二胎政策的影响
问题一模型程序及结果
程序如下:
w1=[3447004432416884346411854798428463403945501768144761638157634855611452865181813538389937402295362883285620364811165689441257327474556963432118104743525226327082];%2010年各年龄段女性人口
ying=[000519345180369171406873784389616401718200000000000];%2010年各年龄段生育女儿人口
w2=[4466375627845123811881418164241564214967242830851105091695222090912606554002595055545280003797841755215143711814];%2010年各年龄段女性死亡人口
b=ying./w1;%生育率
d=w2./w1;%死亡率
s=1-d;%存活率
L=zeros(21,21);
L(1,:
)=b;
fori=2:
21
L(i,i-1)=s(i-1);
end
w3=zeros(21,1);%2060年各年龄段女性人口
w3=L*L*L*L*L*L*L*L*L*L*w1.'
w3=zeros(21,1);
w3=L*L*L*L*L*L*L*L*L*L*w1.'
w4=0;%2060年总女性人口
fori=1:
21
w4=w4+w3(i)
end
w5=0;%大于60的女性总人口
fori=13:
21
w5=w5+w3(i)
end
得出
w3=
1.0e+007*
0.0013
0.0025
0.0055
0.0118
0.0237
0.0343
0.0737
0.0786
0.0877
0.1021
3.4243
3.2152
3.4221
4.7070
6.1415
4.7443
4.3227
4.8642
4.5928
3.2435
1.9161
w4=4.5015e+008
w5=3.7954e+008
问题二模型程序
(1)没有实行二胎政策
w1=[38958433652135220365809075961557712460558474121694648573580252252256223340502430024223822518902812184162725199014184402];
b=[0000.03080.433300.48290.25140.09920.03780.028900000000000];
s=[0.997048130.99985680.99981650.99981350.99980830.99974730.99963990.99941080.99905070.99861280.9974890.99642930.99404910.9892860.9791230.96307610.92969860.87790270.80023020.74390430.458505];
L=zeros(21,21);
L(1,:
)=b;
fori=2:
21
L(i,i-1)=s(i-1);
end
forj=1:
6
w3=zeros(21,1);
w3=L^j*w1.'
w4=0;
fori=1:
21
w4=w4+w3(i);
end
W4=w4
w5=0;
fori=15:
21
w5=w5+w3(i);
end
W5=w5
end
w3=
1.0e+005*
9.1092
3.8843
3.3647
3.5214
6.5797
7.5947
5.7698
6.0537
7.4078
9.4559
7.3478
5.2121
5.6023
4.0261
2.9703
2.3325
1.8205
1.1328
0.5507
0.1593
0.0311
W4=
9.3926e+006
W5=
8.9970e+005
w3=
1.0e+005*
9.2312
9.0823
3.8838
3.3641
3.5207
6.5784
7.5928
5.7677
6.0501
7.4008
9.4427
7.3294
5.1935
5.5689
3.9830
2.9082
2.2464
1.6925
0.9944
0.4407
0.1185
W4=
1.0239e+007
W5=
1.2384e+006
w3=
1.0e+005*
7.7294
9.2040
9.0810
3.8831
3.3635
3.5201
6.5767
7.5900
5.7643
6.0443
7.3905
9.4190
7.3032
5.1626
5.5093
3.8998
2.8009
2.0885
1.4859
0.7958
0.3278
W4=
1.0894e+007
W5=
1.6908e+006
w3=
1.0e+005*
6.0757
7.7066
9.2027
9.0793
3.8823
3.3628
3.5192
6.5744
7.5856
5.7588
6.0360
7.3719
9.3854
7.2597
5.1073
5.3942
3.7559
2.6040
1.8335
1.1890
0.5920
W4=
1.1328e+007
W5=
2.0476e+006
w3=
1.0e+005*
5.5758
6.0578
7.7055
9.2010
9.0776
3.8816
3.3620
3.5179
6.5705
7.5784
5.7508
6.0208
7.3456
9.3296
7.1820
5.0006
5.1951
3.4918
2.2860
1.4672
0.8845
W4=
1.1648e+007
W5=
2.5507e+006
w3=
1.0e+005*
7.7527
5.5594
6.0569
7.7041
9.1993
9.0759
3.8806
3.3608
3.5158
6.5643
7.5679
5.7364
5.9993
7.3019
9.2296
7.0320
4.8160
4.8298
3.0655
1.8293
1.0915
W4=
1.2117e+007
W5=
3.1894e+006
(2)没有实行二胎政策
>>w1=[38958433652135220365809075961557712460558474121694648573580252252256223340502430024223822518902812184162725199014184402];%2010年江苏省各年龄段女性人口数
b=[0000.03080.433300.48290.25140.09920.03780.028900000000000];%2010年江苏省各年龄段生育率
s=[0.997048130.99985680.99981650.99981350.99980830.99974730.99963990.99941080.99905070.99861280.9974890.99642930.99404910.9892860.9791230.96307610.92969860.87790270.80023020.74390430.458505];%存活率
B=1.47*b
L=zeros(21,21);
L(1,:
)=B;
fori=2:
21
L(i,i-1)=s(i-1);
end
forj=1:
6
w3=zeros(21,1);%各年龄段女性总人口
w3=L^j*w1.'
w4=0;%江苏省总女性人口
fori=1:
21
w4=w4+w3(i);
end
W4=w4
w5=0;%江苏省女性老龄人口
fori=15:
21
w5=w5+w3(i);
end
W5=w5
end
B=
Columns1through9
0000.04530.63700.70990.36960.14580.0556
Columns10through18
0.042500000000
Columns19through21
000
w3=
1.0e+006*
1.3390
0.3884
0.3365
0.3521
0.6580
0.7595
0.5770
0.6054
0.7408
0.9456
0.7348
0.5212
0.5602
0.4026
0.2970
0.2333
0.1820
0.1133
0.0551
0.0159
0.0031
W4=
9.8208e+006
W5=
8.9970e+005
w3=
1.0e+006*
1.3570
1.3351
0.3884
0.3364
0.3521
0.6578
0.7593
0.5768
0.6050
0.7401
0.9443
0.7329
0.5193
0.5569
0.3983
0.2908
0.2246
0.1693
0.0994
0.0441
0.0118
W4=
1.1100e+007
W5=
1.2384e+006
w3=
1.0e+006*
1.1362
1.3530
1.3349
0.3883
0.3363
0.3520
0.6577
0.7590
0.5764
0.6044
0.7390
0.9419
0.7303
0.5163
0.5509
0.3900
0.2801
0.2088
0.1486
0.0796
0.0328
W4=
1.2117e+007
W5=
1.6908e+006
w3=
1.0e+006*
0.8931
1.1329
1.3528
1.3347
0.3882
0.3363
0.3519
0.6574
0.7586
0.5759
0.6036
0.7372
0.9385
0.7260
0.5107
0.5394
0.3756
0.2604
0.1833
0.1189
0.0592
W4=
1.2835e+007
W5=
2.0476e+006
w3=
1.0e+006*
0.8390
0.8905
1.1327
1.3525
1.3344
0.3882
0.3362
0.3518
0.6571
0.7578
0.5751
0.6021
0.7346
0.9330
0.7182
0.5001
0.5195
0.3492
0.2286
0.1467
0.0885
W4=
1.3436e+007
W5=
2.5507e+006
w3=
1.0e+006*
1.4310
0.8365
0.8904
1.1325
1.3523
1.3342
0.3881
0.3361
0.3516
0.6564
0.7568
0.5736
0.5999
0.7302
0.9230
0.7032
0.4816
0.4830
0.3065
0.1829
0.1091
W4=
1.4559e+007
W5=
3.1894e+006
问题三模型程序及结果
(1)
w1=[3447004432416884346411854798428463403945501768144761638157634855611452865181813538389937402295362883285620364811165689441257327474556963432118104743525226327082];%2010年各年龄段女性人口
ying=[000519345180369171406873784389616401718200000000000];%2010年各年龄段生育女儿人口
w2=[4466375627845123811881418164241564214967242830851105091695222090912606554002595055545280003797841755215143711814];%2010年各年龄段女性死亡人口
b=ying./w1;%生育率
d=w2./w1;%死亡率
s=1-d;%存活率
L=zeros(21,21);
L(1,:
)=b;
fori=2:
21
L(i,i-1)=s(i-1);
end
fori=1:
30
w3=zeros(21,1);
w3=L^i*w1.';
w4=0;
fori=1:
21
w4=w4+w3(i);
end
W4=w4
w5=0;
fori=14:
21
w5=w5+w3(i);
end
W5=w5
w6=0;
fori=4:
14
w6=w6+w3(i);
W6=w6
end
end
(2)
x=[134091000012967285341288700000127528000012542800001223220000118142000011294800001067180000991100000900300000807520000701760000590120000485020000391440000];%预测的2010年到2085年以五年为一阶段的总人口数
fori=1:
16
R=1-x(i)/1200000000;
r=0.0075*R
end
得到相应的结果:
r=-8.8069e-004
r=-6.0455e-004
r=-5.5437e-004
r=-4.7050e-004
r=-3.3925e-004
r=-1.4512e-004
r=1.1612e-004
r=4.4075e-004
r=8.3013e-004
r=0.0013
r=0.0019
r=0.0025
r=0.0031
r=0.0038
r=0.0045
r=0.0051
(3)
%x=[119.25120.22120.56119.45117.94117.78];gm1(x);测试数据
%二次拟合预测GM(1,1)模型
functiongmcal=gm1(x)
sizexd2=size(x,2);
%求数组长度
k=0;
fory1=x
k=k+1;
ifk>1
x1(k)=x1(k-1)+x(k);
%累加生成
z1(k-1)=-0.5*(x1(k)+x1(k-1));
%z1维数减1,用于计算B
yn1(k-1)=x(k);
else
x1(k)=x(k);
end
end
%x1,z1,k,yn1
sizez1=size(z1,2);
%size(yn1);
z2=z1';
z3=ones(1,sizez1)';
YN=yn1';%转置
%YN
B=[z2z3];
au0=inv(B'*B)*B'*YN;
au=au0';
%B,au0,au
afor=au
(1);
ufor=au
(2);
ua=au
(2)./au
(1);
%afor,ufor,ua
%输出预测的au和u/a的值
constant1=x
(1)-ua;
afor1=-afor;
x1t1='x1(t+1)';
estr='exp';
tstr='t';
leftbra='(';
rightbra=')';
%constant1,afor1,x1t1,estr,tstr,leftbra,rightbra
strcat(x1t1,'=',num2str(constant1),estr,leftbra,num2str(afor1),tstr,rightbra,'+',leftbra,num2str(ua),rightbra)
%输出时间响应方程
%******************************************************
%二次拟合
k2=0;
fory2=x1
k2=k2+1;
ifk2>k
else
ze1(k2)=exp(-(k2-1)*afor);
end
end
%ze1
sizeze1=size(ze1,2);
z4=ones(1,sizeze1)';
G=[ze1'z4];
X1=x1';
au20=inv(G'*G)*G'*X1;
au2=au20';
%z4,X1,G,au20
Aval=au2
(1);
Bval=au2
(2);
%Aval,Bval
%输出预测的A,B的值
strcat(x1t1,'=',num2str(Aval),estr,leftbra,num2str(afor1),tstr,rightbra,'+',leftbra,num2str(Bval),rightbra)
%输出时间响应方程
nfinal=sizexd2-1+1;
%决定预测的步骤数5这个步骤可以通过函数传入
%nfinal=sizexd2-1+1;
%预测的步骤数1
fork3=1:
nfinal
x3fcast(k3)=constant1*exp(afor1*k3)+ua;
end
%x3fcast
%一次拟合累加值
fork31=nfinal:
-1:
0
ifk31>1
x31fcast(k31+1)=x3fcast(k31)-x3fcast(k31-1);
else
ifk31>0
x31fcast(k31+1)=x3fcast(k31)-x
(1);
else
x31fcast(k31+1)=x
(1);
end
end
end
x31fcast
%一次拟合预测值
fork4=1:
nfinal
x4fcast(k4)=Aval*exp(afor1*k4)+Bval;
end
%x4fcast
fork41=nfinal:
-1:
0
ifk41>1
x41fcast(k41+1)=x4fcast(k41)-x4fcast(k41-1);
else
ifk41>0
x41fcast(k41+1)=x4fcast(k41)-x
(1);
else
x41fcast(k41+1)=x
(1);
end
end
end
x41fcast,x
%二次拟合预测值
%***精度检验pC************//////////////////////////////////
k5=0;
fory5=x
k5=k5+1;
ifk5>sizexd2
else
err1(k5)=x(k5)-x41fcast(k5);
end
end
%err1
%绝对误差
xavg=mean(x);
%xavg
%x平均值
err1avg=mean(err1);
%err1avg
%err1平均值
k5=0;
s1total=0;
fory5=x
k5=k5+1;
ifk5>sizexd2
else
s1total=s1total+(x(k5)-xavg)^2;
end
end
s1suqare=s1total./sizexd2;
s1sqrt=sqrt(s1suqare);
%s1suqare,s1sqrt
%s1suqare残差数列x的方差s1sqrt为x方差的平方根S1
k5=0;
s2total=0;
fory5=x
k5=k5+1;
ifk5>sizexd2
else
s2total=s2total+(err1(k5)-err1avg)^2;
end
end
s2suqare=s2total./sizexd2;
%s2suqare残差数列err1的方差S2
Cval=sqrt(s2suqare./s1suqare);
Cval
%nnn=0.6745*s1sqrt
%CvalC检验值
k5=0;
pnum=0;
fory5=x
k5=k5+1;
ifabs(err1(k5)-err1avg)<0.6745*s1sqrt
pnum=pnum+1;
%ppp=abs(err1(k5)-err1avg)
else
end
end
pval=pnum./sizexd2;
pval
%p检验值
%arr1=x41fcast(1:
6)
>>x=[119.25120.22120.56119.45117.94117.78];gm1(x);
ans=
x1(t+1)=-19263.798exp(-0.006285t)+(19383.048)
ans=
x1(t+1)=-19270.5085exp(-0.006285t)+(19389.6567)
x31fcast=
119.2500120.6925119.9363119.1849118.4382117.6961116.9588
x41fcast=
119.2500120.6328119.9781
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数学 建模 源程序