SBRP problem with capacity os bus

I’m trying to model a problem with school transport routes, however, according to the code below, whenever the bus capacity is exceeded by the number of students, the code presents an error. I don’t know which constraint the problem is. Can anybody help me?

function sbrp(C, V, S, c, s, i, time_limit)
    # Extract the number of stops
    n = length(V)

    # Create a JuMP model with CPLEX optimizer
    model_sbrp = Model(optimizer_with_attributes(CPLEX.Optimizer,
        "CPX_PARAM_TILIM" => time_limit,
        "CPX_PARAM_THREADS" => 1))

    # Decision Variables
    @variable(model_sbrp, x[i in V, j in V, k = 1:n; i != j], Bin)  # 1 if bus k travels from i to j, 0 otherwise
    @variable(model_sbrp, y[i in V, k = 1:n], Bin)  # 1 if bus k visits stop i, 0 otherwise   
    @variable(model_sbrp, z[i in V, l in S, k = 1:n], Bin)  # 1 if student l is picked up by bus k at stop i, 0 otherwise 
    @variable(model_sbrp, u[i in V], Int)  # order of visit to stop i 

    # Objective Function
    @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))

    # Constraints
    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 != 0], 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, [i in 2:n, j in 2:n, k = 1:n; i != j], (u[i] + 1) <= (u[j] + n * (1 - x[i, j, k])))

    # Optimization
    status = optimize!(model_sbrp)

    # Retrieve results
    X_values = value.(x)
    zIP = objective_value(model_sbrp)
    tzIP = MOI.get(model_sbrp, MOI.SolveTimeSec())
    LRG = MOI.get(model_sbrp, MOI.RelativeGap())

    return (zIP, tzIP, LRG, X_values)
end

Hi @Victor_Neto, welcome to the forum.

Can you provide a reproducible example of running the code with data and the error that happens?

If by error you mean infeasibility, then the JuMP documentation has some suggestions for how to debug: Debugging · JuMP

Dear Oscar
thank you very much for your support.
I created a new topic: https://discourse.julialang.org/t/subtour-elimination-constraints/106902
Best
Victor

1 Like

No need to start a new topic if it’s the same question. We’re not StackOverflow, so you’re free to have a conversation :smile:

this time i formulated the question better kkkk

1 Like

Haha it’s not a problem. But you can always edit your original post, or reply with the new formulation. We tend to try and go for a more conversational tone, rather than a question-and-answer where you immediately have to post a coherent and useful question. Anyway, let’s carry on in the other thread.