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

#123: fixing the rectangular formulation #153

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

hhijazi
Copy link
Member

@hhijazi hhijazi commented Jul 5, 2024

Description

This PR fixes #123 and corrects the rectangular ACOPF formulation as follows:

  • Formulate the problem without auxiliary variables to avoid feasibility violations.
  • Make sure to add voltage magnitude and phase angle bound constraints in the original space (e,f).
  • Make sure to remove buses that are disconnected (status==4).
  • Make sure to use the correct initial point (setting evar to 1).
  • Compute the voltage angles and magnitudes correctly when using the rectangular formulation.

Warning

The pstart initialization does not work with Gurobi 11, only with Gurobi 12. Therefore the performance on ACOPF will be bad until Gurobi 12. For instance, Gurobi 11.0.2 cannot find a feasible solution on network IEEE69.mat (from #123) after 600 seconds.

Copy link
Member

@simonbowly simonbowly left a comment

Choose a reason for hiding this comment

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

I added some comments. Happy to help with the changes, just let me know. The main issue is that the tests do not pass. Have you run them locally?

@@ -153,6 +155,7 @@ def fix_shape(arr, ncols=None):
"gen": gen.to_dict("records"),
"branch": branch.to_dict("records"),
"gencost": gencost,
"casename": os.path.splitext(file_path)[0],
Copy link
Member

Choose a reason for hiding this comment

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

Would be better to use pathlib's stem here. This also needs a test which checks for the case name.

@@ -905,7 +948,7 @@ def lpformulator_ac_create_constraints(alldata, model):
lpformulator_ac_add_polarconstraints(alldata, model)

# nonconvex e, f representation
if alldata["use_ef"]:
if alldata["skipjabr"] is False and alldata["use_ef"]:
Copy link
Member

Choose a reason for hiding this comment

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

Why is False? if not alldata["skipjabr"] is the proper way to do a boolean test in python

@@ -769,6 +766,52 @@ def lpformulator_ac_create_constraints(alldata, model):

logger.info(f" {count} balance constraints added.")

if alldata["skipjabr"] is True and alldata["use_ef"]:
Copy link
Member

Choose a reason for hiding this comment

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

Remove is True here

@@ -369,7 +379,7 @@ def fill_result_fields(alldata, model, opftype, result):

alldata["LP"]["cvar"] = cvar

compute_voltage_angles(alldata, result)
# compute_voltage_angles(alldata, result)
Copy link
Member

Choose a reason for hiding this comment

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

Why is this just commented out?

@@ -195,7 +214,7 @@ def convert_case_to_internal_format(case_dict):
branch["ratio"] = 1.0

alldata = {"LP": {}, "MIP": {}}

alldata["casename"] = case_dict["casename"]
Copy link
Member

Choose a reason for hiding this comment

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

Add a test that "casename" comes through in the result (assuming that's the intention?)

# Remove isolated buses and their connected branches
remove_buses = {bus["bus_i"] for bus in case_dict["bus"] if bus["type"] == 4}
if remove_buses:
logger.info(f"Removing buses {remove_buses} (bustype=4)")
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 result of this that the isolated buses do not appear in the solution at all? We should have a test to make sure they are put back in.

@@ -78,7 +78,7 @@ def solve_opf(
if opftype.lower() == "ac":
opftype = "ac"
useef = True
usejabr = True
usejabr = False
Copy link
Member

Choose a reason for hiding this comment

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

Changing the defaults. Are the tests updated to reflect this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OPF problem
2 participants