Skip to content

Commit

Permalink
renaming soc edge cuts class
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbynum committed Mar 25, 2021
1 parent b74e545 commit 4b9976b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions egret/models/ac_relaxations.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ def _get_bounds(v):
return lb, ub


@declare_custom_block(name='KocukSOCOverestimator')
class KocukSOCOverestimatorData(BaseRelaxationData):
@declare_custom_block(name='SOCEdgeCuts')
class SOCEdgeCutsData(BaseRelaxationData):
"""
Relaxation for
Expand Down Expand Up @@ -210,7 +210,7 @@ def use_linear_relaxation(self):
@use_linear_relaxation.setter
def use_linear_relaxation(self, val):
if val is not True:
raise ValueError('The KocukSOCOverestimator class can only produce linear relaxations')
raise ValueError('The SOCEdgeCuts class can only produce linear relaxations')
self._use_linear_relaxation = True


Expand All @@ -228,20 +228,20 @@ def create_soc_relaxation(model_data, use_linear_relaxation=True, include_feasib


def create_atan_relaxation(model_data, use_linear_relaxation=True, include_feasibility_slack=False,
use_kocuk_soc_overestimators=False):
use_soc_edge_cuts=False):
model, md = create_atan_acopf_model(model_data=model_data, include_feasibility_slack=include_feasibility_slack)
del model.ineq_soc
del model._con_ineq_soc
if use_kocuk_soc_overestimators:
if use_soc_edge_cuts:
del model.ineq_soc_ub
del model._con_ineq_soc_ub
_relaxation_helper(model=model, md=md, include_soc=True, use_linear_relaxation=use_linear_relaxation)
if use_kocuk_soc_overestimators:
if use_soc_edge_cuts:
branch_attrs = md.attributes(element_type='branch')
bus_pairs = zip_items(branch_attrs['from_bus'], branch_attrs['to_bus'])
unique_bus_pairs = OrderedSet(val for val in bus_pairs.values())
model.ineq_soc_ub_set = pe.Set(initialize=list(unique_bus_pairs))
model.ineq_soc_ub = KocukSOCOverestimator(model.ineq_soc_ub_set)
model.ineq_soc_ub = SOCEdgeCuts(model.ineq_soc_ub_set)
for from_bus, to_bus in model.ineq_soc_ub_set:
model.ineq_soc_ub[from_bus, to_bus].build(c=model.c[from_bus, to_bus],
s=model.s[from_bus, to_bus],
Expand Down
12 changes: 6 additions & 6 deletions egret/models/tests/test_relaxations.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import numpy as np
try:
import coramin
from egret.models.ac_relaxations import KocukSOCOverestimator
from egret.models.ac_relaxations import SOCEdgeCuts
coramin_available = True
except ImportError:
coramin_available = False
Expand Down Expand Up @@ -139,11 +139,11 @@ def test_atan_relaxation(self, case_name):
self.assertTrue(comparison)

@parameterized.expand(case_names)
def test_atan_relaxation_with_kocuk_overestimators(self, case_name):
def test_atan_relaxation_with_soc_edge_cuts(self, case_name):
test_case = os.path.join(current_dir, 'transmission_test_instances', 'pglib-opf-master', '{}.m'.format(case_name))
upper_bound_soln = upper_bounds[case_name]
md = create_ModelData(test_case)
nlp, scaled_md = create_atan_relaxation(md, use_linear_relaxation=True, use_kocuk_soc_overestimators=True)
nlp, scaled_md = create_atan_relaxation(md, use_linear_relaxation=True, use_soc_edge_cuts=True)
for b in coramin.relaxations.relaxation_data_objects(nlp, descend_into=True, active=True, sort=True):
b.rebuild(build_nonlinear_constraint=True)

Expand Down Expand Up @@ -176,14 +176,14 @@ def test_rectangular_relaxation(self, case_name):


@unittest.skipIf(not coramin_available, "coramin is not available")
class TestKocukSOCOverestimator(unittest.TestCase):
def test_kocuk_soc_overestimator(self):
class TestSOCEdgeCuts(unittest.TestCase):
def test_soc_edge_cuts(self):
m = pe.ConcreteModel()
m.c = pe.Var()
m.s = pe.Var()
m.w1 = pe.Var()
m.w2 = pe.Var()
m.rel = KocukSOCOverestimator()
m.rel = SOCEdgeCuts()
m.rel.set_input(c=m.c, s=m.s, vmsq_1=m.w1, vmsq_2=m.w2)

c_bounds = [(0.5, 1.5), (0.8, 1.5), (0.5, 1.2), (0.95, 0.95)]
Expand Down

0 comments on commit 4b9976b

Please sign in to comment.