How to lock variables
Awaiting user inputHi all,
for an algorithm I need to fixate a few variables.
For instance, x_ij should be fixated to x_34 and then afterwards the problem will be solved with the gurobi solver.
How do I do that?
-
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 try Gurobot, our chatbot interface offering instant, expert-level support. -
Hi Timur,
what do you exactly mean by "fixate"? Do you need to assign a constant value to this variable? Or perhaps you want to keep only \(x_{3,4}\) out of all \(x_{i, j} \) for some \(i \in I, j \in J \) and remove the others?
Please let us know - we will then gladly help you further.
Best regards
Jonasz0 -
Hi Jonasz,
lets assume x_ij is a binary variable.
I want to keep only x_34 = 1 out of all x_ij for all i and j.
Best regards,
Timur
0 -
I would then either add a constraint or modify the bounds of the respective variable:
model.addLConstr(x[3,4] == 1)
# or alternatively
x[3,4].LB = 1
x[3,4].UB = 1Do you even need the variables pertaining to \( x_{i,j} \) s.t. \( i \neq 3, j \neq 4\) in such a situation? If not, I would abstain from generating them in the first place.
Best regards
Jonasz0
Post is closed for comments.
Comments
4 comments