From 98de0fa4f86b4151a40a51df4c3369540875231f Mon Sep 17 00:00:00 2001 From: Simon Bowly Date: Thu, 24 Oct 2024 19:44:02 +1100 Subject: [PATCH] Add some tests for ACLocal mode --- tests/opf/test_solver.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/opf/test_solver.py b/tests/opf/test_solver.py index a6ec3f37..d8cf97a2 100644 --- a/tests/opf/test_solver.py +++ b/tests/opf/test_solver.py @@ -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 @@ -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):