@@ -676,14 +676,18 @@ end
676676
677677function MOI. add_constraint (model:: Optimizer , x:: MOI.VariableIndex , :: MOI.ZeroOne )
678678 MOI. throw_if_not_valid (model, x)
679- lb, ub = nothing , nothing
679+ fx, lb, ub = nothing , nothing , nothing
680680 p = Ref {Cdouble} (NaN )
681681 info = model. variable_info[x. value]
682- if info. has_lower_bound || info. is_fixed
682+ if info. is_fixed
683+ KNITRO. @_checked KNITRO. KN_get_var_fxbnd (model. inner, _c_column (x), p)
684+ fx = p[]
685+ end
686+ if info. has_lower_bound
683687 KNITRO. @_checked KNITRO. KN_get_var_lobnd (model. inner, _c_column (x), p)
684688 lb = max (0.0 , p[])
685689 end
686- if info. has_upper_bound || info . is_fixed
690+ if info. has_upper_bound
687691 KNITRO. @_checked KNITRO. KN_get_var_upbnd (model. inner, _c_column (x), p)
688692 ub = min (1.0 , p[])
689693 end
@@ -694,6 +698,9 @@ function MOI.add_constraint(model::Optimizer, x::MOI.VariableIndex, ::MOI.ZeroOn
694698 )
695699 # Calling `set_var_type` resets variable bounds in KNITRO. To fix, we need
696700 # to restore them after calling `set_var_type`.
701+ if fx != = nothing
702+ KNITRO. @_checked KNITRO. KN_set_var_fxbnd (model. inner, _c_column (x), fx)
703+ end
697704 if lb != = nothing
698705 KNITRO. @_checked KNITRO. KN_set_var_lobnd (model. inner, _c_column (x), lb)
699706 end
0 commit comments