Hello,
I am writing a mixed integer problem in AMPL, trying to develop a model for a problem of trucks+drones delivery found in literature (the first proposed in the attached paper). Unfortunately, I’m having problems as AMPL gives me errors that I do not completely understand, especially it says that ‘all variables have been eliminated’ in some constraints. You can find attached my .mod and .dat files.
Any suggestions and help would be really appreciated.
Thank you very much in advance,
Lara
FILE.MOD
set nodes;
set D; #depot
set U; #parkings
set W; #customers
set K; #trucks
param coord_x {nodes};
param coord_y {nodes};
param b {nodes}; #demand
param theta;
param Q; #trucks capacity
set E := {i in nodes, j in nodes: i != j};
set A:= {s in W, i in U};
param dist {nodes, nodes};
param dist1 {W, U};
param p {nodes} default 0;
param c {nodes, nodes};
param d {nodes, nodes};
param R;
var z {i in nodes} binary;
var x {i in nodes, j in nodes, k in K : i != j} binary; #: i != j
var y {s in W, i in U} binary;
var q {i in nodes, k in K} >=0;
minimize obj : sum {k in K} sum {(i,j) in E} c[i,j] * x[i,j,k] + sum {s in W, i in U} d[s,i]*y[s,i] + sum {i in U} p[i]*z[i];
subject to constr_b : z[1] = 1;
subject to constr_c {k in K} : sum { (i,j) in E : j != 1} x[1,j,k] <= 1;
subject to constr_d {i in nodes} : sum {k in K} sum {j in nodes: j != i} x[i,j,k] = z[i];
subject to constr_e {s in W} : sum {i in U} y [s,i] = 1 - z[s];
subject to constr_f {i in nodes, k in K} : sum {j in nodes: j != i} x[i,j,k] = sum {j in nodes: j != i} x[j,i,k];
subject to constr_g {s in W, i in U} : d[s,i] * y [s,i] <= R * z[i];
#subject to constr_h {s in W} : y [s,1] = 0;
subject to constr_i {i in nodes, j in W, k in K : i != j} : q[j,k] >= q[i,k] + b[j] + Q * (x[i,j,k]-1);
subject to constr_j {i in nodes, j in U, k in K: i != j} : q[j,k] >= q[i,k] + sum {s in W} b[s] * y [s,j] + Q * ( x[i,j,k] - 1);
subject to constr_k {i in nodes, k in K} : q[i,k] <= Q * z[i];
FILE.DAT
set nodes:= 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26;
set D:= 1;
set U:= 2 3 4 5 6 7;
set W:= 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26;
set K:= 1 2 3;
param coord_x:=
1 30
2 37
3 49
4 52
5 20
6 40
7 21
8 17
9 31
10 52
11 51
12 42
13 31
14 5
15 12
16 36
17 52
18 27
19 17
20 13
21 57
22 62
23 42
24 16
25 8
26 7;
param coord_y:=
1 40
2 52
3 49
4 64
5 26
6 30
7 47
8 63
9 62
10 33
11 21
12 41
13 32
14 25
15 42
16 16
17 41
18 23
19 33
20 13
21 58
22 42
23 57
24 57
25 52
26 38;
param b:=
1 0
2 7
3 30
4 16
5 9
6 21
7 15
8 19
9 23
10 11
11 5
12 19
13 29
14 23
15 21
16 10
17 15
18 3
19 41
20 9
21 28
22 8
23 8
24 16
25 10
26 28;
param theta:= 5;
param Q:= 35;
for {i in nodes, j in nodes}{
let dist[i,j]:= sqrt((coord_x[i] - coord_x[j])^2 + (coord_y[i]-coord_y[j])^2);
let c[i,j]:= dist[i,j]*theta;
}
for {s in W, i in U}{
let dist1[s,i]:= sqrt((coord_x[s] - coord_x[i])^2 + (coord_y[s]-coord_y[i])^2);
let d[s,i]:= (10 - theta) * dist1[s,i];
}
let R:= max {s in W, i in U} dist1[s,i];