資源描述:
《MATLAB練習題及求解.doc》由會員上傳分享,免費在線閱讀,更多相關內容在行業(yè)資料-天天文庫。
1、建立模型并求解練習1:如圖,P,Q到河岸的距離分別為10,8,試選一點R,使得R到河岸的距離及RP,RQ的和最小.PQR6解:設點R的坐標為(x,y)則有:=PR+R(y)+RQ=+y+在lingo中輸入:RP=@sqrt((x)^2+(10-y)^2);
RY=y;
RQ=@sqrt((x-6)^2+(y-8)^2);
min=RP+RY+RQ;
則可得到結果:Localoptimalsolutionfound.Objectivevalue:14.19615Infeasibilities:0.3330669E-14
2、Extendedsolversteps:5Totalsolveriterations:200VariableValueReducedCostRP5.4641020.000000X4.732051-0.2154924E-07Y7.2679490.000000RY7.2679490.000000RQ1.4641020.000000RowSlackorSurplusDualPrice10.000000-1.00000020.000000-1.00000030.000000-1.000000414.19615-1.00000
3、0所以R(4.732,7.268)。練習2:要把7種規(guī)格的包裝箱裝到兩輛鐵路平板車上去,箱子寬、高相同,而厚度和重量不同,下表給出了它們的厚度、重量和數(shù)量。c1c2c3c4c5c6c7厚度(厘米)重量(千克)數(shù)量48.72000852.03000761.31000972.0500648.74000652.02000464.010008每輛平板車有10.2米長的地方用于裝箱(像面包片那樣),載重40噸。由于貨運限制,對c5,c6,c7三種包裝箱的裝載有如下特殊約束:它們所占的空間(厚度)不得超過302.7厘米。試把包裝
4、箱裝到平板車上,使浪費的空間最小。解:程序為:min=2040-x11*48.7-x21*48.7-(x12+x22)*52-(x13+x23)*61.3-(x14+x24)*72-(x15+x25)*48.7-(x16+x26)*52-(x17+x27)*64;x11+x21<=8;x12+x22<=7;x13+x23<=9;x14+x24<=6;x15+x25<=6;x16+x26<=4;x17+x27<=8;x11*48.7+x12*52+x13*61.3+x14*72+x15*48.7+x16*52+x17*
5、64<=1020;x21*48.7+x22*52+x23*61.3+x24*72+x25*48.7+x26*52+x27*64<=1020;x15*47.8+x16*52+x17*64<=302.7;x25*47.8+x26*52+x27*64<=302.7;x11*2+x12*3+x13*1+x14*0.5+x15*4+x16*2+x17*1<=40;x21*2+x22*3+x23*1+x24*0.5+x25*4+x26*2+x27*1<=40;?@gin(x11);@gin(x12);@gin(x13);@gin
6、(x14);@gin(x15);@gin(x16);@gin(x17);@gin(x21);@gin(x22);@gin(x23);@gin(x24);@gin(x25);@gin(x26);@gin(x27);運行結果:Globaloptimalsolutionfound.Objectivevalue:0.000000Objectivebound:0.000000Infeasibilities:0.1154632E-12Extendedsolversteps:140191Totalsolveriterations:
7、262446VariableValueReducedCostX110.000000-48.70000X216.000000-48.70000X125.000000-52.00000X222.000000-52.00000X132.000000-61.30000X236.000000-61.30000X145.000000-72.00000X240.000000-72.00000X152.000000-48.70000X250.000000-48.70000X161.000000-52.00000X260.000000
8、-52.00000X172.000000-64.00000X274.000000-64.00000RowSlackorSurplusDualPrice10.000000-1.00000022.0000000.00000030.0000000.00000041.0000000.00000051.0000000.00000064.0000000.0