Skip to content

Commit

Permalink
Fix one-sided bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Oct 25, 2023
1 parent 12be227 commit e79694d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Test/test_linear.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2813,6 +2813,7 @@ function test_linear_SOS1_integration(
@requires MOI.supports_constraint(model, MOI.VectorOfVariables, MOI.SOS1{T})
@requires MOI.supports_constraint(model, MOI.VariableIndex, MOI.LessThan{T})
v = MOI.add_variables(model, 3)
MOI.add_constraint.(model, v, MOI.GreaterThan(zero(T)))
@test MOI.get(model, MOI.NumberOfVariables()) == 3
vc1 = MOI.add_constraint(model, v[1], MOI.LessThan(T(1)))
@test vc1.value == v[1].value
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function get_bounds(
if MOI.is_valid(model, ci)
l, u = max(l, zero(T)), min(u, one(T))
end
if (l, u) == (typemin(T), typemax(T))
if l == typemin(T) || u == typemax(T)
return nothing
end
bounds_cache[x] = (l, u)
Expand Down
4 changes: 4 additions & 0 deletions test/Utilities/variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ function test_get_bounds_scalar_affine()
@test MOI.Utilities.get_bounds(model, cache, 1.5 * x + z) == (1.5, 4.0)
@test MOI.Utilities.get_bounds(model, cache, -1.0 * y) == nothing
@test MOI.Utilities.get_bounds(model, cache, 1.0 * x + y) == nothing
MOI.add_constraint(model, y, MOI.GreaterThan(2.0))
@test MOI.Utilities.get_bounds(model, cache, y) == nothing
MOI.add_constraint(model, y, MOI.LessThan(3.0))
@test MOI.Utilities.get_bounds(model, cache, y) == (2.0, 3.0)
return
end

Expand Down

0 comments on commit e79694d

Please sign in to comment.