Constraint has no Bool Value
AnsweredI get the following error for this constraint :
for i in range(I):
for k in range(K):
for t in range(T):
model.addConstr(Tr[i,k,t]==0 or Tr[i,k,t]==9 or Tr[i,k,t]==10 or Tr[i,k,t]==11)

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. -
You cannot specify a group of "or" constraints like this using the Model.addConstr() method.
Assuming \(\texttt{Tr}\) is a variable object, you can model this logic by defining the \(\texttt{Tr}\) variables as semi-continuous integer variables. Semi-continuous variables can either take a value of \( 0 \) or a value between the specified lower and upper bounds. In your case, you would add lower bounds of \( 9 \) and upper bounds of \( 11 \):
Tr = model.addVars(I, K, T, lb=9, ub=11, vtype=GRB.SEMIINT, name="Tr")
0 -
it worked !!
Tnahk you !
0
Post is closed for comments.
Comments
3 comments