Sets
i clients and depots /1*4/
*clients 1 and 2, starting depot 3, ending depot 4
m time intervals /1*3/
*k vehicles /k1/
;
Alias(i,j)
;
Scalars
t0 starting time /0/
B1 /500000000/
B2 /5000000/
B /10/
nc number of clients /2/
;
Parameters
tserv(i) service time at i/
1 300
2 300
3 0
4 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(i) vehicle capacity/
4 10
/
proc(i) client demand/
1 1
2 1
3 0
4 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
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
x(i,j,m) binary variable that defines in which time interval m does the travel from i to j occur
;
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)
Eq4(i) defines the starting time for all routes
Eq5(i,j,m) defines the departure time for each node j
Eq6(i,j,m)
Eq7(i,j,m)
*equations 5 and 6 that the proper time interval m is chosen for each link ij
Eq8(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
Eq9(i) each vehicle arrives at the ending depot empty
Eq10(j) ensures that vehicle capacities are not exceeded
;
Obj .. z =e= sum((i)$(ord(i)>3),t(i));
Eq1(j)$(ord(j)<3 or ord(j)>3) .. sum((i,m)$(ord(i)<4 and ord(i)<>ord(j)),x(i,j,m)) =e= 1;
Eq2(i)$(ord(i)=3) .. sum((j,m)$(ord(i) <> ord(j) and ord(j) < 3),x(i,j,m)) =e= 1;
Eq3(i)$(ord(i)<3)..sum((j,m)$(ord(i) <> ord(j) and ord(j) < 3 or ord(j) > 3),x(i,j,m)) =e= 1;
Eq4(i)$(ord(i)=3) .. t(i) =e= t0;
Eq5(i,j,m)$(ord(i)<>ord(j) and ord(i)<4 and ord(j)<3 or ord(j)>3) .. t(j) - t(i) - B1*x(i,j,m) =e= tviag(i,j,m) + tserv(j) - B1;
Eq6(i,j,m)$(ord(i)<>ord(j) and ord(i)<4 and ord(j)<3 or ord(j)>3) .. t(i) + B2*x(i,j,m) =l= lsup(i,j,m) + B2;
Eq7(i,j,m)$(ord(i)<>ord(j) and ord(i)<4 and ord(j)<3 or ord(j)>3) .. t(i) - lsup(i,j,m-1) =g= 0;
Eq8(i,j)$(ord(i)<>ord(j) and ord(i)<4 and ord(j)<3 or ord(j)>3) .. w(i) - w(j) - B*sum((m),x(i,j,m)) =g= proc(j) - B;
Eq9(i)$(ord(i)>3) .. w(i) =e= 0;
Eq10(j)$(ord(j)=4) .. w(j) =l= cap(j);
Model tdvrp /all/;
tdvrp.optcr=0;
x.fx('3','1','1')=1;
x.fx('1','2','1')=1;
x.fx('2','4','1')=1;
option limrow=100;
option limcol= 100;
solve tdvrp using mip minimizing z;
display t.l;
display x.l;
display tviag;
display lsup;