数学建模社区-数学中国
标题:
两个程序比较,为什么第一个通不过呢?
[打印本页]
作者:
bei_fang
时间:
2013-9-9 14:21
标题:
两个程序比较,为什么第一个通不过呢?
程序1
model:
sets:
node /supply,res_1,res_2,simple_1,simple_2,simple_3,simple_4,simple_5,outlet/;
nl (node)/res_1,res_2/;
month /Jan, Feb, Mar,Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec/:sup1,sup2,demand_dom,demand_ind,demand_agr,divert_dom,divert_ind,divert_agr,out,int;
endsets
sets: net_flow(node,node)
/supply,res_1
supply,res_2
res_1,simple_1
res_2,simple_1
simple_1,simple_2
simple_2,simple_3
simple_3,simple_4
simple_4,simple_5
simple_5,outlet
outlet,supply/;
endsets
sets:
net_time(net_flow,month):waterflow;
endsets
data:
sup1=128 125 234 290 350 400 500 440 240 210 181 128; !水源1的入流量;
sup2=39 39 52 121 168 144 105 78 49 44 45 39; !水源2的入流量;
demand_dom=20 20 20 20 20 20 20 20 20 20 20 20;
demand_ind=40 40 40 40 40 40 40 40 40 40 40 40;
demand_agr=60 60 60 60 60 60 60 60 60 60 60 60;
enddata
@for(net_time(i,j,t)|i#eq#1 #and# j#eq#2:waterflow(i,j,t)=sup1(t));
@for(net_time(i,j,t)|i#eq#1 #and# j#eq#3:waterflow(i,j,t)=sup2(t));
max=@sum(month(t):divert_dom(t)+divert_ind(t)+divert_agr(t));
@for(month(t):divert_dom(t)>=demand_dom(t));
@for(month(t):divert_ind(t)>=demand_ind(t));
@for(month(t):divert_agr(t)>=demand_agr(t));
@for(month(t):int(t)=@sum(net_time(j,i,t)|i#eq#5:waterflow(j,i,t)));
@for(month(t):out(t)=divert_dom(t)+divert_ind(t)+divert_agr(t));
@for(month(t):int(t)>=out(t));
@for(month(t):
@for(node(i):@sum(net_time(i,j,t):waterflow(i,j,t))=
@if(i#lt#5,@sum(net_time(j,i,t):waterflow(j,i,t)),
@if(i#eq#5,@sum(net_time(j,i,t):waterflow(j,i,t))-divert_dom(t)-divert_ind(t)-divert_agr(t),@sum(net_time(j,i,t):waterflow(j,i,t))
)
)
)
);
end
程序2
model:
sets:
month /Jan, Feb, Mar,Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec/:sup1,sup2,demand_dom,demand_ind,demand_agr,divert_dom,divert_ind,divert_agr,out,int;
endsets
data:
sup1=128 125 234 290 350 400 500 440 240 210 181 128; !水源1的入流量;
sup2=39 39 52 121 168 144 105 78 49 44 45 39; !水源2的入流量;
demand_dom=20 20 20 20 20 20 20 20 20 20 20 20;
demand_ind=40 40 40 40 40 40 40 40 40 40 40 40;
demand_agr=60 60 60 60 60 60 60 60 60 60 60 60;
enddata
max=@sum(month(t):divert_dom(t)+divert_ind(t)+divert_agr(t));
@for(month(t):divert_dom(t)>=demand_dom(t));
@for(month(t):divert_ind(t)>=demand_ind(t));
@for(month(t):divert_agr(t)>=demand_agr(t));
@for(month(t):out(t)=divert_dom(t)+divert_ind(t)+divert_agr(t));
@for(month(t):int(t)=sup1(t)+sup2(t));
@for(month(t):int(t)>=out(t));
end
两个程序中,运行结果显示int(t)的值是相同的啊,为什么第一个通不过,而第二个却可以通过?
作者:
madio
时间:
2013-9-10 13:22
可以看出来程序二是程序一去掉了一些约束的,程序一提示没有可行解,也就是这些被去掉的约束无法满足,你可以看看这些约束是什么意思,是不是和上面的约束相矛盾
作者:
bei_fang
时间:
2013-9-10 13:29
程序1多了一个平衡条件,程序1中的int(t)与程序2中的int(t)的运行值是一样的,但不知道为什么程序1却没有可行解了?
作者:
magic2728
时间:
2013-9-10 23:29
约束之间有相互矛盾的地方。
欢迎光临 数学建模社区-数学中国 (http://www.madio.net/)
Powered by Discuz! X2.5