Constraint expression
AnsweredHelloo,
I have a probleme and i would like some help,
i want to establish different constraint for my variable S[i,c,j,t] depending on j,
So i defined different J like this :
J1=range(6,11)
J21=range(0,1)
J22=range(2,3)
J2=chain(J21,J22)
J31=range(1,2)
J32=range(3,5)
J3=chain(J31,J32)
J4=range(5,6)
After that i defined my constraint this way :
for i in range(I):
for c in range(C):
for t in range(T):
for j in J2:
model.addConstr(S[i,c,j,t]<=15)
for i in range(I):
for c in range(C):
for t in range(T):
for j in J3:
model.addConstr(S[i,c,j,t]<=6)
Same thing for J4 and J1...
The probleme is that i found a solution where S[2,0,3,0]=15, while j=3 is in J3 and my variable S shoulde be <=6.

Thank you !
0
-
Official comment
This post is more than two 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 Rayan,
As a way of debugging I suggest you add a print statement in your code:
for i in range(I):
for c in range(C):
for t in range(T):
for j in J3:
print(i,c,j,t)
model.addConstr(S[i,c,j,t]<=6)which will make it clear if you are actually generating this constraint for S[2,0,3,0].
The most likely explanation is that you are not.
- Riley
0
Post is closed for comments.
Comments
2 comments