Seeking help: Explored 0 nodes (0 simplex iterations)
AnsweredMy project is about CVRP in picking-up waste with the fuzzy capacity of the vehicle.
n = 11 #nodes
cust = [ i for i in range(n) if i !=0]
nodes = [0] + cust
#traveltime
tt = {(i,j): traveltime[randomizer,i,j] for i in nodes for j in nodes}
#capacity
a = {1:5000, 2:5000, 3:5000, 4:5000}
d = {1:5300, 2:5300, 3:5300, 4:5300}
vehiculos = [1,2,3,4]
arco_var = [(i,j,k) for i in nodes for j in nodes for k in vehiculos]
arco_qua = [(i,k) for i in nodes for k in vehiculos]
arco_miu = [k for k in vehiculos]
from gurobipy import Model, GRB, quicksum
mdl = Model('CVRP')
mdl.ModelSense = GRB.MINIMIZE
y = mdl.addVars(arco_var, vtype=GRB.BINARY, name='y')
x = mdl.addVars(arco_qua, vtype=GRB.CONTINUOUS, name='x')
m = mdl.addVars(arco_miu, vtype=GRB.CONTINUOUS, name='m')
mdl.setObjective(quicksum(y[i,j,k]*tt[i,j]*m[k] for i,j,k in arco_var))
#fuzzy capacity constraints
for k in vehiculos:
for i in cust:
covva = x[i,k]
woce = m[k]
mdl.addGenConstrPWL(covva, woce, [0,5000,5100,5300,5500], [1,1,1.25,2.5,10])
m[k] = woce
mdl.addConstrs(quicksum(y[0,j,k] for j in cust )<=1 for k in vehiculos)
mdl.addConstrs(quicksum(y[i,0,k] for i in cust )<=1 for k in vehiculos)
mdl.addConstrs(quicksum(y[i,j,k] for j in nodes for k in vehiculos if i!=j)==1 for i in cust)
mdl.addConstrs((quicksum(y[i,j,k] for j in nodes if i!=j)-quicksum(y[j,i,k] for j in nodes if i!=j))==0
for i in nodes for k in vehiculos)
mdl.addConstrs((y[i,j,k]==1) >> (x[i,k] + demand[i] == x[j,k]) for i in cust for j in cust for k in vehiculos if i!=j)
mdl.addConstrs((x[i,k] + eps) <= d[k] for i in cust for k in vehiculos)
When I run this model I keep having 0 results as if the model is not iterating on any nodes.
Please help, thanks!
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support. -
Hi Putri,
I can't tell what the issue is here from looking solely at the model code. What error message and/or log output are you seeing? At what point in this code do you call mdl.optimize() to solve the model?
Best regards,
Simon0 -
Hi Simon,
I write my code as what I write above and call the mdl.optimize() afterward. Here is the result I got.

The obj func = 0 and there is no value stored at y, x, and m variables
0 -
Update:
I put the codes which contains 'mdl' in one cell
and the result:
0 -
Hi Putri,
You will need to have your full Gurobi license set up (academic license or take-gurobi-with-you, as we discussed today, depending on whether this is for your commercial or academic work) to run models with more than 2000 variables and constraints.
Please see this post for further details, or open a support ticket at https://support.gurobi.com/hc/en-us if you are having trouble with the license setup.
Best regards,
Simon0
Post is closed for comments.
Comments
5 comments