model:title Location problem; sets:demand/1..6/:a,b,d; supply/1,2/:x,y,e; link(demand,supply):c; e
照書上寫的,還是出錯了.大惑不解.
錯誤代碼:50
for函數使用不當
所用版本為lingo11
model:
title Location problem;
sets:
demand/1..6/:a,b,d;
supply/1,2/:x,y,e;
link(demand,supply):c;
endsets
data:
a=1.25 8.75 0.5 5.75 3 7.25;
b=1.25 0.75 4.75 5 6.5 7.75;
enddata
init:
x,y=5,1,2,7;
endinit
[obj]min=@SUM( link(i,j):c(i,j)*((x(j)-a(i))^2+(y(j)-b(i)^2)^(1/2));
@for(demand(i):@sum(supply(j):c(i,j);)=d(i));
@for(supply(i):@sum(demand(j):c(j,i);)
少右括號 model:
title Location problem;
sets:
demand/1..6/:a,b,d;
supply/1,2/:x,y,e;
link(demand,supply):c;
endsets
data:
a=1.25 8.75 0.5 5.75 3 7.25;
b=1.25 0.75 4.75 5 6.5 7.75;
enddata
init:
x,y=5,1,2,7;
endinit
[obj]min=@SUM( link(i,j): c(i,j)*((x(j)-a(i))^2+(y(j)-b(i)^2)^(1/2)));
@for(demand(i): @sum(supply(j):c(i,j);)=d(i));
@for(supply(i): @sum(demand(j):c(j,i);)
@for(supply:@free(X);@free(Y););
end