# Using the solver SDPT3 with PowerModels.jl

**URL:** <https://discourse.julialang.org/t/using-the-solver-sdpt3-with-powermodels-jl/68070>\
**Category:** Optimization (Mathematical)\
**Tags:** optimization\
**Created:** [September 13, 2021, 4:11am UTC](https://discourse.julialang.org/t/using-the-solver-sdpt3-with-powermodels-jl/68070 "2021-09-13T04:11:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaldik](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@aaldik](https://discourse.julialang.org/u/aaldik)\
**Post date:** [September 13, 2021, 4:11am UTC](https://discourse.julialang.org/t/using-the-solver-sdpt3-with-powermodels-jl/68070/1 "2021-09-13T04:11:14Z")

</div>

Hello

I’m trying to use the solver SDPT3 for solving a SDP problem using the library PowerModels.jl that utilizes JuMP, the error that I get is

julia\> test=run\_opf(“case3\_SDP.m”,SDPWRMPowerModel,solver4)  
┌ Warning: MathOptInterface.VariablePrimalStart() is not supported by MathOptInterface.Bridges.LazyBridgeOptimizer{SDPT3.Optimizer}. This information will be discarded.  
└ @ MathOptInterface.Utilities C:\Users\Abd-PC.julia\packages\MathOptInterface\YDdD3\src\Utilities\copy.jl:290  
ERROR: In `MathOptInterface.ScalarAffineFunction{Float64}`-in-`MathOptInterface.EqualTo{Float64}` constraint: Constant -5.6 of the function is not zero. The function constant should be moved to the set. You can use `MOI.Utilities.normalize_and_add_constraint` which does this automatically.  
Stacktrace:  
[1] add\_constraint(optimizer::SDPT3.Optimizer, func::MathOptInterface.ScalarAffineFunction{Float64}, set::MathOptInterface.EqualTo{Float64})  
@ SDPT3 C:\Users\Abd-PC.julia\packages\SDPT3\UbGG2\src\MOI\_wrapper.jl:329  
[2] \_broadcast\_getindex\_evalf  
@ .\broadcast.jl:648 [inlined]  
[3] \_broadcast\_getindex  
@ .\broadcast.jl:621 [inlined]  
[4] getindex  
@ .\broadcast.jl:575 [inlined]  
[5] macro expansion  
@ .\broadcast.jl:984 [inlined]  
[6] macro expansion  
@ .\simdloop.jl:77 [inlined]  
[7] copyto!  
@ .\broadcast.jl:983 [inlined]  
[8] copyto!  
@ .\broadcast.jl:936 [inlined]  
[9] copy  
@ .\broadcast.jl:908 [inlined]  
[10] materialize  
@ .\broadcast.jl:883 [inlined]  
[11] add\_constraints(model::SDPT3.Optimizer, funcs::Vector{MathOptInterface.ScalarAffineFunction{Float64}}, sets::Vector{MathOptInterface.EqualTo{Float64}})  
@ MathOptInterface C:\Users\Abd-PC.julia\packages\MathOptInterface\YDdD3\src\constraints.jl:229  
[12] add\_constraints(b::MathOptInterface.Bridges.LazyBridgeOptimizer{SDPT3.Optimizer}, f::Vector{MathOptInterface.ScalarAffineFunction{Float64}}, s::Vector{MathOptInterface.EqualTo{Float64}})  
@ MathOptInterface.Bridges C:\Users\Abd-PC.julia\packages\MathOptInterface\YDdD3\src\Bridges\bridge\_optimizer.jl:1510  
[13] copy\_constraints(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{SDPT3.Optimizer}, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ModelFunctionConstraints{Float64}}}, idxmap::MathOptInterface.Utilities.IndexMap, cis\_src::Vector{MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.EqualTo{Float64}}}, filter\_constraints::Nothing)  
@ MathOptInterface.Utilities C:\Users\Abd-PC.julia\packages\MathOptInterface\YDdD3\src\Utilities\copy.jl:419  
[14] copy\_constraints(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{SDPT3.Optimizer}, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ModelFunctionConstraints{Float64}}}, idxmap::MathOptInterface.Utilities.IndexMap, cis\_src::Vector{MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.EqualTo{Float64}}})  
@ MathOptInterface.Utilities C:\Users\Abd-PC.julia\packages\MathOptInterface\YDdD3\src\Utilities\copy.jl:409  
[15] pass\_nonvariable\_constraints\_fallback(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{SDPT3.Optimizer}, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ModelFunctionConstraints{Float64}}}, idxmap::MathOptInterface.Utilities.IndexMap, constraint\_types::Vector{Tuple{DataType, DataType}}, pass\_cons::typeof(MathOptInterface.Utilities.copy\_constraints); filter\_constraints::Nothing)  
@ MathOptInterface.Utilities C:\Users\Abd-PC.julia\packages\MathOptInterface\YDdD3\src\Utilities\copy.jl:439  
[16] pass\_nonvariable\_constraints(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{SDPT3.Optimizer}, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ModelFunctionConstraints{Float64}}}, idxmap::MathOptInterface.Utilities.IndexMap, constraint\_types::Vector{Tuple{DataType, DataType}}, pass\_cons::Function; filter\_constraints::Nothing)  
@ MathOptInterface.Bridges C:\Users\Abd-PC.julia\packages\MathOptInterface\YDdD3\src\Bridges\bridge\_optimizer.jl:363  
[17] pass\_constraints(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{SDPT3.Optimizer}, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ModelFunctionConstraints{Float64}}}, copy\_names::Bool, idxmap::MathOptInterface.Utilities.IndexMap, single\_variable\_types::Vector{Type{var"#s316"} where var"#s316"\<:MathOptInterface.AbstractScalarSet}, single\_variable\_indices::Vector{Vector{var"#s284"} where var"#s284"\<:(MathOptInterface.ConstraintIndex{MathOptInterface.SingleVariable, S} where S)}, vector\_of\_variables\_types::Vector{Type{var"#s323"} where var"#s323"\<:MathOptInterface.AbstractVectorSet}, vector\_of\_variables\_indices::Vector{Vector{var"#s318"} where var"#s318"\<:(MathOptInterface.ConstraintIndex{MathOptInterface.VectorOfVariables, S} where S)}, pass\_cons::typeof(MathOptInterface.Utilities.copy\_constraints), pass\_attr::typeof(MathOptInterface.set); filter\_constraints::Nothing)  
@ MathOptInterface.Utilities C:\Users\Abd-PC.julia\packages\MathOptInterface\YDdD3\src\Utilities\copy.jl:532  
[18] default\_copy\_to(dest::MathOptInterface.Bridges.LazyBridgeOptimizer{SDPT3.Optimizer}, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ModelFunctionConstraints{Float64}}}, copy\_names::Bool, filter\_constraints::Nothing)  
@ MathOptInterface.Utilities C:\Users\Abd-PC.julia\packages\MathOptInterface\YDdD3\src\Utilities\copy.jl:714  
[19] #automatic\_copy\_to#127  
@ C:\Users\Abd-PC.julia\packages\MathOptInterface\YDdD3\src\Utilities\copy.jl:24 [inlined]  
[20] #copy\_to#4  
@ C:\Users\Abd-PC.julia\packages\MathOptInterface\YDdD3\src\Bridges\bridge\_optimizer.jl:401 [inlined]  
[21] attach\_optimizer(model::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ModelFunctionConstraints{Float64}}}})  
@ MathOptInterface.Utilities C:\Users\Abd-PC.julia\packages\MathOptInterface\YDdD3\src\Utilities\cachingoptimizer.jl:185  
[22] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ModelFunctionConstraints{Float64}}}})  
@ MathOptInterface.Utilities C:\Users\Abd-PC.julia\packages\MathOptInterface\YDdD3\src\Utilities\cachingoptimizer.jl:248  
[23] optimize!(model::JuMP.Model, optimizer\_factory::Nothing; bridge\_constraints::Bool, ignore\_optimize\_hook::Bool, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})  
@ JuMP C:\Users\Abd-PC.julia\packages\JuMP\klrjG\src\optimizer\_interface.jl:185  
[24] optimize! (repeats 2 times)  
@ C:\Users\Abd-PC.julia\packages\JuMP\klrjG\src\optimizer\_interface.jl:157 [inlined]  
[25] macro expansion  
@ .\timing.jl:368 [inlined]  
[26] optimize\_model!(aim::SDPWRMPowerModel; relax\_integrality::Bool, optimizer::Type, solution\_processors::Vector{Any})  
@ InfrastructureModels C:\Users\Abd-PC.julia\packages\InfrastructureModels\k2fNE\src\core\base.jl:397  
[27] run\_model(data::Dict{String, Any}, model\_type::Type, optimizer::Type, build\_method::typeof(build\_opf); ref\_extensions::Vector{Any}, solution\_processors::Vector{Any}, relax\_integrality::Bool, multinetwork::Bool, multiconductor::Bool, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})  
@ PowerModels C:\Users\Abd-PC.julia\packages\PowerModels\vPrY3\src\core\base.jl:52  
[28] run\_model(data::Dict{String, Any}, model\_type::Type, optimizer::Type, build\_method::Function)  
@ PowerModels C:\Users\Abd-PC.julia\packages\PowerModels\vPrY3\src\core\base.jl:35  
[29] run\_model(file::String, model\_type::Type, optimizer::Type, build\_method::Function; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})  
@ PowerModels C:\Users\Abd-PC.julia\packages\PowerModels\vPrY3\src\core\base.jl:27  
[30] run\_model  
@ C:\Users\Abd-PC.julia\packages\PowerModels\vPrY3\src\core\base.jl:26 [inlined]  
[31] #run\_opf#1082  
@ C:\Users\Abd-PC.julia\packages\PowerModels\vPrY3\src\prob\opf.jl:13 [inlined]  
[32] run\_opf(file::String, model\_type::Type, optimizer::Type)  
@ PowerModels C:\Users\Abd-PC.julia\packages\PowerModels\vPrY3\src\prob\opf.jl:13  
[33] top-level scope  
@ none:1

I would appreciate your help in this regard

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [September 13, 2021, 6:05am UTC](https://discourse.julialang.org/t/using-the-solver-sdpt3-with-powermodels-jl/68070/2 "2021-09-13T06:05:04Z")

</div>

Please open an issue with a reproducible example: [https://github.com/jump-dev/SDPT3.jl/issues](https://github.com/jump-dev/SDPT3.jl/issues)

I’d regard SDPT3.jl support as still experimental. It hasn’t seen much development.

---

<div class="post-metadata">

**Author:** ![blegat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blegat/32/217090_2.png) [@blegat](https://discourse.julialang.org/u/blegat)\
**Post date:** [September 14, 2021, 9:33am UTC](https://discourse.julialang.org/t/using-the-solver-sdpt3-with-powermodels-jl/68070/3 "2021-09-14T09:33:27Z")

</div>

It does not seem to be an issue with SDPT3. It seems PowerModels is providing a function with a non-zero constant. Maybe open an issue in PowerModels ? See [Constraints · MathOptInterface](https://jump.dev/MathOptInterface.jl/stable/manual/constraints/#Linear-constraints)

> By convention, solvers are not expected to support nonzero constant terms in the [`ScalarAffineFunction`](https://jump.dev/MathOptInterface.jl/stable/reference/standard_form/#MathOptInterface.ScalarAffineFunction)s

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [September 14, 2021, 9:52am UTC](https://discourse.julialang.org/t/using-the-solver-sdpt3-with-powermodels-jl/68070/4 "2021-09-14T09:52:55Z")

</div>

I don’t think PowerModels calls MOI directly? So this seems like a problem elsewhere.

---

<div class="post-metadata">

**Author:** ![ccoffrin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ccoffrin/32/400_2.png) [@ccoffrin](https://discourse.julialang.org/u/ccoffrin)\
**Post date:** [September 14, 2021, 2:52pm UTC](https://discourse.julialang.org/t/using-the-solver-sdpt3-with-powermodels-jl/68070/5 "2021-09-14T14:52:46Z")

</div>

I can confirm that PowerModels does not call MOI directly. PowerModels SDP formulations are tested with SCS, with no known issues that the moment. So I would suspect the issue is in the solver interface.

This issue with using [Mosek with PowerModels](https://github.com/jump-dev/MosekTools.jl/issues/71) has also been noted. Maybe these two points are related?

If there is a possibility that the problem is with the JuMP model formulation side let me know and I can help with that aspect.
