Jump.jl: Can't fix variable when bounds are defined.

Created on 18 Nov 2018  路  5Comments  路  Source: jump-dev/JuMP.jl

If a group of variables has been defined within certain bounds, then it is not possible to fix the value of one of them. In many applications, it is valuable to create a group of variables over a set and then be able to fix only of them.

This code will reproduce the error on Master

m = Model() 
@variable(m, 0.0 <= x[1:2] <= 10.0)
JuMP.fix(x[1],0.0) 


AssertionError: !(has_upper_bound(v)) && !(has_lower_bound(v))

Stacktrace:
 [1] fix(::VariableRef, ::Float64) at /Users/jdlara/.julia/packages/JuMP/aU7VH/src/variables.jl:407
 [2] top-level scope at In[50]:3

All 5 comments

What would you expect to happen if you called JuMP.unfix(x[1])? Should it revert to it's bounds?

I haven't thought about the reverse operation; it seems that reverting to the original bounds would be a nice thing but is cumbersome if it requires to keep in memory what the original binding was.

In my opinion, If a user needs to unfree the variable, then it can easily redefine the bounds and having the variable be free is enough

Maybe we want a JuMP.force_fix to remove bounds (if any) and then fix?

And of course a better error message for JuMP.fix when bounds are present.

JuMP.fix(x, 1; force = true)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mlubin picture mlubin  路  8Comments

Thuener picture Thuener  路  7Comments

dourouc05 picture dourouc05  路  7Comments

chriscoey picture chriscoey  路  3Comments

mlubin picture mlubin  路  9Comments