Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Nov 1, 2024
1 parent ab80046 commit 636191e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2004,6 +2004,7 @@ function _moi_add_variable(
index = _moi_add_constrained_variable(moi_backend, index, set_ub)
end
if info.has_fix
@show info
set_eq = MOI.EqualTo{T}(_to_value(T, info.fixed_value, "fixed value"))
index = _moi_add_constrained_variable(moi_backend, index, set_eq)
end
Expand Down
18 changes: 18 additions & 0 deletions test/test_variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1662,4 +1662,22 @@ function test_value_number()
return
end

function test_add_constrained_variable()
model = Model()
@variable(model, x1 >= 0)
@test has_lower_bound(x1)
@variable(model, x2 <= 0)
@test has_upper_bound(x2)
@variable(model, x3 == 0)
@test is_fixed(x3)
@variable(model, x4, Int)
@test is_integer(x4)
@variable(model, x5, Bin)
@test is_binary(x5)
@variable(model, x6 >= 0, Int)
@test has_lower_bound(x6)
@test is_integer(x6)
return
end

end # module TestVariable

0 comments on commit 636191e

Please sign in to comment.