I am using Julia/JuMP to write an algorithm. I have previously defined an MILP, but now I want to relax some of the integer restrictions. How can I do this?
Here is my sample code:
using JuMP
using Gurobi
model = Model(Gurobi.Optimizer)
@variable(model, 0 <= x[i=1:2], Int)
@constraint(model, x[1] + x[2] >= 0.5)
@objective(model, Min, 3*x[1] + x[2])
# *Here I want to relax the integer restriction on x[2]*
optimize!(model)
println(value.(x))
I have found an old post with the same question (How to convert type of a variable when using JuMP), but the solution (using the function setcategory()
) does not seem to work in the current version of JuMP.
You're looking for unset_integer
:
https://jump.dev/JuMP.jl/stable/variables/#Integer-constraints-1
There is also relax_integrality
https://jump.dev/JuMP.jl/stable/variables/#JuMP.relax_integrality