lingo求矩阵列之和怎么求在J=1的时候所有volume(I,J)的和啊 sets:supplyment/s1..s20/:supply;receiver/r1..r20/:demand;links(supplyment ,receiver):cost,volume;endsets目标函数;min=@sum(links:cost*volume);需求约束;@for(receiver(J):@sum(supplyment(I):volume(I,J))=demand(J));产量约束;@for(supplyment(I):@sum(receiver(J):volume(I,J))=supply(I));

问题描述:

lingo求矩阵列之和
怎么求在J=1的时候所有volume(I,J)的和啊
sets:
supplyment/s1..s20/:supply;
receiver/r1..r20/:demand;
links(supplyment ,receiver):cost,volume;
endsets
目标函数;
min=@sum(links:cost*volume);
需求约束;
@for(receiver(J):
@sum(supplyment(I):volume(I,J))=demand(J));
产量约束;
@for(supplyment(I):
@sum(receiver(J):volume(I,J))=supply(I));

求volume(1,1)+volume(2,1)+...+volume(20,1)吗?
加如下的语句在主程序中就可以了,用求和的语句:
@for(supplyment(I):
s=@sum(receiver(J)|J#le#2:volume(I,J)));
即修改后的程序是
sets:
supplyment/s1..s20/:supply;
receiver/r1..r20/:demand;
links(supplyment ,receiver):cost,volume;
endsets
!目标函数;
min=@sum(links:cost*volume);
!需求约束;
@for(receiver(J):
@sum(supplyment(I):volume(I,J))=demand(J));
!产量约束;
@for(supplyment(I):
@sum(receiver(J):volume(I,J))=supply(I));
@for(supplyment(I):
s=@sum(receiver(J)|J#le#2:volume(I,J)));
end
在J=1的时候所有volume(I,J)的和放在变量s里了!