# Unable to fix a JuMP variable, when it hasn't been fixed

**URL:** <https://discourse.julialang.org/t/unable-to-fix-a-jump-variable-when-it-hasnt-been-fixed/71477>\
**Category:** Optimization (Mathematical)\
**Tags:** question, jump\
**Created:** [November 15, 2021, 3:45am UTC](https://discourse.julialang.org/t/unable-to-fix-a-jump-variable-when-it-hasnt-been-fixed/71477 "2021-11-15T03:45:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chkwon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chkwon/32/3632_2.png) [@chkwon](https://discourse.julialang.org/u/chkwon)\
**Post date:** [November 15, 2021, 3:45am UTC](https://discourse.julialang.org/t/unable-to-fix-a-jump-variable-when-it-hasnt-been-fixed/71477/1 "2021-11-15T03:45:12Z")

</div>

```julia
using JuMP
m = Model()
@variable(m, z >= 0)
@objective(m, Min, z)
@show is_fixed(z)
fix(z, 1)

```

The above code generates:

```julia
is_fixed(z) = false
ERROR: LoadError: Unable to fix z to 1 because it has existing variable bounds. Consider calling `JuMP.fix(variable, value; force=true)` which will delete existing bounds before fixing the variable.

```

Is this normal? I am on JuMP v0.22.0.

FYI, when the variable is unrestricted, it works fine.

```julia
m = Model()
@variable(m, z)
@objective(m, Min, z)
@show is_fixed(z) # false
fix(z, 1)
@show is_fixed(z) # true

```

---

<div class="post-metadata">

**Author:** ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Post date:** [November 15, 2021, 4:34am UTC](https://discourse.julialang.org/t/unable-to-fix-a-jump-variable-when-it-hasnt-been-fixed/71477/2 "2021-11-15T04:34:33Z")

</div>

This is normal behaviour; see  
[https://jump.dev/JuMP.jl/stable/manual/variables/#Create-a-fixed-variable](https://jump.dev/JuMP.jl/stable/manual/variables/#Create-a-fixed-variable)
