这是我在位置路由问题中的 OPL 代码,有 3 个候选站点、8 个客户和 4 辆车。最佳结果是:300174667,开放的仓库是2nd和3rd depot。路线是这样的:
from depot 2-4-8- depot 3 (vehicle 2)
from depot 2-7-5- depot 2 (vehicle 1)
from depot 2-10-9- depot 3 (vehicle 4)
from depot 3-6-11- depot 3 (vehicle 3)
可以看出,有两条路线从 2 号站开始,到 3 号站结束。我希望的结果是,如果车辆从 2 号站开始,它们也会在 2 号站结束。
我试图改变需求或容量,但结果仍然如此。你能告诉我哪里出错了吗?太感谢了...
这是我的模型:
int m=...; //depot
int c=...; //customer
int k=...; //vehicle
range M=1..m;
range C=m+1..m+c;
range V=1..m+c;
range K=1..k;
tuple jalur {int i;int j;}
tuple jalur_truk {int i;int j;int k;}
setof (jalur) ij={<i,j> | i,j in V:i!=j};
setof (jalur_truk) ijk={<i,j,k> | i,j in V:i!=j, k in K};
int ct[ij]=...;
int f[M]=...;
int o[K]=...;
int Q[M]=...;
int d[C]=...;
int q[K]=...;
//decision variable
dvar boolean X[ijk];
dvar boolean Y[M];
//(1): objective functions:
minimize sum(m in M) f[m]*Y[m] + sum(i,j in V:i!=j, k in K) ct[<i,j>]*X[<i,j,k>]+
sum(m in M, i in C, k in K) o[k]*X[<m,i,k>];
subject to{
//(2): each customer must be visited exactly once
forall (j in C)
sum (k in K, i in V:j!=i) X[<i,j,k>] == 1;
forall (i in C)
sum (k in K, j in V:j!=i) X[<i,j,k>] == 1;
//(3)-(5): vehicle flow conservation
forall (k in K)
sum (m in M, i in C) X[<m,i,k>] == 1;
forall (k in K)
sum (i in C, m in M) X[<i,m,k>] == 1;
forall (h in C, k in K)
sum(i in V:i!=h) X[<i,h,k>] - sum (j in V:j!=h) X[<h,j,k>] == 0 ;
//(6)-(7): vehicle and depot capacity constraints
forall (k in K)
sum(i in C,j in V: j!=i) d[i]*X[<i,j,k>] <= q[k];
forall (m in M)
sum(j in C, k in K) d[j]*X[<m,j,k>] <= Q[m]*Y[m];
//(8): computes and limits the number of vehicle U used
sum (i in M, j in C, k in K) X[<i,j,k>] - k == 0;
}
和数据:
//data
m=3;
c=8;
k=4;
ct=[3200 4267 2133 6400 5333 8384 5760 6688 3093 3093
3200 2133 2240 1493 4267 2987 5333 6731 245 245
4267 5333 4267 9493 2987 3072 9600 10101 10240 10240
6688 3093 5760 1280 3072 9995 11093 8384 10347 10347
6731 245 5333 6731 9995 3008 907 2987 5653 5653
10101 10240 9600 10101 10240 11093 1493 3072 6187 6187
8384 10347 11093 8384 10347 3072 9493 9995 9493 9493
2987 5653 907 2987 5653 9995 10240 3008 6720 6720
3072 6187 1493 3072 6187 3008 10347 6720 3008 9493
9995 9493 9493 9995 9493 11093 5653 9493 3072 1280
3008 6720 1280 3008 6720 9493 6187 1280 9995 3008];
f=[150000000 150000000 150000000];
o=[32896 32896 32896 32896];
Q=[1500 1500 1500];
d=[419 526 475 464 680 489 509 460];
q=[1100 1100 1100 1100];