数模论坛

 找回密码
 注-册-帐-号
搜索
热搜: 活动 交友 discuz
查看: 5548|回复: 2

高手麻烦看下这个小问题...

[复制链接]
发表于 2007-9-15 21:06:43 | 显示全部楼层 |阅读模式
sets:  
!yongshui/yong/1A,Q2A,Q1B,Q2B,PA,PB,XA,XB,SA;  
jieshui/1..3/:XA,XB,SB,SA;  
ganliu/1..12/:vj,xia,xib,Q1A,Q2A,Q1B,Q2B,PA,PB;  
zhiliu/1,2/:xia2,xib2;  
links1(ganliu,jieshui): wij;  
links(ganliu,jieshui): xia1,xib1;  
endsets  
!目标函数;  
@FOR(ganliu(i):  
max=2000*(Q1A(i)+Q1B(i))+1200*(Q2A(i)+Q2B(i)));  
!限制条件;  
@if(@for(ganliu(i):vj(i)+@sum(jieshui(j):wij(i,j))#ge#500));  
@FOR(ganliu(i)1A(i)+Q1B(i)=20*PA(i));  
@for(ganliu(i)1B(i)+Q2B(i)=15*PB(i));  
@for(ganliu(i):Q1A(i)+Q1B(i)<=9000);  
@for(ganliu(i)A(i)<=SA(i)+XA(i)+@SUM(ganliu(i):xia(i)));  
@for(ganliu(i):20*PA(i)<=1200);  
@for(ganliu(i)|i#gt#1:2200+SA(i-1)+XA(i-1)+@sum(zhiliu(i):xia2(i-1))<=2500);  
@for(ganliu(i)B(i)<=SB(i)+XB(i)+@sum(jieshui(i):xib(i)));  
@for(ganliu(i):15*PB(i)<=800);  
@for(ganliu(i)|i#gt#1:1300<=SB(i-1)+XB(i-1)+@sum(jieshui(i):xib(i)));  
@for(ganliu(i)|i#gt#1:SB(i-1)+XB(i-1)+@sum(jieshui(i):xib(i))<=1600);  
@for(ganliu(i):XA(i)+XB(i)<=vj(i));  
@for(links(i,j):xia1(i,j)+xib1(i,j)<=wij(i,j));  

@if(@for(ganliu(i):vj(i)+@sum(jieshui(j):wij(i,j))#lt#500));  
@FOR(ganliu(i):Q1A(i)+Q1B(i)=20*PA(i));  
@for(ganliu(i):Q1B(i)+Q2B(i)=15*PB(i));  
@for(ganliu(i):Q1A(i)+Q1B(i)<=9000);  
@for(ganliu(i)A(i)<=SA(i)+XA(i)+@SUM(ganliu(i):xia(i)));  
@for(ganliu(i):20*PA(i)<=1200);  
@for(ganliu(i)|i#gt#1:2200+SA(i-1)+XA(i-1)+@sum(zhiliu(i):xia2(i-1))<=3000);  
@for(ganliu(i):PB(i)<=SB(i)+XB(i)+@sum(jieshui(i):xib(i)));  
@for(ganliu(i):15*PB(i)<=800);  
@for(ganliu(i)|i#gt#1:1300<=SB(i-1)+XB(i-1)+@sum(jieshui(i):xib(i)));  
@for(ganliu(i)|i#gt#1:SB(i-1)+XB(i-1)+@sum(jieshui(i):xib(i))<=2100);  
@for(ganliu(i):XA(i)+XB(i)<=vj(i));  
@for(links(i,j):xia1(i,j)+xib1(i,j)<=wij(i,j));  

!这里是数据;  
data:  
vj=417.7575  
51.9156  
298.7572  
584.5667  
367.2415  
620.6028  
516.1856  
306.4603  
751.7399  
545.4762  
186.7592  
217.3451;  
wij=125.2722 140.8795 23.0709  
177.3198 72.7826 60.3576  
133.471 131.8624 59.2441  
170.6446 153.9466 16.6118  
253.3656 192.0216 18.493  
226.819 192.0261 87.8238  
178.8254 191.458 40.5921  
142.7199 134.1288 203.8025  
146.2138 104.5679 6.5488  
119.834 115.7186 133.3922  
165.9355 32.878 89.3362  
40.8715 145.2462 9.7968;  
enddata  
end  
另外if(@for(ganliu(i):vj(i)+@sum(jieshui(j):wij(i,j))#ge#500));  
这语句是想用来实现:当(@for(ganliu(i):vj(i)+@sum(jieshui(j):wij(i,j))这条语句大于或等于500时继续执行下面的语句.而@if(@for(ganliu(i):vj(i)+@sum(jieshui(j):wij(i,j))#lt#500));则是想实现小于500是执行下面的语句.  
请问lingo只能解决单目标规划吗?那是一个循环.这样也不行吗?
该如何解决这类.以12个月利润最大为目标函数的线形规划问题呢?
发表于 2007-9-16 00:46:09 | 显示全部楼层
你的@if函数用法不对,if只能实现对条件的选择,并不能对语句嵌套,且程序冗长,此类问题见意用动态规划去编写代码
发表于 2007-9-16 01:09:46 | 显示全部楼层
至于lingo是否只能解决单目标规划问题,我可以很负责的告诉你目前lingo所有版本只能解单目标问题,多目标的话需自已另写算法,多目标的算法很多.不过多目标最终都需化为单目标才能求解的.在matlab7.0以后版本的优化工具箱中对多目标的函数有所扩充
您需要登录后才可以回帖 登录 | 注-册-帐-号

本版积分规则

小黑屋|手机版|Archiver|数学建模网 ( 湘ICP备11011602号 )

GMT+8, 2024-12-2 12:02 , Processed in 0.064954 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表