Is Gurobi able to handle a decision variable in the index/as a boundary in a sum?
回答済みDear all,
currently I am trying to implement and solve a model in python using gurobi. Unfortunately the model has the value from a decision variable (m_j) as a boundary in the sum and in the index. Is Gurobi able to handle this situation? If yes, how?
The problematic restrictions are constraints 13 which you can see in the following picture:
I have tried to implement constraints 13 in the following way:
model.addConstrs((l[j] == quicksum(x[i, k] for i in J for k in KAll if k <= m[j] - 1) + quicksum(x[i, k] for i in J for k in KAll if k == m[j] if i <= j) for j in J), name="(13)")
However the problem is, that the boundaries for k (k<=m[j]-1 and k == m[j]) are ignored.
I know that it is possible to reformulate the constraints with for instance quadratic constraints. However, my question is whether Gurobi is able to handle decision variables in the index or as a boundary in the sum. Is there a special trick?
Thank you in advance for you help.
-
正式なコメント
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?. -
No, this is not directly possible. In constraint programming, such a constraint is refered to as "element constraint", i.e., you have a decision variable as the index into some array.
If your m_j variables have a reasonably small domain, then you might be able to model this using auxiliary binary variables. For example, to model
y = x_m
with l <= m <= u, you could add (u-l+1) binary variables z_i and use the following constraints:
m = sum_{k=l,...,u} k*z_k
sum_{k=l,...,u} z_k = 1
y = sum_{k=l,...,u} z_k*x_kThe latter constraint is quadratic, but because the z_k variables are binary, Gurobi will translate this into linear and/or SOS constraints.
That being said, I am pretty sure that Gurobi will have a very hard time to solve models that include such a structure. But if your model is small and easy, then maybe you have a chance.
Regards,
Tobias
0
投稿コメントは受け付けていません。
コメント
2件のコメント