资源描述:
《数学建模整数规划程序》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、实用标准文案整数规划和0、1规划!整数规划:maxz=20x1+10x2s.t5x1+4x2<=24,2x1+5x2<=13,x1,x2>=0,x1,x2为整数;MODEL:SETS:!符号说明,整数规划-ZSGH,未知量-WZL,目标函数系数-MBHS,约束条件未知量系数-YSTJ,约束条件常量系数-CLXS;ZSGH/1..2/:WZL,MBHS,YSTJ1,YSTJ2;CLXS/1..2/:CL;ENDSETSDATA:MBHS=2010;YSTJ1=54;YSTJ2=25;CL=2413;ENDDATAM
2、AX=@SUM(ZSGH:MBHS*WZL);@SUM(ZSGH:YSTJ1*WZL)<=CL(1);@SUM(ZSGH:YSTJ2*WZL)<=CL(2);@FOR(ZSGH:@GIN(WZL));END(@GIN表示整数解;@BIN是01解)!0-1整数规划:maxz=2x1+9x2+3x3+8x4+10x5+6x6+4x7+10x8s.t1X1+3X2+4X3+3X4+3X5+X6+5X7+10X8<=15x1,x2=0,OR1;MODEL:SETS:!符号说明,整数规划-ZSGH,未知量-WZL,目标函数
3、系数-MBHS,约束条件未知量系数-YSTJ,约束条件常量系数-CLXS;ZSGH/1..8/:WZL,MBHS,YSTJ;CLXS/1..1/:CL;ENDSETSDATA:MBHS=2938106410;YSTJ=134331510;CL=15;精彩文档实用标准文案ENDDATAMAX=@SUM(ZSGH:MBHS*WZL);@SUM(ZSGH:YSTJ*WZL)<=CL(1);@FOR(ZSGH:@BIN(WZL));ENDLog(最短路问题)模版:SETS:!Wehaveanetworkof10point
4、s.Wewanttofindthelengthoftheshortestroutefrompoint1topoint10.;!Hereisourprimitivesetof10points,whereF(i)representstheshortestpathdistancefrompointitothelastpoint;CITIES/1..10/:F;!ThederivedsetROADSliststheroadsthatexistbetweenthepoints;ROADS(CITIES,CITIES)/1,
5、21,31,42,52,63,53,63,74,64,75,85,96,86,97,87,98,109,10/:D;!D(i,j)isthedistancefrompointitoj;ENDSETSDATA:!Herearethedistancesthatcorrespondtotheabovelinks;D=4.52.8310.3967.410.23.58.34.68.296.55.44.6精彩文档实用标准文案84.6;ENDDATA!Ifyouarealreadyinpoint10,thenthecostto
6、traveltopoint10is0;F(@SIZE(CITIES))=0;@FOR(CITIES(i)
7、i#LT#@SIZE(CITIES):F(i)=@MIN(ROADS(i,j):D(i,j)+F(j)));END阶层用法n=3;a=[120.2;0.511/8;581];e=[1/n;1/n;1/n];c=1;while(max(abs(c))>0.001)f=a*e;g=f(1)+f(2)+f(3);l=f/g;c=l-e;e=l;eendm=eig(a)p=max(m)CI=(p-n)/(n-1)CR
8、=CI/0.58jc=1;fori=9:-2:1jc=jc*iends=0;jc=1;fori=1:10jc=jc*i;精彩文档实用标准文案s=s+jc;end精彩文档