Using the solver SDPT3 with PowerModels.jl

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

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

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

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

By convention, solvers are not expected to support nonzero constant terms in the ScalarAffineFunction s

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

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 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.

1 Like