Dear colleagues,

I am studying the school bus routing problem: Redirecting.

I am reproducing this mixed-integer linear programming formulation. However, I was replacing the sub-tour constraints (3) with a flow constraint (as proposed by Miller, Tucker, and Zemlin, 1960).

I’ve modeled this constraint as follows:

@constraint(model_sbrp, [i in V, j in V, k in 1:n], u[i] - u[j] + n*x[i,j,k] >= n - 1)

Nevertheless, an error message was returned (out of bounds).

I need some assistance to tackle this problem. Could someone help me, please?

```
@variable(model_sbrp, x[i in V, j in V, k = 1:n, i != j], Bin)
@variable(model_sbrp, y[i in V, k = 1:n], Bin)
@variable(model_sbrp, z[i in V, l in S, k = 1:n], Bin)
@variable(model_sbrp, u[i in V] >= 0 )
@objective(model_sbrp, Min, sum(c[i,j] * x[i,j,k] for i in V, j in V, k in 1:n if i != j))
for i in V
for k in 1:n
@constraint(model_sbrp, sum(x[i, j, k] for j in V if i!=j) == sum(x[j, i, k] for j in V if i!=j))
@constraint(model_sbrp, sum(x[i, j, k] for j in V if i!=j) == y[i, k])
end
end
@constraint(model_sbrp, [i in V, i != 1 ],sum(y[i,k] for k = 1:n) <= 1)
@constraint(model_sbrp, [l in S, i in V], sum(z[i,l,k] for k = 1:n) <= s[i,l])
@constraint(model_sbrp, [k in 1:n], sum(z[i,l,k] for i in V, l in S) <= C)
@constraint(model_sbrp, [i in V, l in S, k in 1:n], z[i,l,k] <= y[i,k])
@constraint(model_sbrp, [l in S], sum(z[i,l,k] for i in V, k = 1:n) == 1)
@constraint(model_sbrp, [i in V, j in V, k in 1:n], u[i] - u[j] + n*x[i,j,k] >= n - 1)
@constraint(model_sbrp, u[1] == 1)
```

i’m sending a small-sized test instance

C = 10

q = 8

c=

[0.0 3.16 1.41 1.0 2.24;

3.16 0.0 4.0 3.61 4.12;

1.41 4.0 0.0 2.24 1.0;

1.0 3.61 2.24 0.0 3.16;

2.24 4.12 1.0 3.16 0.0]

s=

[0 0 0 0 0 0 0 0 0 0;

0 0 1 1 1 0 0 0 1 0;

0 0 0 1 0 0 1 1 0 1;

1 0 1 0 0 0 0 1 1 0;

0 1 0 0 0 1 1 1 0 0]

i = 1

V = [1 2 3 4 5]

S = size(s,2)

n = length(V)