Model is infeasible
Hi,
i created a model for scheduling, in which processsteps and timesteps are implemented.
The model works fine until i add constraints which limit the processsteps to a maximum of 2 at one timestep.
for t in range(0,T):
m.addConstr(quicksum([v[(p,t)] for p in processsteps]) <= 2)
After this the model is infeasible. You can uncomment this line and run the code to see what the result would look like. Do you have any idea why it doesnt work after adding?
here is the full code:
from gurobipy import *
P = 5
T = 14
timeperiods = range(T)
processsteps = ['Form_saeubern','Form_
time = {'Form_saeubern':2,'Form_
m = Model()
v = m.addVars(processsteps, timeperiods, vtype=GRB.BINARY)
v_i = m.addVars(processsteps, timeperiods, vtype=GRB.BINARY)
v_e = m.addVars(processsteps, timeperiods, vtype=GRB.BINARY)
w = m.addVars(processsteps, timeperiods, vtype=GRB.BINARY)
z = m.addVars(timeperiods, vtype=GRB.BINARY)
m.addConstr(quicksum([v[(p,0)] for p in processsteps]) >= 1)
m.addConstrs(v_i[(p,t)] == (v[(p,t)]-v[(p,t+1)]) for p in processsteps for t in range(0,T-1))
m.addConstrs(v_e[(p,t)] == max_(v_i[(p,t)], 0.0) for p in processsteps for t in range(0,T-1))
for p in processsteps:
m.addSOS(GRB.SOS_TYPE1, [v_e[(p,t)] for t in range(0,T-1)])
for p in processsteps:
m.addConstr(quicksum([(v[(p,t)
for p in processsteps:
for t in range(0,T):
m.addConstr(w[(p,t)] == 1-v[(p,t)])
for t in range(0,T):
m.addGenConstrAnd(z[(t)], [w[(p,t)] for p in processsteps])
for t in range(0,T):
m.addConstr(quicksum([v[(p,t)] for p in processsteps]) <= 2)
m.setObjective(quicksum([(z[(
m.update()
m.optimize()
print(m.ObjVal)
for p in processsteps:
x = []
for t in timeperiods:
x.append(int(v[(p,t)].X))
print(p,x)
print()
for p in processsteps:
x = []
for t in timeperiods:
x.append(int(w[(p,t)].X))
print(x)
print()
for p in processsteps:
x = []
for t in timeperiods:
x.append(int(v_e[(p,t)].X))
print(x)
print()
u =[]
for t in timeperiods:
u.append(int(z[(t)].X))
print(u)
Nice Regards
Sascha
-
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 why not try our AI Gurobot?.
Post is closed for comments.
Comments
1 comment