Skip to content

Commit

Permalink
Add some tests for ACLocal mode
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbowly committed Oct 24, 2024
1 parent 7cc5000 commit 98de0fa
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/opf/test_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ def test_ac_relax(self):
self.assert_approx_equal(solution["gen"][0]["Pg"], 89.803524, tol=1e-1)
self.assert_approx_equal(solution["branch"][1]["Pt"], -34.1774, tol=1e-1)

def test_aclocal(self):
solution = solve_opf(self.case, opftype="aclocal")
self.assertEqual(solution["success"], 1)
self.assert_solution_valid(solution)

# A local solution should get somewhere close to optimal
self.assert_approx_equal(solution["f"], 5296.66532, tol=1e1)

def test_ac_branchswitching_infeasible(self):
# Modify the case to make it infeasible
self.case["bus"][1]["Vmax"] = 0.8
Expand Down Expand Up @@ -363,6 +371,16 @@ def test_ac_relax(self):
solution_original["f"], solution_reordered["f"], tol=1e1
)

def test_aclocal(self):
# Test AC local option, should arrive at a similar result
kwargs = dict(opftype="aclocal")
solution_original = solve_opf(self.case, **kwargs)
solution_reordered = solve_opf(self.case_reordered, **kwargs)

self.assert_approx_equal(
solution_original["f"], solution_reordered["f"], tol=1e1
)


@unittest.skipIf(size_limited_license(), "size-limited-license")
class TestAPILargeModels(unittest.TestCase):
Expand Down

0 comments on commit 98de0fa

Please sign in to comment.