My model is infeasible. Can someone please help me?
AnsweredHello, my code should model the real-life situation of visiting moisture level sensors. Some of these sensors are at the same location as the depot and therefore my distance matrix seems a bit weird. I am trying to use Gurobi to check my heuristic solution to see if it is even close to optimality. However, something is not working quite right. I want to automate checking the heuristic solution, with the inputs: number of vehicles (num_vehicles), the capacity of all the vehicles which is uniform (capacity), and demand at all the sensors which is also uniform (demand). These can all differ according to the input from the heuristic solution. Afterwards, I want to print the different routes to be able to check if they are the same as the heuristic solution.
However, after checking the code thoroughly I am not able to see what is wrong with it.
I hope someone can help me! Thank you in advance!
Edit:
The IIS can be found here:
\ Model CVRP_copy
\ LP format - for model browsing. Use MPS format to capture full model detail.
Minimize
Subject To
R7: C12 + C13 + C24 + C25 + C36 + C37 + C48 + C49 + C60 + C61 + C72 + C73
= 1
R42: C12 + C24 + C36 + C48 + C60 + C72 = 1
R43: C13 + C25 + C37 + C49 + C61 + C73 = 1
Bounds
Binaries
C12 C13 C24 C25 C36 C37 C48 C49 C60 C61 C72 C73
End
AC
-
Hi Jordi - Did you try to compute an IIS as discussed in the Knowledge Base article How do I determine why my model is infeasible?
0 -
yes, but still it is not very clear to me what is wrong the ISS:
\ Model CVRP_copy
\ LP format - for model browsing. Use MPS format to capture full model detail.
Minimize
Subject To
R7: C12 + C13 + C24 + C25 + C36 + C37 + C48 + C49 + C60 + C61 + C72 + C73
= 1
R42: C12 + C24 + C36 + C48 + C60 + C72 = 1
R43: C13 + C25 + C37 + C49 + C61 + C73 = 1
Bounds
Binaries
C12 C13 C24 C25 C36 C37 C48 C49 C60 C61 C72 C73
End
AC0 -
You probably need to define N and V as
N = [i for i in range(1,n)] # set of clients
V = [i for i in range(n)] # set of clients plus the depot (depot is 0)This would lead to a feasible model. But I think a constraint is missing that the same vehicle is used when arriving at client i and when leaving client i.And finally, I think# Each vehicle must leave the depot
mdl.addConstrs(quicksum(x[i, 0, k] for i in V if i != 0) == 1 for k in range(num_vehicles))needs to be
# Each vehicle must leave the depot
mdl.addConstrs(quicksum(x[0, i, k] for i in V if i != 0) == 1 for k in range(num_vehicles))Then it also fits your evaluation of the solution.0
Please sign in to leave a comment.
Comments
3 comments