Skip to content

Commit 6e987a5

Browse files
committed
[FileFormats.LP] fix reading variable with negative upper bound
1 parent 692f8f2 commit 6e987a5

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

src/FileFormats/LP/read.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -981,9 +981,6 @@ function _add_bound(
981981
end
982982

983983
function _add_bound(cache::_ReadCache, x::MOI.VariableIndex, set::MOI.LessThan)
984-
if set.upper < 0
985-
delete!(cache.variable_with_default_bound, x)
986-
end
987984
if isfinite(set.upper)
988985
MOI.add_constraint(cache.model, x, set)
989986
end

test/FileFormats/LP/test_LP.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ function test_read_model2()
626626
ci = MOI.ConstraintIndex{MOI.VariableIndex,MOI.Interval{Float64}}(2)
627627
@test !MOI.is_valid(model, ci)
628628
@test MOI.get(model, MOI.VariableName(), MOI.VariableIndex(8)) == "V8"
629-
@test model.variables.lower[8] == -Inf
629+
@test model.variables.lower[8] == 0.0
630630
@test model.variables.upper[8] == -3
631631
obj_type = MOI.get(model, MOI.ObjectiveFunctionType())
632632
obj_func = MOI.get(model, MOI.ObjectiveFunction{obj_type}())
@@ -895,17 +895,17 @@ function test_reading_bounds()
895895
# Test upper bound
896896
_test_round_trip("x <= 1", "Bounds\n0 <= x <= 1\nEnd")
897897
_test_round_trip("x <= 0", "Bounds\nx = 0\nEnd")
898-
_test_round_trip("x <= -1", "Bounds\n-infinity <= x <= -1\nEnd")
898+
_test_round_trip("x <= -1", "Bounds\n0 <= x <= -1\nEnd")
899899
_test_round_trip("x < 1", "Bounds\n0 <= x <= 1\nEnd")
900900
_test_round_trip("x < 0", "Bounds\nx = 0\nEnd")
901-
_test_round_trip("x < -1", "Bounds\n-infinity <= x <= -1\nEnd")
901+
_test_round_trip("x < -1", "Bounds\n0 <= x <= -1\nEnd")
902902
# Test reversed upper bound
903903
_test_round_trip("1 >= x", "Bounds\n0 <= x <= 1\nEnd")
904904
_test_round_trip("0 >= x", "Bounds\nx = 0\nEnd")
905-
_test_round_trip("-1 >= x", "Bounds\n-infinity <= x <= -1\nEnd")
905+
_test_round_trip("-1 >= x", "Bounds\n0 <= x <= -1\nEnd")
906906
_test_round_trip("1 > x", "Bounds\n0 <= x <= 1\nEnd")
907907
_test_round_trip("0 > x", "Bounds\nx = 0\nEnd")
908-
_test_round_trip("-1 > x", "Bounds\n-infinity <= x <= -1\nEnd")
908+
_test_round_trip("-1 > x", "Bounds\n0 <= x <= -1\nEnd")
909909
# Test equality
910910
_test_round_trip("x == 1", "Bounds\nx = 1\nEnd")
911911
_test_round_trip("x == 0", "Bounds\nx = 0\nEnd")

0 commit comments

Comments
 (0)