Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] [docs] Complex number AC Optimal Power Flow tutorial #3382

Closed
wants to merge 12 commits into from

Conversation

jd-foster
Copy link
Collaborator

@jd-foster jd-foster commented May 24, 2023

Still plenty to add and fix here, but the first pass at #3363 .

It currently is a nonlinear AC-OPF formulation, but the idea is to add to it the original intent, SDP relaxation of AC-OPF using HermitianPSDCone. Not sure whether it should be under conic or nonlinear...

@codecov
Copy link

codecov bot commented May 24, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (4a304dd) 98.06% compared to head (30e7d2d) 98.07%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3382   +/-   ##
=======================================
  Coverage   98.06%   98.07%           
=======================================
  Files          34       34           
  Lines        4922     4928    +6     
=======================================
+ Hits         4827     4833    +6     
  Misses         95       95           

see 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

# following question: what is the most cost-effective operation of electricity
# generators while meeting constraints on the safe limits of network components?

# We will use the 9 _bus_ network test case `case9mod` to explore this problem
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In there, it seems "case9mod" is some standard name but it's only where from. Is it coming from some benchmarking suite ?

# Even before solving, we can substitute the lower bound on each generator's real power range
# (all 10, as it turns out in this case)

objval_basic_lb = value(lower_bound, objective_function(model));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unclear why this is a lower bound since you have quadratic terms

@blegat
Copy link
Member

blegat commented May 24, 2023

Not sure whether it should be under conic or nonlinear...

I think your choice of putting it in conic is good.

@jd-foster
Copy link
Collaborator Author

Thanks @blegat for the review. Could you see if the latest commit addresses your comments?

# The techniques of *convex relaxations* can also be used to improve on our
# current best lower bound:

## println("Objective value (better lower bound): $(objval_better_lb)")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the plan to add this section?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Still to do.

@odow
Copy link
Member

odow commented May 25, 2023

I made a few formatting changes. Perhaps this would be better in the application section? https://github.com/jump-dev/JuMP.jl/tree/master/docs/src/tutorials/applications


# The purpose of this tutorial is to highlight JuMP's ability to directly
# formulate problems involving complex-valued decision variables and complex
# matrix cones such as the [`HermitianPSDCone`](@ref) object.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: add an SDP relaxation so this sentence is true.

@jd-foster
Copy link
Collaborator Author

Yes, that seems reasonable since it cuts across a few areas and is fairly technical in places.


Y =
A * SparseArrays.spdiagm(1 ./ z) * A' +
SparseArrays.spdiagm(LinearAlgebra.diag(A * SparseArrays.spdiagm(y_sh) * A'))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@odow I agree with this formatting but the computer says no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I think the formatter must be changing its mind. I didn't change this. Just ran the formatter locally.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a formatting file I'm not seeing by just running

JuliaFormatter.format_file("./docs/src/tutorials/conic/optimal_power_flow.jl", verbose=true)

from the ./JuMP/ dir?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No that should work. Maybe we have different versions of JuliaFormatter. Otherwise break it up a bit so there aren't so many nested calls?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would help readability anyway.

@odow
Copy link
Member

odow commented May 29, 2023

@jd-foster, I've sent you an invite to join JuMP.jl as a maintainer: https://jump.dev/pages/governance/#repository-maintainers.

This will give you write permission to push to the github.com/jump-dev/JuMP.jl remote, which will let you generate previews for the documentation pull requests 😄

@jd-foster
Copy link
Collaborator Author

Thoughts on taking Hypatia as a dependency in the docs environment? It worked well for the hardest SDP example here while SCS seems to struggle, at least on the default settings.

@odow
Copy link
Member

odow commented May 29, 2023

Potentially Clarabel? I used it in #3385 for higher precision.

@odow
Copy link
Member

odow commented May 30, 2023

Closing in favor of #3395

@odow odow closed this May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants