From ebef8fc7afae5b8d84c073531280b6dfc4677f37 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 23 Apr 2026 10:17:29 +1200 Subject: [PATCH] [FileFormats.LP] fix reading variable with negative upper bound --- src/FileFormats/LP/read.jl | 3 --- test/FileFormats/LP/test_LP.jl | 10 +++++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/FileFormats/LP/read.jl b/src/FileFormats/LP/read.jl index 2aac656a7c..41fbd70ff1 100644 --- a/src/FileFormats/LP/read.jl +++ b/src/FileFormats/LP/read.jl @@ -981,9 +981,6 @@ function _add_bound( end function _add_bound(cache::_ReadCache, x::MOI.VariableIndex, set::MOI.LessThan) - if set.upper < 0 - delete!(cache.variable_with_default_bound, x) - end if isfinite(set.upper) MOI.add_constraint(cache.model, x, set) end diff --git a/test/FileFormats/LP/test_LP.jl b/test/FileFormats/LP/test_LP.jl index fcef626ffc..bb5b4659ff 100644 --- a/test/FileFormats/LP/test_LP.jl +++ b/test/FileFormats/LP/test_LP.jl @@ -626,7 +626,7 @@ function test_read_model2() ci = MOI.ConstraintIndex{MOI.VariableIndex,MOI.Interval{Float64}}(2) @test !MOI.is_valid(model, ci) @test MOI.get(model, MOI.VariableName(), MOI.VariableIndex(8)) == "V8" - @test model.variables.lower[8] == -Inf + @test model.variables.lower[8] == 0.0 @test model.variables.upper[8] == -3 obj_type = MOI.get(model, MOI.ObjectiveFunctionType()) obj_func = MOI.get(model, MOI.ObjectiveFunction{obj_type}()) @@ -895,17 +895,17 @@ function test_reading_bounds() # Test upper bound _test_round_trip("x <= 1", "Bounds\n0 <= x <= 1\nEnd") _test_round_trip("x <= 0", "Bounds\nx = 0\nEnd") - _test_round_trip("x <= -1", "Bounds\n-infinity <= x <= -1\nEnd") + _test_round_trip("x <= -1", "Bounds\n0 <= x <= -1\nEnd") _test_round_trip("x < 1", "Bounds\n0 <= x <= 1\nEnd") _test_round_trip("x < 0", "Bounds\nx = 0\nEnd") - _test_round_trip("x < -1", "Bounds\n-infinity <= x <= -1\nEnd") + _test_round_trip("x < -1", "Bounds\n0 <= x <= -1\nEnd") # Test reversed upper bound _test_round_trip("1 >= x", "Bounds\n0 <= x <= 1\nEnd") _test_round_trip("0 >= x", "Bounds\nx = 0\nEnd") - _test_round_trip("-1 >= x", "Bounds\n-infinity <= x <= -1\nEnd") + _test_round_trip("-1 >= x", "Bounds\n0 <= x <= -1\nEnd") _test_round_trip("1 > x", "Bounds\n0 <= x <= 1\nEnd") _test_round_trip("0 > x", "Bounds\nx = 0\nEnd") - _test_round_trip("-1 > x", "Bounds\n-infinity <= x <= -1\nEnd") + _test_round_trip("-1 > x", "Bounds\n0 <= x <= -1\nEnd") # Test equality _test_round_trip("x == 1", "Bounds\nx = 1\nEnd") _test_round_trip("x == 0", "Bounds\nx = 0\nEnd")