Sets
i clients and depots /1*11/
*clients 1 to 7, starting depots 8 and 9, ending depots 10 and 11
m time intervals /1*3/
k vehicles /k1*k2/
;
Alias(i,j)
;
Scalars
t0 starting time /0/
B1 /50000/
B2 /50000/
B /10/
nc number of clients /7/
;
Parameters
tserv(i) service time at i/
1 300
2 300
3 300
4 300
5 300
6 300
7 300
8 0
9 0
10 0
11 0
/
lsup(i,j,m) upper bound for time interval m for link ij
*$call gdxxrw lsup.xlsx par=lsup rng=lsup!A2 Rdim=3 Dset=i rng=lsup!A2 Rdim=1 Dset=j rng=lsup!B2 Rdim=1 Dset=m rng=lsup!C2 Rdim=1
$gdxin lsup.gdx
$load lsup
$gdxin
cap(k) vehicle capacity/
k1 10
k2 10
/
proc(i) client demand/
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 0
9 0
10 0
11 0
/
tviag(i,j,m) travel time for i to j during time interval m
*$call gdxxrw tviag.xlsx trace=3 par=tviag rng=tviag!A2 Rdim=3 Dset=i rng=tviag!A2 Rdim=1 Dset=j rng=tviag!B2 Rdim=1 Dset=m rng=tviag!C2 Rdim=1
$gdxin tviag.gdx
$load tviag
$gdxin
;
Variables
x(i,j,m) binary variable that defines in which time interval m does the travel from i to j occur
t(j) departure time of vehicle from node j
w(j) weight larger than or equal to that carried by a vehicle when leaving node j
z
;
Binary Variables x
;
Positive Variables t, w
;
Equations
Obj minimizes total time of all routes
Eq1(j) arrival only occurs once for each client and ending depot
Eq2(i) departure only occurs once for each client and starting depots
*equations 1 and 2 ensure that each client is only visited once by a vehicle, routes start at starting depots and end at ending depots
Eq3(i) defines the starting time for all routes
Eq4(i,j,m) defines the departure time for each node j
Eq5(i,j,m)
Eq6(i,j,m)
*equations 5 and 6 that the proper time interval m is chosen for each link ij
Eq7(i,j) the weight carried by a vehicle leaving i minus the weight carried when leaving j is atleast equal to the weight of the product delivered at j
Eq8(i) each vehicle arrives at the ending depot empty
Eq9(j,k) ensures that vehicle capacities are not exceeded
;
Obj .. z =e= sum((i)$(ord(i)>9),t(i));
Eq1(j)$(ord(j)<8 and ord(j)>9) .. sum((i,m)$(ord(i)<10 and ord(i)<>ord(j)),x(i,j,m)) =e= 1;
Eq2(i)$(ord(i)<8) .. sum((j,m)$(ord(j)<8 and ord(j)>9 and ord(i)<>ord(j)),x(i,j,m)) =e= 1;
Eq3(i)$(ord(i)=1) .. t(i) =e= t0;
Eq4(i,j,m)$(ord(i)<>ord(j) and ord(i)<10 and ord(j)<8 and ord(j)>9) .. t(j) - t(i) - B1*x(i,j,m) =g= tviag(i,j,m) + tserv(j) - B1;
Eq5(i,j,m)$(ord(i)<>ord(j) and ord(i)<10 and ord(j)<8 and ord(j)>9) .. t(i) + B2*x(i,j,m) =l= lsup(i,j,m) + B2;
Eq6(i,j,m)$(ord(i)<>ord(j) and ord(i)<10 and ord(j)<8 and ord(j)>9) .. t(i) - lsup(i,j,m-1) =g= 0;
Eq7(i,j)$(ord(i)<>ord(j) and ord(i)<10 and ord(j)<8 and ord(j)>9) .. w(i) - w(j) - B*sum((m),x(i,j,m)) =g= proc(j) - B;
Eq8(i)$(ord(i)>9) .. w(i) =e= 0;
Eq9(j,k) .. w(j) =l= cap(k);
Model tdvrp /all/;
tdvrp.optcr=0;
solve tdvrp using mip minimizing z;
display t.l;