lingo语言一直在报错,求各位大神指导啊!! 50
model:titlegangguanproblem3;sets:gangchang/1..7/:s,x;yunshudian/1..21/:d,m;!d表示出度,m表示...
model:
title gangguan problem3;
sets:
gangchang/1..7/:s,x;
yunshudian/1..21/:d,m;!d表示出度,m表示入度;
link1(gangchang,yunshudian):c,y;
link2(yunshudian,yunshudian):z,w,p;!p是0-1变量,判断两个运输点是否相连;
endsets
data:
enddata
init:
endinit
min=@sum(link1(i,j)|j#le#15:c(i,j)*y(i,j))+@sum(link2(k,j):(z(k,j)*(z(k,j)-1)+(w(k,j)-z(k,j))*(w(k,j)-z(k,j)-1))*p(i,j))*0.05;
@for(gangchang(i):@sum(yunshudian(j):y(i,j))<=s(i)*x(i));
@for(gangchang(i):@sum(yunshudian(j):y(i,j))>=500*x(i));
@for(link2(k,j)|p(k,j)#eq#1:@for(yunshudian(j):@sum(gangchang(i):y(i,j))=@if(yunshudian(j):d(j)#eq#0,w(k,j)-z(k.j),@if(m(j)#eq#0,z(k,j),@sum(z(k,j))+w(k,j)-z(k,j)));
@for(link2(k,j)|p(k,j)#eq#1:z(k,j)<=w(k,j));
@for(gangchang(i):@bin(x(i));
@for(link2(k,j):@bin(p(k,j));
@sum(link1(i,j):y(i,j)=5903); 展开
title gangguan problem3;
sets:
gangchang/1..7/:s,x;
yunshudian/1..21/:d,m;!d表示出度,m表示入度;
link1(gangchang,yunshudian):c,y;
link2(yunshudian,yunshudian):z,w,p;!p是0-1变量,判断两个运输点是否相连;
endsets
data:
enddata
init:
endinit
min=@sum(link1(i,j)|j#le#15:c(i,j)*y(i,j))+@sum(link2(k,j):(z(k,j)*(z(k,j)-1)+(w(k,j)-z(k,j))*(w(k,j)-z(k,j)-1))*p(i,j))*0.05;
@for(gangchang(i):@sum(yunshudian(j):y(i,j))<=s(i)*x(i));
@for(gangchang(i):@sum(yunshudian(j):y(i,j))>=500*x(i));
@for(link2(k,j)|p(k,j)#eq#1:@for(yunshudian(j):@sum(gangchang(i):y(i,j))=@if(yunshudian(j):d(j)#eq#0,w(k,j)-z(k.j),@if(m(j)#eq#0,z(k,j),@sum(z(k,j))+w(k,j)-z(k,j)));
@for(link2(k,j)|p(k,j)#eq#1:z(k,j)<=w(k,j));
@for(gangchang(i):@bin(x(i));
@for(link2(k,j):@bin(p(k,j));
@sum(link1(i,j):y(i,j)=5903); 展开
1个回答
展开全部
问题很多 min那句里面对k,j求和里面的i是什么东西?
@if不是集循环函数不知道你为什么写集名在里面 还有如果你的p未知也不能作为集元素筛选的条件
@if不是集循环函数不知道你为什么写集名在里面 还有如果你的p未知也不能作为集元素筛选的条件
追问
那请问@if那一句应该怎么改呢?
我想表达的意思就是说
如果d(j)=0,对y(i,j)的求和就等于w(k,j)-z(k,j),如果m(j)=0,对y(i,j)的求和就等于z(k,j),二者都不是的话就等于对z(k,j)的求和+w(k,j)-z(k,j)。
麻烦了。。新手上路。。。
追答
你这个约束没法写 @if就是一个数 @if(条件,x1,x2) 条件成立是x1 条件不成立是x2
你拿等式放里面怎么写?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询