Lingo求解线性规划问题Matlab与Excel数据交互Word文档格式.docx
- 文档编号:20371039
- 上传时间:2023-01-22
- 格式:DOCX
- 页数:12
- 大小:43.92KB
Lingo求解线性规划问题Matlab与Excel数据交互Word文档格式.docx
《Lingo求解线性规划问题Matlab与Excel数据交互Word文档格式.docx》由会员分享,可在线阅读,更多相关《Lingo求解线性规划问题Matlab与Excel数据交互Word文档格式.docx(12页珍藏版)》请在冰豆网上搜索。
WH1WH2WH3WH4WH5WH6~
V1V2V3V4V5V6V7V8~
605551434152~
3537223241324338~
62674259
49538582
52197433
76739271
23957265
55228143
在Lingo窗口输入:
sets:
warehouse/@file('
G:
\study\数学建模\LINGO10\LINGO10\1_2.txt'
)/:
capacity;
vendors/@file('
demand;
links(warehouse,vendors):
cost,volume;
endsets
min=@sum(links:
cost*volume);
@for(vendors(J):
@sum(warehouse(I):
volume(I,J))=demand(J));
@for(warehouse(I):
@sum(vendors(J):
volume(I,J))<
=capacity(I));
data:
capacity=@file('
);
demand=@file('
cost=@file('
enddata
end
运行
2、读入*.dat数据:
\study\数学建模\LINGO10\LINGO10\1_2.dat'
3、读入*.Xls数据
建立1_2.xls文件:
选中A1:
F1,插入姓名,定义为”warehouse”
选中A2:
H2,插入姓名,定义为”vendors”
选中A3:
F3,插入姓名,定义为”capacity”
选中A4:
H4,插入姓名,定义为”demand”
选中B6:
I11,插入姓名,定义为”cost”
在Lingo窗口输入
warehouse/@ole('
D:
\study\数学建模\2013\LINGO10\LINGO10\1_2.xls'
vendors/@ole('
capacity=@ole('
demand=@ole('
cost=@ole('
二、MATLAB与EXCEL数据的交互,xlsread、xlsread的使用
建立Excel,输入姓名,学号,成绩
在Matlab命令窗口输入:
[numberstringscore]=xlsread('
cjb.xls'
row_length=length(score(:
1));
temp=score(2:
row_length,:
A=(number(:
2)+number(:
3)+number(:
4))/3
fori=1:
5
temp1(i,:
)=[temp(i,:
)A(i)];
score1=[score(1,:
)'
average'
];
data_sorted=sortrows(temp1,6);
data_out=[score1;
data_sorted];
success=xlswrite('
result.xls'
data_out);
ifsuccess==1
disp('
成功!
!
'
else
失败!
结论
(结果)
Lingo读入*.dat,*.txt,*.xls数据计算结果都为:
Globaloptimalsolutionfound.
Objectivevalue:
664.0000
Totalsolveriterations:
15
VariableValueReducedCost
CAPACITY(WH1)60.000000.
CAPACITY(WH2)55.000000.
CAPACITY(WH3)51.000000.
CAPACITY(WH4)43.000000.
CAPACITY(WH5)41.000000.
CAPACITY(WH6)52.000000.
DEMAND(V1)35.000000.
DEMAND(V2)37.000000.
DEMAND(V3)22.000000.
DEMAND(V4)32.000000.
DEMAND(V5)41.000000.
DEMAND(V6)32.000000.
DEMAND(V7)43.000000.
DEMAND(V8)38.000000.
COST(WH1,V1)6.0.
COST(WH1,V2)2.0.
COST(WH1,V3)6.0.
COST(WH1,V4)7.0.
COST(WH1,V5)4.0.
COST(WH1,V6)2.0.
COST(WH1,V7)5.0.
COST(WH1,V8)9.0.
COST(WH2,V1)4.0.
COST(WH2,V2)9.0.
COST(WH2,V3)5.0.
COST(WH2,V4)3.0.
COST(WH2,V5)8.0.
COST(WH2,V6)5.0.
COST(WH2,V7)8.0.
COST(WH2,V8)2.0.
COST(WH3,V1)5.0.
COST(WH3,V2)2.0.
COST(WH3,V3)1.0.
COST(WH3,V4)9.0.
COST(WH3,V5)7.0.
COST(WH3,V6)4.0.
COST(WH3,V7)3.0.
COST(WH3,V8)3.0.
COST(WH4,V1)7.0.
COST(WH4,V2)6.0.
COST(WH4,V3)7.0.
COST(WH4,V4)3.0.
COST(WH4,V5)9.0.
COST(WH4,V6)2.0.
COST(WH4,V7)7.0.
COST(WH4,V8)1.0.
COST(WH5,V1)2.0.
COST(WH5,V2)3.0.
COST(WH5,V3)9.0.
COST(WH5,V4)5.0.
COST(WH5,V5)7.0.
COST(WH5,V6)2.0.
COST(WH5,V7)6.0.
COST(WH5,V8)5.0.
COST(WH6,V1)5.0.
COST(WH6,V2)5.0.
COST(WH6,V3)2.0.
COST(WH6,V4)2.0.
COST(WH6,V5)8.0.
COST(WH6,V6)1.0.
COST(WH6,V7)4.0.
COST(WH6,V8)3.0.
VOLUME(WH1,V1)0.5.
VOLUME(WH1,V2)19.000000.
VOLUME(WH1,V3)0.5.
VOLUME(WH1,V4)0.7.
VOLUME(WH1,V5)41.000000.
VOLUME(WH1,V6)0.2.
VOLUME(WH1,V7)0.2.
VOLUME(WH1,V8)0.10.00000
VOLUME(WH2,V1)1.0.
VOLUME(WH2,V2)0.4.
VOLUME(WH2,V3)0.1.
VOLUME(WH2,V4)32.000000.
VOLUME(WH2,V5)0.1.
VOLUME(WH2,V6)0.2.
VOLUME(WH2,V7)0.2.
VOLUME(WH2,V8)0.0.
VOLUME(WH3,V1)0.4.
VOLUME(WH3,V2)11.000000.
VOLUME(WH3,V3)0.0.
VOLUME(WH3,V4)0.9.
VOLUME(WH3,V5)0.3.
VOLUME(WH3,V6)0.4.
VOLUME(WH3,V7)40.000000.
VOLUME(WH3,V8)0.4.
VOLUME(WH4,V1)0.4.
VOLUME(WH4,V2)0.2.
VOLUME(WH4,V3)0.4.
VOLUME(WH4,V4)0.1.
VOLUME(WH4,V5)0.3.
VOLUME(WH4,V6)5.0.
VOLUME(WH4,V7)0.2.
VOLUME(WH4,V8)38.000000.
VOLUME(WH5,V1)34.000000.
VOLUME(WH5,V2)7.0.
VOLUME(WH5,V3)0.7.
VOLUME(WH5,V4)0.4.
VOLUME(WH5,V5)0.2.
VOLUME(WH5,V6)0.1.
VOLUME(WH5,V7)0.2.
VOLUME(WH5,V8)0.5.
VOLUME(WH6,V1)0.3.
VOLUME(WH6,V2)0.2.
VOLUME(WH6,V3)22.000000.
VOLUME(WH6,V4)0.1.
VOLUME(WH6,V5)0.3.
VOLUME(WH6,V6)27.000000.
VOLUME(WH6,V7)3.0.
VOLUME(WH6,V8)0.3.
RowSlackorSurplusDualPrice
1664.0000-1.
20.-4.
30.-5.
40.-4.
50.-3.
60.-7.
70.-3.
80.-6.
90.-2.
100.3.
1122.000000.
120.3.
130.1.
140.2.
150.2.
二、MATLAB与EXCEL数据交互
A=
87.0000
81.0000
81.3333
87.6667
85.0000
备注或说明(成功或失败的原因、实验后的心得体会)
当把成绩表中的姓名、学号两列对调时,则无法输出平均成绩,所以一直得不到正确结果,在定义A时,number(:
n)应对4、5、6列求平均,但在输入n值时,应该是number的2、3、4列,在程序编写时也出现了错误,所以一直没能得出结果,以后应加强对程序语句的具体细节的理解。
指导教师评分(包括对实验的预习、操作和结果的综合评分):
指导教师总评:
签名:
日期:
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Lingo 求解 线性规划 问题 Matlab Excel 数据 交互
![提示](https://static.bdocx.com/images/bang_tan.gif)