Help with implementing an LP
OngoingHello folks,
I need your help. I'm currently trying to implement an old LP (which I set up as part of my research at university) in a new programming language for nostalgic reasons. The old model was written in OLP, and now I want to implement it with Gurobi (Python). It is a manpower problem. I get the model set up without errors, but not solved, all solutions are infeasible. But I know that the model is feasible. Now I am wondering where I have made a mistake. I would be very grateful for any help.
You can find the relevant data here. In my code, I have read everything separately as CSV, but I upload the data in a .xlsx. You can find the old code here, the mathematical model here.
This is my current code:
import gurobipy as gp
from gurobipy import GRB
import pandas as pd
model = gp.Model()
T = [1,2,3,4,5,6,7]
B = [1,2]
# Data
df = pd.read_csv('/.../Work.csv', delimiter=';')
ID_W = df['Id'].tolist()
Q_W = df['Quali'].tolist()
WE_W = df['WE'].tolist()
NW_W = df['Night'].tolist()
F_W = df['Field'].tolist()
RT_W = df['Remaining Work Time'].tolist()
ED_W = df['ED'].tolist()
Q_W = {s:q for s,q in zip(ID_W, Q_W)}
WE_W = {s:we for s,we in zip(ID_W, WE_W)}
NW_W = {s:nd for s,nd in zip(ID_W, NW_W)}
F_W = {s:b for s,b in zip(ID_W, F_W)}
RT_W = {s:raz for s,raz in zip(ID_W, RT_W)}
ED_W = {s:na for s,na in zip(ID_W, ED_W)}
df1 = pd.read_csv('/.../People.csv', delimiter=';')
ID_P = df1['Id'].tolist()
C_P = df1['Cost'].tolist()
Q_P = df1['Quali'].tolist()
WT_P = df1['Work Time'].tolist()
ED_P = df1['ED'].tolist()
C_P = {a:c for a,c in zip(ID_P, C_P)}
Q_P = {a:q for a,q in zip(ID_P, Q_P)}
WT_P = {a:az for a,az in zip(ID_P, WT_P)}
ED_P = {a:na for a,na in zip(ID_P, ED_P)}
DemandList = [
[1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 0, 0],
[1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 0, 0],
[1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1],
[0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 0, 0],
[1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1],
[0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 0, 0],
[1, 0, 1, 0, 0, 0, 0]
]
Demanddict = {}
for i in ID_W:
for t in T:
Demanddict[i,t]=DemandList[i-1][t-1]
x = model.addVars(ID_P, ID_W, T, vtype=GRB.BINARY, name="x")
y = model.addVars(ID_P, B, vtype=GRB.BINARY, name="y")
# Objective function
model.setObjective(gp.quicksum(C_P[j] * y[j,b] for j in ID_P for b in B), GRB.MINIMIZE)
# Constraints
for j in ID_P:
for t in T:
for b in B:
model.addConstr((gp.quicksum(x[j,i,t] for i in F_W) <= y[j,b]), name = "CONS1")
for i in ID_W:
for t in T:
if Demanddict[i,t] > 0:
model.addConstr((gp.quicksum(x[j,i,t] for j in ID_P if Q_P[j] <= Q_W[i]) >= Demanddict[i,t]), name = "CONS3")
for j in ID_P:
for b in B:
model.addConstr((gp.quicksum(x[j,i,t] for i in ID_W for t in T if NW_W[i] == 1 and F_W[i] == b) <= 5), name = "CONS3")
for j in ID_P:
for b in B:
model.addConstr((gp.quicksum(x[j,i,t] for i in ID_W for t in T if WE_W[i] == 1 and F_W[i] == b) <= 2), name = "CONS4")
for j in ID_P:
for b in B:
model.addConstr((gp.quicksum(RT_W[i] * x[j,i,t] for i in ID_W for t in T if F_W[i] == b) <= WT_P[j] * y[j,b]), name = "CONS5")
for j in ID_P:
model.addConstr((gp.quicksum(y[j,b] for b in B) <= 1), name ="CONS6")
for t in T[:-1]:
for j in ID_P:
for i in ID_W:
if NW_W[i] == 1:
model.addConstr((x[j,i,t] + gp.quicksum(x[j,k,t+1] for k in ID_W if F_W[k] == F_W[i] and NW_W[k] != 1) <= 1), name = "CONS7")
model.optimize()
-
Have you tried to run the Model.ComputeIIS() method on the infeasible model? It will let you know the smallest set of variables and constraints that make your model infeasible. To this end, the following articles will be helpful:
0 -
Simranjit Kaur I just did. It yielded this output!
Computing Irreducible Inconsistent Subsystem (IIS)...
Constraints | Bounds | Runtime
Min Max Guess | Min Max Guess |
--------------------------------------------------------------------------
0 2031 - 0 0 0 0s
31 31 31 0 0 0 1sIIS computed: 31 constraints, 0 bounds
IIS runtime: 1.14 seconds (0.69 work units)
Warning: linear constraint 0 and linear constraint 1 have the same name "CONS1"0 -
Great! Once you've executed computeIIS(), the constraints participating in the IIS can be exported to an ILP file using model.write("mymodel.ilp"). You can inspect the constraints in this file using any text editor.
0 -
Thats the Output i get:
\ Model _copy
\ LP format - for model browsing. Use MPS format to capture full model detail.
Minimize
Subject To
CONS1: x[1,1,5] + x[1,2,5] + x[1,3,5] + x[1,4,5] + x[1,5,5] + x[1,6,5]
+ x[1,7,5] + x[1,8,5] + x[1,9,5] + x[1,10,5] + x[1,11,5] + x[1,12,5]
+ x[1,13,5] + x[1,14,5] + x[1,15,5] + x[1,16,5] + x[1,17,5] + x[1,18,5]
+ x[1,19,5] - y[1,1] <= 0
CONS1: x[1,1,5] + x[1,2,5] + x[1,3,5] + x[1,4,5] + x[1,5,5] + x[1,6,5]
+ x[1,7,5] + x[1,8,5] + x[1,9,5] + x[1,10,5] + x[1,11,5] + x[1,12,5]
+ x[1,13,5] + x[1,14,5] + x[1,15,5] + x[1,16,5] + x[1,17,5] + x[1,18,5]
+ x[1,19,5] - y[1,2] <= 0
CONS1: x[2,1,5] + x[2,2,5] + x[2,3,5] + x[2,4,5] + x[2,5,5] + x[2,6,5]
+ x[2,7,5] + x[2,8,5] + x[2,9,5] + x[2,10,5] + x[2,11,5] + x[2,12,5]
+ x[2,13,5] + x[2,14,5] + x[2,15,5] + x[2,16,5] + x[2,17,5] + x[2,18,5]
+ x[2,19,5] - y[2,1] <= 0
CONS1: x[3,1,5] + x[3,2,5] + x[3,3,5] + x[3,4,5] + x[3,5,5] + x[3,6,5]
+ x[3,7,5] + x[3,8,5] + x[3,9,5] + x[3,10,5] + x[3,11,5] + x[3,12,5]
+ x[3,13,5] + x[3,14,5] + x[3,15,5] + x[3,16,5] + x[3,17,5] + x[3,18,5]
+ x[3,19,5] - y[3,1] <= 0
CONS1: x[4,1,5] + x[4,2,5] + x[4,3,5] + x[4,4,5] + x[4,5,5] + x[4,6,5]
+ x[4,7,5] + x[4,8,5] + x[4,9,5] + x[4,10,5] + x[4,11,5] + x[4,12,5]
+ x[4,13,5] + x[4,14,5] + x[4,15,5] + x[4,16,5] + x[4,17,5] + x[4,18,5]
+ x[4,19,5] - y[4,1] <= 0
CONS1: x[4,1,5] + x[4,2,5] + x[4,3,5] + x[4,4,5] + x[4,5,5] + x[4,6,5]
+ x[4,7,5] + x[4,8,5] + x[4,9,5] + x[4,10,5] + x[4,11,5] + x[4,12,5]
+ x[4,13,5] + x[4,14,5] + x[4,15,5] + x[4,16,5] + x[4,17,5] + x[4,18,5]
+ x[4,19,5] - y[4,2] <= 0
CONS1: x[5,1,5] + x[5,2,5] + x[5,3,5] + x[5,4,5] + x[5,5,5] + x[5,6,5]
+ x[5,7,5] + x[5,8,5] + x[5,9,5] + x[5,10,5] + x[5,11,5] + x[5,12,5]
+ x[5,13,5] + x[5,14,5] + x[5,15,5] + x[5,16,5] + x[5,17,5] + x[5,18,5]
+ x[5,19,5] - y[5,1] <= 0
CONS1: x[5,1,5] + x[5,2,5] + x[5,3,5] + x[5,4,5] + x[5,5,5] + x[5,6,5]
+ x[5,7,5] + x[5,8,5] + x[5,9,5] + x[5,10,5] + x[5,11,5] + x[5,12,5]
+ x[5,13,5] + x[5,14,5] + x[5,15,5] + x[5,16,5] + x[5,17,5] + x[5,18,5]
+ x[5,19,5] - y[5,2] <= 0
CONS1: x[6,1,5] + x[6,2,5] + x[6,3,5] + x[6,4,5] + x[6,5,5] + x[6,6,5]
+ x[6,7,5] + x[6,8,5] + x[6,9,5] + x[6,10,5] + x[6,11,5] + x[6,12,5]
+ x[6,13,5] + x[6,14,5] + x[6,15,5] + x[6,16,5] + x[6,17,5] + x[6,18,5]
+ x[6,19,5] - y[6,1] <= 0
CONS1: x[6,1,5] + x[6,2,5] + x[6,3,5] + x[6,4,5] + x[6,5,5] + x[6,6,5]
+ x[6,7,5] + x[6,8,5] + x[6,9,5] + x[6,10,5] + x[6,11,5] + x[6,12,5]
+ x[6,13,5] + x[6,14,5] + x[6,15,5] + x[6,16,5] + x[6,17,5] + x[6,18,5]
+ x[6,19,5] - y[6,2] <= 0
CONS1: x[7,1,5] + x[7,2,5] + x[7,3,5] + x[7,4,5] + x[7,5,5] + x[7,6,5]
+ x[7,7,5] + x[7,8,5] + x[7,9,5] + x[7,10,5] + x[7,11,5] + x[7,12,5]
+ x[7,13,5] + x[7,14,5] + x[7,15,5] + x[7,16,5] + x[7,17,5] + x[7,18,5]
+ x[7,19,5] - y[7,1] <= 0
CONS1: x[8,1,5] + x[8,2,5] + x[8,3,5] + x[8,4,5] + x[8,5,5] + x[8,6,5]
+ x[8,7,5] + x[8,8,5] + x[8,9,5] + x[8,10,5] + x[8,11,5] + x[8,12,5]
+ x[8,13,5] + x[8,14,5] + x[8,15,5] + x[8,16,5] + x[8,17,5] + x[8,18,5]
+ x[8,19,5] - y[8,1] <= 0
CONS1: x[9,1,5] + x[9,2,5] + x[9,3,5] + x[9,4,5] + x[9,5,5] + x[9,6,5]
+ x[9,7,5] + x[9,8,5] + x[9,9,5] + x[9,10,5] + x[9,11,5] + x[9,12,5]
+ x[9,13,5] + x[9,14,5] + x[9,15,5] + x[9,16,5] + x[9,17,5] + x[9,18,5]
+ x[9,19,5] - y[9,1] <= 0
CONS1: x[9,1,5] + x[9,2,5] + x[9,3,5] + x[9,4,5] + x[9,5,5] + x[9,6,5]
+ x[9,7,5] + x[9,8,5] + x[9,9,5] + x[9,10,5] + x[9,11,5] + x[9,12,5]
+ x[9,13,5] + x[9,14,5] + x[9,15,5] + x[9,16,5] + x[9,17,5] + x[9,18,5]
+ x[9,19,5] - y[9,2] <= 0
CONS1: x[10,1,5] + x[10,2,5] + x[10,3,5] + x[10,4,5] + x[10,5,5]
+ x[10,6,5] + x[10,7,5] + x[10,8,5] + x[10,9,5] + x[10,10,5]
+ x[10,11,5] + x[10,12,5] + x[10,13,5] + x[10,14,5] + x[10,15,5]
+ x[10,16,5] + x[10,17,5] + x[10,18,5] + x[10,19,5] - y[10,1] <= 0
CONS3: x[1,11,5] + x[2,11,5] + x[3,11,5] + x[4,11,5] + x[5,11,5]
+ x[6,11,5] + x[7,11,5] + x[8,11,5] + x[9,11,5] + x[10,11,5] >= 1
CONS5: 8 x[2,11,1] + 8 x[2,11,2] + 8 x[2,11,3] + 8 x[2,11,4] + 8 x[2,11,5]
+ 8 x[2,11,6] + 8 x[2,11,7] + 8 x[2,12,1] + 8 x[2,12,2] + 8 x[2,12,3]
+ 8 x[2,12,4] + 8 x[2,12,5] + 8 x[2,12,6] + 8 x[2,12,7] + 6 x[2,13,1]
+ 6 x[2,13,2] + 6 x[2,13,3] + 6 x[2,13,4] + 6 x[2,13,5] + 6 x[2,13,6]
+ 6 x[2,13,7] + 8 x[2,14,1] + 8 x[2,14,2] + 8 x[2,14,3] + 8 x[2,14,4]
+ 8 x[2,14,5] + 8 x[2,14,6] + 8 x[2,14,7] + 8 x[2,15,1] + 8 x[2,15,2]
+ 8 x[2,15,3] + 8 x[2,15,4] + 8 x[2,15,5] + 8 x[2,15,6] + 8 x[2,15,7]
+ 8 x[2,16,1] + 8 x[2,16,2] + 8 x[2,16,3] + 8 x[2,16,4] + 8 x[2,16,5]
+ 8 x[2,16,6] + 8 x[2,16,7] - 40 y[2,2] <= 0
CONS5: 8 x[3,11,1] + 8 x[3,11,2] + 8 x[3,11,3] + 8 x[3,11,4] + 8 x[3,11,5]
+ 8 x[3,11,6] + 8 x[3,11,7] + 8 x[3,12,1] + 8 x[3,12,2] + 8 x[3,12,3]
+ 8 x[3,12,4] + 8 x[3,12,5] + 8 x[3,12,6] + 8 x[3,12,7] + 6 x[3,13,1]
+ 6 x[3,13,2] + 6 x[3,13,3] + 6 x[3,13,4] + 6 x[3,13,5] + 6 x[3,13,6]
+ 6 x[3,13,7] + 8 x[3,14,1] + 8 x[3,14,2] + 8 x[3,14,3] + 8 x[3,14,4]
+ 8 x[3,14,5] + 8 x[3,14,6] + 8 x[3,14,7] + 8 x[3,15,1] + 8 x[3,15,2]
+ 8 x[3,15,3] + 8 x[3,15,4] + 8 x[3,15,5] + 8 x[3,15,6] + 8 x[3,15,7]
+ 8 x[3,16,1] + 8 x[3,16,2] + 8 x[3,16,3] + 8 x[3,16,4] + 8 x[3,16,5]
+ 8 x[3,16,6] + 8 x[3,16,7] - 40 y[3,2] <= 0
CONS5: 8 x[7,11,1] + 8 x[7,11,2] + 8 x[7,11,3] + 8 x[7,11,4] + 8 x[7,11,5]
+ 8 x[7,11,6] + 8 x[7,11,7] + 8 x[7,12,1] + 8 x[7,12,2] + 8 x[7,12,3]
+ 8 x[7,12,4] + 8 x[7,12,5] + 8 x[7,12,6] + 8 x[7,12,7] + 6 x[7,13,1]
+ 6 x[7,13,2] + 6 x[7,13,3] + 6 x[7,13,4] + 6 x[7,13,5] + 6 x[7,13,6]
+ 6 x[7,13,7] + 8 x[7,14,1] + 8 x[7,14,2] + 8 x[7,14,3] + 8 x[7,14,4]
+ 8 x[7,14,5] + 8 x[7,14,6] + 8 x[7,14,7] + 8 x[7,15,1] + 8 x[7,15,2]
+ 8 x[7,15,3] + 8 x[7,15,4] + 8 x[7,15,5] + 8 x[7,15,6] + 8 x[7,15,7]
+ 8 x[7,16,1] + 8 x[7,16,2] + 8 x[7,16,3] + 8 x[7,16,4] + 8 x[7,16,5]
+ 8 x[7,16,6] + 8 x[7,16,7] - 40 y[7,2] <= 0
CONS5: 8 x[8,11,1] + 8 x[8,11,2] + 8 x[8,11,3] + 8 x[8,11,4] + 8 x[8,11,5]
+ 8 x[8,11,6] + 8 x[8,11,7] + 8 x[8,12,1] + 8 x[8,12,2] + 8 x[8,12,3]
+ 8 x[8,12,4] + 8 x[8,12,5] + 8 x[8,12,6] + 8 x[8,12,7] + 6 x[8,13,1]
+ 6 x[8,13,2] + 6 x[8,13,3] + 6 x[8,13,4] + 6 x[8,13,5] + 6 x[8,13,6]
+ 6 x[8,13,7] + 8 x[8,14,1] + 8 x[8,14,2] + 8 x[8,14,3] + 8 x[8,14,4]
+ 8 x[8,14,5] + 8 x[8,14,6] + 8 x[8,14,7] + 8 x[8,15,1] + 8 x[8,15,2]
+ 8 x[8,15,3] + 8 x[8,15,4] + 8 x[8,15,5] + 8 x[8,15,6] + 8 x[8,15,7]
+ 8 x[8,16,1] + 8 x[8,16,2] + 8 x[8,16,3] + 8 x[8,16,4] + 8 x[8,16,5]
+ 8 x[8,16,6] + 8 x[8,16,7] - 40 y[8,2] <= 0
CONS5: 8 x[10,11,1] + 8 x[10,11,2] + 8 x[10,11,3] + 8 x[10,11,4]
+ 8 x[10,11,5] + 8 x[10,11,6] + 8 x[10,11,7] + 8 x[10,12,1]
+ 8 x[10,12,2] + 8 x[10,12,3] + 8 x[10,12,4] + 8 x[10,12,5]
+ 8 x[10,12,6] + 8 x[10,12,7] + 6 x[10,13,1] + 6 x[10,13,2]
+ 6 x[10,13,3] + 6 x[10,13,4] + 6 x[10,13,5] + 6 x[10,13,6]
+ 6 x[10,13,7] + 8 x[10,14,1] + 8 x[10,14,2] + 8 x[10,14,3]
+ 8 x[10,14,4] + 8 x[10,14,5] + 8 x[10,14,6] + 8 x[10,14,7]
+ 8 x[10,15,1] + 8 x[10,15,2] + 8 x[10,15,3] + 8 x[10,15,4]
+ 8 x[10,15,5] + 8 x[10,15,6] + 8 x[10,15,7] + 8 x[10,16,1]
+ 8 x[10,16,2] + 8 x[10,16,3] + 8 x[10,16,4] + 8 x[10,16,5]
+ 8 x[10,16,6] + 8 x[10,16,7] - 40 y[10,2] <= 0
CONS6: y[1,1] + y[1,2] <= 1
CONS6: y[2,1] + y[2,2] <= 1
CONS6: y[3,1] + y[3,2] <= 1
CONS6: y[4,1] + y[4,2] <= 1
CONS6: y[5,1] + y[5,2] <= 1
CONS6: y[6,1] + y[6,2] <= 1
CONS6: y[7,1] + y[7,2] <= 1
CONS6: y[8,1] + y[8,2] <= 1
CONS6: y[9,1] + y[9,2] <= 1
CONS6: y[10,1] + y[10,2] <= 1
Bounds
Binaries
x[1,1,5] x[1,2,5] x[1,3,5] x[1,4,5] x[1,5,5] x[1,6,5] x[1,7,5] x[1,8,5]
x[1,9,5] x[1,10,5] x[1,11,5] x[1,12,5] x[1,13,5] x[1,14,5] x[1,15,5]
x[1,16,5] x[1,17,5] x[1,18,5] x[1,19,5] x[2,1,5] x[2,2,5] x[2,3,5]
x[2,4,5] x[2,5,5] x[2,6,5] x[2,7,5] x[2,8,5] x[2,9,5] x[2,10,5] x[2,11,1]
x[2,11,2] x[2,11,3] x[2,11,4] x[2,11,5] x[2,11,6] x[2,11,7] x[2,12,1]
x[2,12,2] x[2,12,3] x[2,12,4] x[2,12,5] x[2,12,6] x[2,12,7] x[2,13,1]
x[2,13,2] x[2,13,3] x[2,13,4] x[2,13,5] x[2,13,6] x[2,13,7] x[2,14,1]
x[2,14,2] x[2,14,3] x[2,14,4] x[2,14,5] x[2,14,6] x[2,14,7] x[2,15,1]
x[2,15,2] x[2,15,3] x[2,15,4] x[2,15,5] x[2,15,6] x[2,15,7] x[2,16,1]
x[2,16,2] x[2,16,3] x[2,16,4] x[2,16,5] x[2,16,6] x[2,16,7] x[2,17,5]
x[2,18,5] x[2,19,5] x[3,1,5] x[3,2,5] x[3,3,5] x[3,4,5] x[3,5,5] x[3,6,5]
x[3,7,5] x[3,8,5] x[3,9,5] x[3,10,5] x[3,11,1] x[3,11,2] x[3,11,3]
x[3,11,4] x[3,11,5] x[3,11,6] x[3,11,7] x[3,12,1] x[3,12,2] x[3,12,3]
x[3,12,4] x[3,12,5] x[3,12,6] x[3,12,7] x[3,13,1] x[3,13,2] x[3,13,3]
x[3,13,4] x[3,13,5] x[3,13,6] x[3,13,7] x[3,14,1] x[3,14,2] x[3,14,3]
x[3,14,4] x[3,14,5] x[3,14,6] x[3,14,7] x[3,15,1] x[3,15,2] x[3,15,3]
x[3,15,4] x[3,15,5] x[3,15,6] x[3,15,7] x[3,16,1] x[3,16,2] x[3,16,3]
x[3,16,4] x[3,16,5] x[3,16,6] x[3,16,7] x[3,17,5] x[3,18,5] x[3,19,5]
x[4,1,5] x[4,2,5] x[4,3,5] x[4,4,5] x[4,5,5] x[4,6,5] x[4,7,5] x[4,8,5]
x[4,9,5] x[4,10,5] x[4,11,5] x[4,12,5] x[4,13,5] x[4,14,5] x[4,15,5]
x[4,16,5] x[4,17,5] x[4,18,5] x[4,19,5] x[5,1,5] x[5,2,5] x[5,3,5]
x[5,4,5] x[5,5,5] x[5,6,5] x[5,7,5] x[5,8,5] x[5,9,5] x[5,10,5] x[5,11,5]
x[5,12,5] x[5,13,5] x[5,14,5] x[5,15,5] x[5,16,5] x[5,17,5] x[5,18,5]
x[5,19,5] x[6,1,5] x[6,2,5] x[6,3,5] x[6,4,5] x[6,5,5] x[6,6,5] x[6,7,5]
x[6,8,5] x[6,9,5] x[6,10,5] x[6,11,5] x[6,12,5] x[6,13,5] x[6,14,5]
x[6,15,5] x[6,16,5] x[6,17,5] x[6,18,5] x[6,19,5] x[7,1,5] x[7,2,5]
x[7,3,5] x[7,4,5] x[7,5,5] x[7,6,5] x[7,7,5] x[7,8,5] x[7,9,5] x[7,10,5]
x[7,11,1] x[7,11,2] x[7,11,3] x[7,11,4] x[7,11,5] x[7,11,6] x[7,11,7]
x[7,12,1] x[7,12,2] x[7,12,3] x[7,12,4] x[7,12,5] x[7,12,6] x[7,12,7]
x[7,13,1] x[7,13,2] x[7,13,3] x[7,13,4] x[7,13,5] x[7,13,6] x[7,13,7]
x[7,14,1] x[7,14,2] x[7,14,3] x[7,14,4] x[7,14,5] x[7,14,6] x[7,14,7]
x[7,15,1] x[7,15,2] x[7,15,3] x[7,15,4] x[7,15,5] x[7,15,6] x[7,15,7]
x[7,16,1] x[7,16,2] x[7,16,3] x[7,16,4] x[7,16,5] x[7,16,6] x[7,16,7]
x[7,17,5] x[7,18,5] x[7,19,5] x[8,1,5] x[8,2,5] x[8,3,5] x[8,4,5] x[8,5,5]
x[8,6,5] x[8,7,5] x[8,8,5] x[8,9,5] x[8,10,5] x[8,11,1] x[8,11,2]
x[8,11,3] x[8,11,4] x[8,11,5] x[8,11,6] x[8,11,7] x[8,12,1] x[8,12,2]
x[8,12,3] x[8,12,4] x[8,12,5] x[8,12,6] x[8,12,7] x[8,13,1] x[8,13,2]
x[8,13,3] x[8,13,4] x[8,13,5] x[8,13,6] x[8,13,7] x[8,14,1] x[8,14,2]
x[8,14,3] x[8,14,4] x[8,14,5] x[8,14,6] x[8,14,7] x[8,15,1] x[8,15,2]
x[8,15,3] x[8,15,4] x[8,15,5] x[8,15,6] x[8,15,7] x[8,16,1] x[8,16,2]
x[8,16,3] x[8,16,4] x[8,16,5] x[8,16,6] x[8,16,7] x[8,17,5] x[8,18,5]
x[8,19,5] x[9,1,5] x[9,2,5] x[9,3,5] x[9,4,5] x[9,5,5] x[9,6,5] x[9,7,5]
x[9,8,5] x[9,9,5] x[9,10,5] x[9,11,5] x[9,12,5] x[9,13,5] x[9,14,5]
x[9,15,5] x[9,16,5] x[9,17,5] x[9,18,5] x[9,19,5] x[10,1,5] x[10,2,5]
x[10,3,5] x[10,4,5] x[10,5,5] x[10,6,5] x[10,7,5] x[10,8,5] x[10,9,5]
x[10,10,5] x[10,11,1] x[10,11,2] x[10,11,3] x[10,11,4] x[10,11,5]
x[10,11,6] x[10,11,7] x[10,12,1] x[10,12,2] x[10,12,3] x[10,12,4]
x[10,12,5] x[10,12,6] x[10,12,7] x[10,13,1] x[10,13,2] x[10,13,3]
x[10,13,4] x[10,13,5] x[10,13,6] x[10,13,7] x[10,14,1] x[10,14,2]
x[10,14,3] x[10,14,4] x[10,14,5] x[10,14,6] x[10,14,7] x[10,15,1]
x[10,15,2] x[10,15,3] x[10,15,4] x[10,15,5] x[10,15,6] x[10,15,7]
x[10,16,1] x[10,16,2] x[10,16,3] x[10,16,4] x[10,16,5] x[10,16,6]
x[10,16,7] x[10,17,5] x[10,18,5] x[10,19,5] y[1,1] y[1,2] y[2,1] y[2,2]
y[3,1] y[3,2] y[4,1] y[4,2] y[5,1] y[5,2] y[6,1] y[6,2] y[7,1] y[7,2]
y[8,1] y[8,2] y[9,1] y[9,2] y[10,1] y[10,2]
End0 -
Hi Lorenz,
The sum of the variables participating in the following constraint must be at least one:
CONS3: x[1,11,5] + x[2,11,5] + x[3,11,5] + x[4,11,5] + x[5,11,5] + x[6,11,5] + x[7,11,5] + x[8,11,5] + x[9,11,5] + x[10,11,5] >= 1
However, each of these variables is forced to zero from other constraints, which causes the infeasibility.
To see this, let's look at the constraints in which x[1,11,5] participates.
x[1,1,5] + x[1,2,5] + x[1,3,5] + x[1,4,5] + x[1,5,5] + x[1,6,5] + x[1,7,5] + x[1,8,5] + x[1,9,5] + x[1,10,5] + x[1,11,5] + x[1,12,5] + x[1,13,5] + x[1,14,5] + x[1,15,5] + x[1,16,5] + x[1,17,5] + x[1,18,5] + x[1,19,5] <= y[1,1]
x[1,1,5] + x[1,2,5] + x[1,3,5] + x[1,4,5] + x[1,5,5] + x[1,6,5] + x[1,7,5] + x[1,8,5] + x[1,9,5] + x[1,10,5] + x[1,11,5] + x[1,12,5] + x[1,13,5] + x[1,14,5] + x[1,15,5] + x[1,16,5] + x[1,17,5] + x[1,18,5] + x[1,19,5] <= y[1,2]
y[1,1] + y[1,2] <= 1The first two constraints imply that x[1,11,5] can be non-zero only if both y[1,2] and y[1,1] are positive. The third constraint forces at least one of y1,1] or y[1,2] to be zero, and therefore x[1,11,5] has to be zero. The same is true for other variables in the constraint CONS3 above.
To resolve this, please check the data input for accuracy, review the logic behind these constraints, and ensure they are built as expected.
Best regards,
Simran0 -
Thanks i got it. Sadly i dont really know why this happens. Do you have any idea which constraint may cause this issue or could be wrong?
\[
\begin{align} &\min\sum_{j,b}^{}j.C \cdot y_{jb}\\&\sum_{i:i.F}^{}x_{jit}\le y_{jf}~~~\forall j\in J,t\in T,f\in F\\&\sum_{j:j.Q\le i.Q}^{}x_{jit}\ge d_{it}~~~\forall i\in I,t\in T\\&\sum_{i,t:i.Night=1\wedge i.F=f}^{}x_{jit}\le 5~~~\forall j\in J,f\in F\\&\sum_{i,t:i.WE=1\wedge i.F=f}^{}x_{jit}\le 2~~~\forall j\in J,f\in F\\
&\sum_{i,t:i.F=f}^{}i.RT\cdot x_{jit}\le j.WT\cdot y_{jf}~~~\forall j\in J,f\in F\\&\sum_{f\in F}^{}y_{jf}\le 1~~~~\forall j\in J\\&x_{jit}+\sum_{k:k.F=f\wedge k.Night\neq1}^{}x_{jk(t+1)}\le 1~~~\forall j\in J,t\in T,i:i.Night = 1\\\end{align}\]0
Please sign in to leave a comment.
Comments
6 comments