0

I have a vehicle routing problem solved by linear programming, but I'm confused about the constraints of it (see the model on figure 1). in the model, u and x are decision variables, and we set node 0 as the depot, nodes 1 to n as customers. constraints 1 & 2 indicate that there can only be one edge for both going into and out of the CUSTOMER nodes. However when I use Gurobi optimizer to solve it, I find the solution always includes the depot (node 0) in (see a solution on figure 2). Even I set the depot to an extremely far location (figure 3&4), the depot is still in the solution. Theoretically, to minimize the objective function, if there's no constraints about the edges into and out of the depot, then x_0i and x_i0 should always be 0. The constraints about the depot can be like sum(x_i0 >= 1), but there's no such constraints in the model.

This is the code used for adding constraints:

mdl.addConstrs(   # mdl is the name of the model
    quicksum(x[i, j] for j in V if j != i) == 1 for i in N)  # only one edge into customer node i
mdl.addConstrs(
    quicksum(x[i, j] for i in V if i != j) == 1 for j in N)  # only one edge out of customer node i
mdl.addConstrs((x[i, j] == 1) >> (u[i] + q[i] == u[j]) for i, j in A if i != 0 and j != 0)
mdl.addConstrs(u[i] >= q[i] for i in N)
mdl.addConstrs(u[i] <= Q for i in N)

Now I'm confident that my code is not problematic (if anyone want to check it I've put it on my Github: https://github.com/KaiyuWei/VRP-problem-by-Gurobi--Python), then could anyone explain the reason why the depot is always included? Thanks!

figure 1

figure 2

figure 3

figure 4

kaiyu wei
  • 431
  • 2
  • 5
  • 14
  • You should probably first look into the node with **3** out-going edges (2nd picture). And please include the relevant parts of the code here if debugging is what you need. Don't force people leaving this site to see your code. – sascha Jul 10 '21 at 17:50
  • @sascha Thank you for your response. I've posted the code about adding constraints here. – kaiyu wei Jul 10 '21 at 20:32
  • This question is better suited for the OR stackexchange site: https://or.stackexchange.com/ – mattmilten Jul 14 '21 at 10:00
  • @mattmilten Thank you somuch, it's a good place! – kaiyu wei Jul 15 '21 at 13:00

0 Answers0