Skip to main content

Capacitated Vehicle Routing Problem - Formulation & Code

Awaiting user input

Comments

6 comments

  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    This is a continuation of https://support.gurobi.com/hc/en-us/community/posts/4403683886993

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Wissam,

    Could you elaborate or what exactly is strange with the formulation/implementation?

    To my understanding your objective function should read

    mdl.setObjective(quicksum(x[i,j,k]*c[(i,j)] for (i,j) in A for k in K))

    Is this the source of the problem?

    I would also recommend to work with the write() function and check whether the model you constructed is the one you also expect it to be.

    mdl.write("myLP.lp")

    Best regards,
    Jaromił

    0
  • Wissam El Jablaoui
    Gurobi-versary
    First Comment
    First Question

    In the results, there should be active arcs leaving the depot and it shows none. In addition, there is one vehicle type 1 and it cannot satisfy all the customers' demand at the same time. 

    I rewrote the objective function like you recommended and I got the same solution. 

    Will review and get back with new findings. 

     

    Thank you for your support!

    Regards,

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Wissam,

    Usually, you should define a set of edges and then define your \(\texttt{x}\) variables over it. I guess in your case, the set of edges is defined as \(\texttt{A}\).

    Best regards,
    Jaromił

    0
  • Mario Ruthmair
    Gurobi Staff Gurobi Staff

    Since I just stumbled over this old thread:
    Note that there are constraints missing that eliminate vehicle subtours that are separated from the depot.
    There are many ways to do that, using Big-M constraints, single/multi-commodity flows, connectivity cuts, etc.

    0
  • Mario Ruthmair
    Gurobi Staff Gurobi Staff

    Additionally, since variable index k defines a vehicle type and not a single vehicle, the capacity constraint for one particular k is too restrictive since it sums up the demands served by all vehicles of some type.

    0

Please sign in to leave a comment.