1

this is in my OPL code in Location Routing Problem, there are 3 candidates depots, 8 customers and 4 vehicles. the optimal result was: 300174667, the depot which open are 2nd and 3rd depot. the route turns out like this:

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)

it can be seen that there are two routes that start with depot 2 and end at depot 3. the result that I hope is if the vehicle starts in depot 2 they will end also in depot 2.

I have tried to change the demand or the capacity, but it's still turns out like that. can you tell me where I went wrong? thank you so much...

this is my model:

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;  

}

And the data:

//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];
rkersh
  • 4,447
  • 2
  • 22
  • 31
ndns
  • 21
  • 3

1 Answers1

0

If you want that a route ends in the same depot in which it started then you must explicitly state this as a constraint. Your constraints only state that for each vehicle, the vehicle must leave any depot and must enter any depot. You probably also want something like this:

forall(k in K) forall (m in M) sum(i in C) X[<m,i,k>] == sum(c in C) X[<i,m,k>];

That is, for each depot the number of used outbound arcs must be the same as the number of used inbound arcs. Alternatively, you could state this flow conservation constraint

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 ;

also for the depots (currently it is only stated for the customers).

Daniel Junglas
  • 5,830
  • 1
  • 5
  • 22