From 3ac5966d621bca5f2869e9d09e4f0cfb0dcf20bb Mon Sep 17 00:00:00 2001 From: odow Date: Thu, 2 Nov 2023 14:15:30 +1300 Subject: [PATCH 1/5] [Bridges] add support for start values in NumberConversionBridge --- .../Constraint/bridges/number_conversion.jl | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/Bridges/Constraint/bridges/number_conversion.jl b/src/Bridges/Constraint/bridges/number_conversion.jl index fd10db2c79..1aca2ae202 100644 --- a/src/Bridges/Constraint/bridges/number_conversion.jl +++ b/src/Bridges/Constraint/bridges/number_conversion.jl @@ -120,3 +120,39 @@ function MOI.get( s = MOI.get(model, MOI.ConstraintSet(), bridge.constraint) return MOI.Utilities.convert_approx(S1, s) end + +function MOI.supports( + model::MOI.ModelLike, + attr::Union{MOI.ConstraintPrimalStart,MOI.ConstraintDualStart}, + ::Type{NumberConversionBridge{T,F1,S1,F2,S2}}, +) where {T,F1,S1,F2,S2} + return MOI.supports(model, attr, MOI.ConstraintIndex{F2,S2}) +end + +function MOI.get( + model::MOI.ModelLike, + attr::Union{ + MOI.ConstraintPrimalStart, + MOI.ConstraintDualStart, + MOI.ConstraintPrimal, + MOI.ConstraintDual, + }, + bridge::NumberConversionBridge{T,F1,S1,F2,S2}, +) where {T,F1,S1,F2,S2} + return MOI.get(model, attr, bridge.constraint) +end + +function MOI.set( + model::MOI.ModelLike, + attr::Union{ + MOI.ConstraintPrimalStart, + MOI.ConstraintDualStart, + MOI.ConstraintPrimal, + MOI.ConstraintDual, + }, + bridge::NumberConversionBridge{T,F1,S1,F2,S2}, + value, +) where {T,F1,S1,F2,S2} + MOI.set(model, attr, bridge.constraint, value) + return +end From 9dfc30acc14cb074e541bd931c4912e382f59073 Mon Sep 17 00:00:00 2001 From: odow Date: Thu, 2 Nov 2023 14:18:15 +1300 Subject: [PATCH 2/5] Use value_type --- src/Bridges/Constraint/bridges/number_conversion.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Bridges/Constraint/bridges/number_conversion.jl b/src/Bridges/Constraint/bridges/number_conversion.jl index 1aca2ae202..db18bd6c2a 100644 --- a/src/Bridges/Constraint/bridges/number_conversion.jl +++ b/src/Bridges/Constraint/bridges/number_conversion.jl @@ -139,7 +139,11 @@ function MOI.get( }, bridge::NumberConversionBridge{T,F1,S1,F2,S2}, ) where {T,F1,S1,F2,S2} - return MOI.get(model, attr, bridge.constraint) + ret = MOI.get(model, attr, bridge.constraint) + if ret === nothing + return nothing + end + return convert(MOI.Utilities.value_type(T,F1), ret) end function MOI.set( From 448210f1a5440131bf49eb176883d7b871dc0558 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 2 Nov 2023 15:11:14 +1300 Subject: [PATCH 3/5] Update src/Bridges/Constraint/bridges/number_conversion.jl --- src/Bridges/Constraint/bridges/number_conversion.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bridges/Constraint/bridges/number_conversion.jl b/src/Bridges/Constraint/bridges/number_conversion.jl index db18bd6c2a..ca1f24fb47 100644 --- a/src/Bridges/Constraint/bridges/number_conversion.jl +++ b/src/Bridges/Constraint/bridges/number_conversion.jl @@ -143,7 +143,7 @@ function MOI.get( if ret === nothing return nothing end - return convert(MOI.Utilities.value_type(T,F1), ret) + return convert(MOI.Utilities.value_type(T, F1), ret) end function MOI.set( From 3542c0226dbc055d9689f0e62a21d9c11ef8b771 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Fri, 3 Nov 2023 08:16:31 +1300 Subject: [PATCH 4/5] Update number_conversion.jl --- src/Bridges/Constraint/bridges/number_conversion.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bridges/Constraint/bridges/number_conversion.jl b/src/Bridges/Constraint/bridges/number_conversion.jl index ca1f24fb47..194bb1f6da 100644 --- a/src/Bridges/Constraint/bridges/number_conversion.jl +++ b/src/Bridges/Constraint/bridges/number_conversion.jl @@ -124,9 +124,9 @@ end function MOI.supports( model::MOI.ModelLike, attr::Union{MOI.ConstraintPrimalStart,MOI.ConstraintDualStart}, - ::Type{NumberConversionBridge{T,F1,S1,F2,S2}}, -) where {T,F1,S1,F2,S2} - return MOI.supports(model, attr, MOI.ConstraintIndex{F2,S2}) + ::Type{<:NumberConversionBridge}, +) + return true end function MOI.get( From b3629195b9f3a61f9e063bdd3649d33ca77de428 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Fri, 3 Nov 2023 10:19:49 +1300 Subject: [PATCH 5/5] Update number_conversion.jl --- src/Bridges/Constraint/bridges/number_conversion.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bridges/Constraint/bridges/number_conversion.jl b/src/Bridges/Constraint/bridges/number_conversion.jl index 194bb1f6da..ca1f24fb47 100644 --- a/src/Bridges/Constraint/bridges/number_conversion.jl +++ b/src/Bridges/Constraint/bridges/number_conversion.jl @@ -124,9 +124,9 @@ end function MOI.supports( model::MOI.ModelLike, attr::Union{MOI.ConstraintPrimalStart,MOI.ConstraintDualStart}, - ::Type{<:NumberConversionBridge}, -) - return true + ::Type{NumberConversionBridge{T,F1,S1,F2,S2}}, +) where {T,F1,S1,F2,S2} + return MOI.supports(model, attr, MOI.ConstraintIndex{F2,S2}) end function MOI.get(