From c4d4ac88f3d9b62629e4cade0ba1bba955bdc879 Mon Sep 17 00:00:00 2001 From: odow Date: Mon, 4 Nov 2024 10:26:20 +1300 Subject: [PATCH 1/4] Use add_constrained_variable with two sets when adding bounded variables --- Project.toml | 2 +- src/variables.jl | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index ec52f38bbe9..e9c26a2ebea 100644 --- a/Project.toml +++ b/Project.toml @@ -23,7 +23,7 @@ JuMPDimensionalDataExt = "DimensionalData" DimensionalData = "0.24, 0.25, 0.26.2, 0.27, 0.28" LinearAlgebra = "<0.0.1, 1.6" MacroTools = "0.5" -MathOptInterface = "1.25.2" +MathOptInterface = "1.34.0" MutableArithmetics = "1.1" OrderedCollections = "1" Printf = "<0.0.1, 1.6" diff --git a/src/variables.jl b/src/variables.jl index 9fd501b90ae..c32648dcf35 100644 --- a/src/variables.jl +++ b/src/variables.jl @@ -1981,6 +1981,15 @@ function _moi_add_constrained_variable( return x end +function _moi_add_constrained_variable( + moi_backend::MOI.ModelLike, + ::Nothing, + set::Tuple{MOI.GreaterThan{T},MOI.LessThan{T}} +) where {T} + x, _ = MOI.add_constrained_variable(moi_backend, set) + return x +end + function _moi_add_variable( moi_backend, model::GenericModel{T}, @@ -1992,12 +2001,17 @@ function _moi_add_variable( # variables. index = nothing info = v.info - if info.has_lb + if info.has_lb && info.has_ub + set = ( + MOI.GreaterThan{T}(_to_value(T, info.lower_bound, "lower bound")), + MOI.LessThan{T}(_to_value(T, info.upper_bound, "upper bound")), + ) + index = _moi_add_constrained_variable(moi_backend, index, set) + elseif info.has_lb set_lb = MOI.GreaterThan{T}(_to_value(T, info.lower_bound, "lower bound")) index = _moi_add_constrained_variable(moi_backend, index, set_lb) - end - if info.has_ub + elseif info.has_ub set_ub = MOI.LessThan{T}(_to_value(T, info.upper_bound, "upper bound")) index = _moi_add_constrained_variable(moi_backend, index, set_ub) end From 74d86b4ae5879f4886c97e61d128b23625b2f3e0 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 7 Nov 2024 11:20:30 +1300 Subject: [PATCH 2/4] Update src/variables.jl --- src/variables.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/variables.jl b/src/variables.jl index c32648dcf35..0d4a3546481 100644 --- a/src/variables.jl +++ b/src/variables.jl @@ -1985,7 +1985,7 @@ function _moi_add_constrained_variable( moi_backend::MOI.ModelLike, ::Nothing, set::Tuple{MOI.GreaterThan{T},MOI.LessThan{T}} -) where {T} +) where {T<:Real} x, _ = MOI.add_constrained_variable(moi_backend, set) return x end From 1bd54e49cca29e1c90e0242ed987c88b75b076a3 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 7 Nov 2024 11:24:01 +1300 Subject: [PATCH 3/4] Update src/variables.jl --- src/variables.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/variables.jl b/src/variables.jl index 0d4a3546481..89959157adb 100644 --- a/src/variables.jl +++ b/src/variables.jl @@ -1984,7 +1984,7 @@ end function _moi_add_constrained_variable( moi_backend::MOI.ModelLike, ::Nothing, - set::Tuple{MOI.GreaterThan{T},MOI.LessThan{T}} + set::Tuple{MOI.GreaterThan{T},MOI.LessThan{T}}, ) where {T<:Real} x, _ = MOI.add_constrained_variable(moi_backend, set) return x From e9a6ffc204e4387d728293c7bbcb00be4a6d3d9e Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 7 Nov 2024 11:26:41 +1300 Subject: [PATCH 4/4] Update Project.toml --- docs/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Project.toml b/docs/Project.toml index 1d750157221..0de6cf6f551 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -61,7 +61,7 @@ JSON = "0.21" JSONSchema = "1" Literate = "2.8" MarkdownAST = "0.1" -MathOptInterface = "=1.32.0" +MathOptInterface = "=1.34.0" MultiObjectiveAlgorithms = "=1.3.3" PATHSolver = "=1.7.8" ParametricOptInterface = "0.8.1"