Skip to content

Commit 64b3900

Browse files
authored
Fix variable bounds passed as Rational{Int}(Inf) (#2896)
1 parent 88e9248 commit 64b3900

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/variables.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ struct VariableInfo{S,T,U,V}
138138
if has_fix && !_isfinite(fixed_value)
139139
error("Unable to fix variable to $(fixed_value)")
140140
end
141-
return new{S,T,U,V}(
141+
return new{typeof(lower_bound),typeof(upper_bound),U,V}(
142142
has_lb,
143143
lower_bound,
144144
has_ub,

test/variable.jl

+9
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,15 @@ function test_Model_error_messages(::Any, ::Any)
10251025
return
10261026
end
10271027

1028+
function test_rational_inf_bounds(ModelType, ::Any)
1029+
model = ModelType()
1030+
u = Rational{Int}(Inf)
1031+
@variable(model, -u <= x <= u)
1032+
@test has_lower_bound(x) == false
1033+
@test has_upper_bound(x) == false
1034+
return
1035+
end
1036+
10281037
function runtests()
10291038
for name in names(@__MODULE__; all = true)
10301039
if !startswith("$(name)", "test_")

0 commit comments

Comments
 (0)