From a43161eec6dde5638770b8c6e50331b4787ecfc4 Mon Sep 17 00:00:00 2001 From: Sam Dotson Date: Fri, 7 Mar 2025 15:11:59 -0500 Subject: [PATCH 1/3] fixes bug in n_mga --- osier/utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/osier/utils.py b/osier/utils.py index b7c5dcc..e5d00a9 100644 --- a/osier/utils.py +++ b/osier/utils.py @@ -562,12 +562,18 @@ def n_mga(results_obj, raise ValueError pf = results_obj.F + xpf = results_obj.X try: n_inds, n_objs = pf.shape except ValueError: n_inds = pf.shape[0] n_objs = 1 + try: + n_inds, n_vars = xpf.shape + except ValueError: + n_vars = xpf.shape[0] + pop_size = results_obj.algorithm.pop_size n_gen = results_obj.algorithm.n_gen - 1 @@ -576,7 +582,7 @@ def n_mga(results_obj, sense=sense) X_hist = np.array([hist.pop.get("X") for hist in results_obj.history]).reshape( - n_gen * pop_size, n_objs) + n_gen * pop_size, n_vars) F_hist = np.array([hist.pop.get("F") for hist in results_obj.history]).reshape( n_gen * pop_size, n_objs) try: From 929ca90154cbddbd0e8e1c6b44f8a7879cce3ad2 Mon Sep 17 00:00:00 2001 From: Sam Dotson Date: Sun, 29 Jun 2025 15:39:13 -0500 Subject: [PATCH 2/3] fixes issue causing major slow down for the logical dispatch algorithm --- osier/models/dispatch.py | 4 ++-- osier/models/logic_dispatch.py | 4 ++-- osier/models/model.py | 10 ++++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/osier/models/dispatch.py b/osier/models/dispatch.py index 9cfda74..95f5483 100644 --- a/osier/models/dispatch.py +++ b/osier/models/dispatch.py @@ -148,7 +148,7 @@ class DispatchModel(): penalty : float The penalty applied to the objective function to eliminate simultaneous charging and discharging. Users may need to tune - this parameter. Default is 1e-4. + this parameter. Default is 1e-10. model_initialized : bool Indicates whether :attr:`DispatchModel.model` has been populated with equations yet. This is set to ``True`` after @@ -205,7 +205,7 @@ def __init__(self, oversupply=0.0, undersupply=0.0, verbosity=50, - penalty=1e-4, + penalty=1e-10, power_units=MW, curtailment=True, allow_blackout=False, diff --git a/osier/models/logic_dispatch.py b/osier/models/logic_dispatch.py index 925e4bd..abb9149 100644 --- a/osier/models/logic_dispatch.py +++ b/osier/models/logic_dispatch.py @@ -101,7 +101,7 @@ def _format_results(self): t.charge_history).to_ndarray() data["Curtailment"] = np.array( [v if v <= 0 else 0 for v in self.covered_demand]) - data["Shortfall"] = np.array( + data["LoadLoss"] = np.array( [v if v > 0 else 0 for v in self.covered_demand]) self.results = pd.DataFrame(data) return @@ -134,7 +134,7 @@ def solve(self): if self.verbosity <= 20: print( ('solve failed -- ' - 'too much overproduction ' + 'too much supply ' '(no curtailment allowed)')) raise ValueError diff --git a/osier/models/model.py b/osier/models/model.py index 675fe91..27ded9e 100644 --- a/osier/models/model.py +++ b/osier/models/model.py @@ -41,10 +41,12 @@ def __init__(self, else: self.power_units = power_units - self.technology_list = synchronize_units( - technology_list, - unit_power=self.power_units, - unit_time=self.time_delta.units) + # self.technology_list = synchronize_units( + # technology_list, + # unit_power=self.power_units, + # unit_time=self.time_delta.units) + + self.technology_list = technology_list @property def time_delta(self): From 564e76d544ebe2cfb276e54520733d3ab7fbbf02 Mon Sep 17 00:00:00 2001 From: Sam Dotson Date: Sun, 29 Jun 2025 15:57:10 -0500 Subject: [PATCH 3/3] removes commented code --- osier/models/model.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/osier/models/model.py b/osier/models/model.py index 27ded9e..92d3711 100644 --- a/osier/models/model.py +++ b/osier/models/model.py @@ -41,11 +41,6 @@ def __init__(self, else: self.power_units = power_units - # self.technology_list = synchronize_units( - # technology_list, - # unit_power=self.power_units, - # unit_time=self.time_delta.units) - self.technology_list = technology_list @property