@@ -29,6 +29,7 @@ const CI{F, S} = MOI.ConstraintIndex{F, S}
2929mutable struct SOItoMOIBridge{T, SIT <: AbstractSDOptimizer } <: MOI.AbstractOptimizer
3030 sdoptimizer:: SIT
3131 setconstant:: Dict{Int64, T}
32+ blkconstant:: Dict{Int, T}
3233 objconstant:: T
3334 objsign:: Int
3435 objshift:: T
@@ -42,7 +43,7 @@ mutable struct SOItoMOIBridge{T, SIT <: AbstractSDOptimizer} <: MOI.AbstractOpti
4243 slackmap:: Vector{Tuple{Int, Int, Int, T}} # c -> blk, i, j, coef
4344 double:: Vector{CI} # created when there are two cones for same variable
4445 function SOItoMOIBridge {T} (sdoptimizer:: SIT ) where {T, SIT}
45- new {T, SIT} (sdoptimizer, Dict {Int64, T} (),
46+ new {T, SIT} (sdoptimizer, Dict {Int64, T} (), Dict {Int, T} (),
4647 zero (T), 1 , zero (T), 0 , 0 ,
4748 Int[],
4849 IntSet (),
@@ -70,6 +71,7 @@ include("load.jl")
7071function MOI. isempty (optimizer:: SOItoMOIBridge )
7172 isempty (optimizer. double) &&
7273 isempty (optimizer. setconstant) &&
74+ isempty (optimizer. blkconstant) &&
7375 iszero (optimizer. objconstant) &&
7476 optimizer. objsign == 1 &&
7577 iszero (optimizer. objshift) &&
@@ -88,6 +90,7 @@ function MOI.empty!(optimizer::SOItoMOIBridge{T}) where T
8890 end
8991 optimizer. double = CI[]
9092 optimizer. setconstant = Dict {Int64, T} ()
93+ optimizer. blkconstant = Dict {Int, T} ()
9194 optimizer. objconstant = zero (T)
9295 optimizer. objsign = 1
9396 optimizer. objshift = zero (T)
@@ -105,14 +108,22 @@ function setconstant!(optimizer::SOItoMOIBridge, ci::CI, s) end
105108function setconstant! (optimizer:: SOItoMOIBridge , ci:: CI , s:: MOI.AbstractScalarSet )
106109 optimizer. setconstant[ci. value] = MOIU. getconstant (s)
107110end
108- function addconstant (optimizer:: SOItoMOIBridge , ci:: CI{<:Any, <:MOI.AbstractScalarSet} , x)
111+ function addsetconstant (optimizer:: SOItoMOIBridge , ci:: CI{<:Any, <:MOI.AbstractScalarSet} , x)
109112 x + optimizer. setconstant[ci. value]
110113end
111- function addconstant (optimizer:: SOItoMOIBridge , ci:: CI , x)
114+ function addsetconstant (optimizer:: SOItoMOIBridge , ci:: CI , x)
112115 x
113116end
117+ function addblkconstant (optimizer:: SOItoMOIBridge , ci:: CI{<:Any, <:Union{NS, PS}} , x)
118+ blk = - ci. value
119+ x + optimizer. blkconstant[blk]
120+ end
121+ function addblkconstant (optimizer:: SOItoMOIBridge , ci:: CI , x)
122+ x
123+ end
124+
114125
115- MOI. supports (:: SOItoMOIBridge{T} , :: MOI.ObjectiveFunction{MOI.ScalarAffineFunction{T}} ) where T = true
126+ MOI. supports (:: SOItoMOIBridge{T} , :: MOI.ObjectiveFunction{<:Union{ MOI.SingleVariable, MOI. ScalarAffineFunction{T} }} ) where T = true
116127MOI. supportsconstraint (:: SOItoMOIBridge{T} , :: Type{<:Union{VF, AF{T}}} , :: Type{<:SupportedSets} ) where T = true
117128MOI. copy! (dest:: SOItoMOIBridge , src:: MOI.ModelLike ; copynames= true ) = MOIU. allocateload! (dest, src, copynames)
118129
@@ -216,11 +227,11 @@ end
216227
217228function MOI. get (m:: SOItoMOIBridge , a:: MOI.ConstraintPrimal , ci:: CI{F, S} ) where {F, S}
218229 if ci. value >= 0
219- addconstant (m, ci, _getattribute (m, ci, getslack))
230+ addsetconstant (m, ci, _getattribute (m, ci, getslack))
220231 else
221232 # Variable Function-in-S with S different from Zeros and EqualTo and not a double variable constraint
222233 blk = - ci. value
223- getvarprimal (m, blk, S)
234+ addblkconstant (m, ci, getvarprimal (m, blk, S) )
224235 end
225236end
226237
0 commit comments