Infeasible model
AnsweredHi,
I have a model based on a paper that I want to implement in Gurobi, but the constraint 13e makes the model infeasible. Any suggestions on what the error might be?
Thanks
Here is the code:
from gurobipy import *
p = [16682, 19802, 25610, 28357, 18389, 30305, 18242, 16129, 15957]
landa_max = [(0.95*i)/(52*5*8) for i in p]
landa_min = 0.125
#we have 9 demand points. the candidate locations for the facility are: 1, 2, 3
t = [[0,0.66,0.3],
[0.66,0,0,36],
[0.3,0.36,0],
[0.58,0.3,0.59],
[0.64,0.52,0.65],
[0.23,0.61,0.24],
[0.48,0.54,0.18],
[0.66,0.72,0.36],
[0.53,0.59,0.23]]
f = [23, 23.89, 16]
c = [10, 10, 10]
alpha = 0.25
beta =1
tau_max = 1.5
L = 10000
eps = 0.1
mu = [50,55,60,65,70,75,80,85]
m = 3 #facilities
n = 9 #customers
model = Model (name = "model")
x = model.addMVar((m,), name = 'x', vtype = GRB.BINARY)
y = model.addMVar((n, m), name = 'y', lb =0, vtype = GRB.CONTINUOUS)
z = model.addMVar((n, m), name = 'z', vtype = GRB.BINARY)
mu = model.addMVar((m, ), name = 'mu',lb =0, vtype = GRB.CONTINUOUS)
aux1 = model.addMVar((n, ), name = 'aux1', vtype = GRB.CONTINUOUS)
aux2 = model.addMVar((n, ), name = 'aux2', vtype = GRB.CONTINUOUS)
aux3 = model.addMVar((m, ), name = 'aux3', vtype = GRB.CONTINUOUS)
aux4 = model.addMVar((n,m), name = 'aux4', vtype = GRB.CONTINUOUS)
model_Obj = quicksum(f[j]*x[j] for j in range(m)) +quicksum(c[j]*mu[j] for j in range(m))
model.setObjective(model_Obj, GRB.MINIMIZE)
model.addConstrs(z[i, j] <= x[j] for i in range(n) for j in range(m)) #13.a
model.addConstrs(y[i, j] <= z[i, j] for i in range(n) for j in range(m)) #13.b
model.addConstrs(quicksum(z[i, j] for j in range(m)) >= 1 for i in range(n)) #13.c
model.addConstrs(quicksum(landa_max[i]*y[i, j] for i in range(n)) >= landa_min*x[j] for j in range(m)) #13.d
model.addConstrs(quicksum(x[j]*y[i,j] for j in range(m)) == aux1[i] for i in range(n))
for i in range(n):
model.addGenConstrLog(aux1[i], aux2[i])
############
model.addConstrs((mu[j]-quicksum(landa_max[r]*y[r,j] for r in range(n))) == aux3[j] for j in range(m))
model.addConstrs(aux2[i]*aux3[j] == aux4[i,j] for i in range(n) for j in range(m))
############
model.addConstrs((alpha*t[i][j]*aux3[j]+beta*alpha +aux4[i, j])*y[i, j] == 0.0
for i in range(n) for j in range(m)) #13e
model.addConstrs(alpha*t[i][j]*(aux3[j])+ beta*alpha+aux2[i]*(aux3[j]) >= 0
for i in range(n) for j in range(m)) #13f
model.addConstrs(t[i][j]*(mu[j]-quicksum(landa_max[i]*y[k,j] for k in range(n))+(1-x[j])*eps)+beta*x[j]<=
(tau_max + (1-z[i,j])*L)*quicksum(landa_max[i]*y[k,j] for k in range(n))
for i in range(n) for j in range(m)) #13g
model.addConstrs((quicksum(landa_max[i]*y[i, j] for i in range(n))) <= mu[j] for j in range(m)) #13h
model.params.NonConvex = 2
model.optimize()
-
Hi Mina,
The default lower bound for variables is 0. You may want to define a negative lower bound for some of your aux-variables.
Please note that the logarithmic constraint is approximated via piecewise linear functions. Tight bounds on the variables help to decrease the error in this approximation.
I hope this helps to solve the problem,
Marika0 -
Hi Marika,
Thank you very much for your response. That helps a lot.
Mina
0
Please sign in to leave a comment.
Comments
2 comments