linopy.variables.Variable.fix#
- Variable.fix(value=None, decimals=8, overwrite=True)#
Fix the variable to a given value by collapsing its bounds.
Sets
lower = upper = value.If no value is given, the current solution value is used.
A fix value outside the variable’s current bounds emits a warning, but does not cause infeasibilities (the bounds are overridden). Fixing a binary variable to anything other than 0 or 1 raises.
- Parameters:
value (
float/array_like, optional) – Value to fix the variable to. If None, the current solution is used.decimals (
int, optional) – Number of decimal places to round continuous variables to. Integer and binary variables are always rounded to 0 decimal places. Default is 8.overwrite (
bool, optional) – If True (default), re-fix a variable that is already fixed to the new value (the originally stashed bounds are kept). If False, raise an error if the variable is already fixed.