谁学过lingo 谁给我看个编程哪错了?哪错了

2025-01-01 14:13:55
推荐回答(2个)
回答1:

model:
sets:
cp/1..7/:c;
yf/1..6/:;
sb/1..5/:;
supply1(yf,cp):x,d,y;
y12(sb,cp):a;
y13(sb,yf):b;
endsets
data:
a=0.5 0.7 0 0 0.3 0.2 0.5
0.1 0.2 0 0.3 0 0.6 0
0.2 0 0.8 0 0 0 0.6
0.05 0.03 0 0.07 0.1 0 0.08
0 0 0.01 0 0.05 0 0.05;
b=3 4 4 4 3 4
2 2 2 1 1 2
3 1 3 3 3 2
1 1 0 1 1 1
1 1 1 1 1 0;
d=500 1000 300 300 800 200 100
600 500 200 0 400 300 150
300 600 0 0 500 400 100
200 300 400 500 200 0 100
0 100 500 100 1000 300 0
500 500 100 300 1100 500 60;
c=100 60 80 40 110 90 30;
enddata
max=@sum(supply1(k,j):c(j)*x(k,j)-5*y(k,j));
@for(cp(j):y(6,j)=50);
@for(supply1(k,j)|k#gt#1:y((k-1),j)<=100); !这里下标越界,加个k>1;
@for(yf(k):@for(sb(i):@sum(cp(j):a(i,j)*x(k,j))<=384*b(i,k))); !这里少了两个“)”,括号不匹配;
@for(yf(k)|k#gt#1:@for(cp(j):y(k,j)=y(k-1,j)+x(k,j)-d(k,j)));
@for(cp(j):y(1,j)=x(1,j)-d(1,j));
end

虽然改过之后程序无错,但模型没有可行解

回答2:

第二个约束下标越界了吧 你发文字行不 发图片没法看