From 544073f701aa05753d0b480793592ca267e72d18 Mon Sep 17 00:00:00 2001 From: odow Date: Wed, 20 Sep 2023 10:54:12 +1200 Subject: [PATCH] [Bridges] fix ConstraintDualStart for Constraint.SplitIntervalBridge --- src/Bridges/Constraint/bridges/interval.jl | 6 ++--- test/Bridges/Constraint/interval.jl | 28 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/Bridges/Constraint/bridges/interval.jl b/src/Bridges/Constraint/bridges/interval.jl index f2e871bbbe..f9f35224a4 100644 --- a/src/Bridges/Constraint/bridges/interval.jl +++ b/src/Bridges/Constraint/bridges/interval.jl @@ -287,12 +287,12 @@ function _split_dual_start(value) end end -function _split_dual_start(value::Vector) - lower = similar(value) - upper = similar(value) +function _split_dual_start(value::Vector{T}) where {T} + lower, upper = similar(value), similar(value) for i in eachindex(value) lower[i], upper[i] = _split_dual_start(value[i]) end + return lower, upper end function MOI.set( diff --git a/test/Bridges/Constraint/interval.jl b/test/Bridges/Constraint/interval.jl index a654c380b4..79009370e5 100644 --- a/test/Bridges/Constraint/interval.jl +++ b/test/Bridges/Constraint/interval.jl @@ -471,6 +471,34 @@ function test_runtests() return end +function test_runtests_vector() + MOI.Bridges.runtests( + MOI.Bridges.Constraint.SplitIntervalBridge, + """ + variables: x + [x] in Zeros(1) + """, + """ + variables: x + [x] in Nonnegatives(1) + [x] in Nonpositives(1) + """, + ) + MOI.Bridges.runtests( + MOI.Bridges.Constraint.SplitIntervalBridge, + """ + variables: x, y + [1.0 * x + 2.0, x + y] in Zeros(2) + """, + """ + variables: x, y + [1.0 * x + 2.0, x + y] in Nonnegatives(2) + [1.0 * x + 2.0, x + y] in Nonpositives(2) + """, + ) + return +end + end # module TestConstraintSplitInterval.runtests()