Recommended method for fixing variables
回答済みHello,
When performing mathematical optimization, there are times when I want to fix certain variables to specific values. For example, I want to fix X to 1. There are three possible approaches to achieve this:
1. Rewrite the variable as a constant and remove the variable itself.
2. Fix the variable’s LB and UB attributes to the specific value. (1<=X<=1)
3. Add a constraint to equate the variable to the desired value.(X=1)
The Gurobi guidelines mention method 2.
I’d like to inquire whether the performance differs depending on the method used to fix variables. Intuitively, method 1, which removes the variable entirely, would result in the smallest model size. However, in other methods, does preprocessing or similar steps nullify the impact on computation?
I’m concerned that the choice of method might affect performance when fixing tens of thousands of binary variables in a large-scale model.
Thank you.
-
Hi Keita,
does preprocessing or similar steps nullify the impact on computation?
Yes, the fixed variables will be replaced faster than you can say "presolve", so please use 2) - it is nothing to worry about.
Kind Regards,
Riley1 -
Hello Riley,
Thank you for your reply.
Sorry for the detailed confirmation, but in the case of 3), will variables also be replaced before presolve? Can I assume that there is no superiority or inferiority between 2) and 3)?
0 -
Hi Keita,
Yes 3) will also be cleaned up by presolve. Any constraint with a single variable is a just a bound in disguise and presolve will adjust the bound of such a variable then remove the now-redundant constraint. If there is a difference between 2) and 3) performance wise it will be tiny but 2) is preferred as it makes your model easier to examine programmatically and visually (i.e. inspecting the LP file).
Kind Regards,
Riley2
サインインしてコメントを残してください。
コメント
3件のコメント