Question about constraint
回答済みHi
I tried to insert this condition (/Zj {0}) but encountered the following error. What other method does Gurobi accept that I can try? My model is a MILP.
for i in items:
for j in items:
if i != j:
if coord_z[j] != 0:
# Restrições para mínimo e máximo de x
model.addConstr(min_x_i_j <= coord_x[i] + l[i], name=f"min_x_i_j_ub_{i}_{j}")
model.addConstr(min_x_i_j <= coord_x[j] + l[j], name=f"min_x_i_j_ub_{i}_{j}_2")
model.addConstr(min_x_i_j >= coord_x[i] + l[i] - (1 - stack[i, j]) * delta, name=f"min_x_i_j_lb_{i}_{j}")
model.addConstr(min_x_i_j >= coord_x[j] + l[j] - (1 - stack[i, j]) * delta, name=f"min_x_i_j_lb_{i}_{j}_2")
model.addConstr(max_x_i_j >= coord_x[i], name=f"max_x_i_j_lb_{i}_{j}")
model.addConstr(max_x_i_j >= coord_x[j], name=f"max_x_i_j_lb_{i}_{j}_2")
model.addConstr(max_x_i_j <= coord_x[i] + l[i] + (1 - stack[i, j]) * delta, name=f"max_x_i_j_ub_{i}_{j}")
model.addConstr(max_x_i_j <= coord_x[j] + l[j] + (1 - stack[i, j]) * delta, name=f"max_x_i_j_ub_{i}_{j}_2")
model.addConstr(L_ij[i, j] == min_x_i_j - max_x_i_j, name=f"L_ij_def_{i}_{j}")
# Restrições para mínimo e máximo de y
model.addConstr(min_y_i_j <= coord_y[i] + w[i], name=f"min_y_i_j_ub_{i}_{j}")
model.addConstr(min_y_i_j <= coord_y[j] + w[j], name=f"min_y_i_j_ub_{i}_{j}_2")
model.addConstr(min_y_i_j >= coord_y[i] + w[i] - (1 - stack[i, j]) * delta, name=f"min_y_i_j_lb_{i}_{j}")
model.addConstr(min_y_i_j >= coord_y[j] + w[j] - (1 - stack[i, j]) * delta, name=f"min_y_i_j_lb_{i}_{j}_2")
model.addConstr(max_y_i_j >= coord_y[i], name=f"max_y_i_j_lb_{i}_{j}")
model.addConstr(max_y_i_j >= coord_y[j], name=f"max_y_i_j_lb_{i}_{j}_2")
model.addConstr(max_y_i_j <= coord_y[i] + w[i] + (1 - stack[i, j]) * delta, name=f"max_y_i_j_ub_{i}_{j}")
model.addConstr(max_y_i_j <= coord_y[j] + w[j] + (1 - stack[i, j]) * delta, name=f"max_y_i_j_ub_{i}_{j}_2")
model.addConstr(W_ij[i, j] == min_y_i_j - max_y_i_j, name=f"W_ij_def_{i}_{j}")
-
正式なコメント
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. -
Let me correct the notation:
coord_z[j] E Zj/{0}0 -
Can you please be more precise about what you want to do, what you tried, and what unexpected result you get?
The code is not reproducible, and it is not clear how the code relates to your question.0 -
Hi Marika,
I'm sorry for not explaining in more detail earlier.
I'm trying to model a bin packing problem with 3D dimensions. In these constraints, I want to establish that only for items of type
jwhere the variablecoord_z[j] != 0, these constraints should be applied. Gurobi did not allow me to useif coord_z[j] != 0. My question is whether there is another alternative to apply this condition in a way that the solver accepts.GurobiError: Inequality constraints not supported0 -
Hi Camyla,
If coord_z is a binary variable, this can be done using Indicator constraints.
For the case that coord_z is integer (or continuous), please have a look at How do I model conditional statements in Gurobi?I hope this helps,
Marika0
投稿コメントは受け付けていません。
コメント
5件のコメント