# SDP relaxation in PowerModelsAneex

**URL:** <https://discourse.julialang.org/t/sdp-relaxation-in-powermodelsaneex/41898>\
**Category:** Optimization (Mathematical)\
**Created:** [June 22, 2020, 11:26pm UTC](https://discourse.julialang.org/t/sdp-relaxation-in-powermodelsaneex/41898 "2020-06-22T23:26:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rasoul](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Post date:** [June 22, 2020, 11:26pm UTC](https://discourse.julialang.org/t/sdp-relaxation-in-powermodelsaneex/41898/1 "2020-06-22T23:26:50Z")

</div>

Hi All,

I am wondering if there is an SDP relaxation of the OPF problem in PowerModelsAnnex? If there is no such function, I would appreciate any guide for implementing that in the PowerModelsAnnex.

I have noticed there are tow different SDP relaxations in PowerModels, including SDP and SparseSDP relaxations; can you please let me know how scalable are those relaxations?

All the best,  
Rasoul

---

<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:** [June 23, 2020, 1:46am UTC](https://discourse.julialang.org/t/sdp-relaxation-in-powermodelsaneex/41898/2 "2020-06-23T01:46:25Z")

</div>

Hi Rasoul,

I have not yet ported the SDP relaxation to PowerModelsAnnex. However, the SOC relaxation there uses a similar variable space, so an extension of that model would be a good place to start.

The basic `SDP` model is the easiest to implement. It is very similar to most of the papers you would find about that model. The sparse version omits some entires in the `W` matrix and is hence more complex. But is also about 10 times more scalable.

In my experience, 100 buses is around the limit for the basic `SDP` model and about 1000 buses for the sparse version. In both cases you will want to use the MOSEK SDP solver. The open-source solvers are lagging far behind in terms of reliability compared to MOSEK.

FWIW, I generally do not use the SDP model in my work due to solver reliability challenges. Making SDP OPF formulation reliable in practice seems to be an open research topic.

I hope that helps!

---

<div class="post-metadata">

**Author:** ![Rasoul](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Post date:** [June 23, 2020, 4:01pm UTC](https://discourse.julialang.org/t/sdp-relaxation-in-powermodelsaneex/41898/3 "2020-06-23T16:01:08Z")

</div>

Hi Dr. Coffrin,

Thank you so much for the response! I will look at the SOC relaxation in the PowerModelAnnex. It sure helps!

All the best,  
Rasoul

---

<div class="post-metadata">

**Author:** ![Rasoul](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Post date:** [July 17, 2020, 1:10am UTC](https://discourse.julialang.org/t/sdp-relaxation-in-powermodelsaneex/41898/4 "2020-07-17T01:10:58Z")

</div>

Hi Dr. Coffrin,

I am implementing the SDP relaxation of the OPF problemin PowerModelsAnnex. I have added the LinearAlgebra package but when I run my code I get the following warning and error:

```julia

┌ Warning: Package PowerModelsAnnex does not have LinearAlgebra in its dependencies:

│ - If you have PowerModelsAnnex checked out for development and have

│ added LinearAlgebra as a dependency but haven't updated your primary

│ environment's manifest file, try `Pkg.resolve()`.

│ - Otherwise you may need to report an issue with PowerModelsAnnex

└ Loading LinearAlgebra into PowerModelsAnnex from project dependency, future warnings for PowerModelsAnnex are suppressed.

[Info: Precompiling Ipopt [b6b21f68-93f8-5de0-b562-5493be1d77c9]

[Info: Precompiling MAT [23992714-dd62-5051-b70f-ba57cb901cac]

[info | PowerModels]: removing 3 cost terms from generator 3: Float64[]

[warn | PowerModels]: Updated generator 3 cost function with order 0 to a function of order 3: [0.0, 0.0, 0.0]

ERROR: LoadError: UndefVarError: I not defined

```

I should note that when I added the LinearAlgebra package it was not added as a unique folder to the packages instead multiple folder have been added. Can you please guide me how I can add LinearAlgebra package to the PowerModelsAnnex dependencies? Thanks in advance!

All the best,

Rasoul

---

<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:** [July 17, 2020, 2:53pm UTC](https://discourse.julialang.org/t/sdp-relaxation-in-powermodelsaneex/41898/5 "2020-07-17T14:53:59Z")

</div>

Hi Rasoul,

The warning,

```julia
Warning: Package PowerModelsAnnex does not have LinearAlgebra in its dependencies:

```

Relates to how Julia package development works. I would recomend looking for a tutorial about that.

The error,

```julia
ERROR: LoadError: UndefVarError: I not defined

```

Is most likely an undefined value in you code.

---

<div class="post-metadata">

**Author:** ![Rasoul](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Post date:** [July 17, 2020, 4:13pm UTC](https://discourse.julialang.org/t/sdp-relaxation-in-powermodelsaneex/41898/6 "2020-07-17T16:13:51Z")

</div>

Hi Dr Coffrin,

Thanks for the response. I is the eye matrix, defined in LinearAlgebra package, that you have directly used in your SDP code in PowerModels. You have used LinearAlgebra package in your code. But When I added that package to PowerModelsAnnex I got the above error. My problem is how I can use the LinearAlgebra library in the power model annex. I will definitely look at the Julia package development documents.

All the best,  
Rasoul

---

<div class="post-metadata">

**Author:** ![Rasoul](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Post date:** [July 23, 2020, 11:37pm UTC](https://discourse.julialang.org/t/sdp-relaxation-in-powermodelsaneex/41898/7 "2020-07-23T23:37:11Z")

</div>

Hi Dr. Coffrin,

I went through the Julia package development documents and could fix the error that I got (i.e, I successfully add the LinearAlgebra as a dependency to the PowerModelsAnnex).

I have written a code to solve the OPF problem via SDP relaxation as function, i.e, sdp.opf, which exports the build\_sdp\_opf. However, when I want to run my code via build\_sdp\_opf(case,model) I get the following error.

```julia
build_sdp_opf not defined

```

I have already run a similar addendum file to PowerModelsAnnex in julia 0.6 without getting any error. But recently I upgraded my julia to 1.3. I will appreciate it if you let me know about possible actions that I should take to run my code in julia 1.3. Thanks in advance!

All the best,  
Rasoul
