diff --git a/src/optimizer/optimizer.py b/src/optimizer/optimizer.py index b878ec8e6..9626701e2 100644 --- a/src/optimizer/optimizer.py +++ b/src/optimizer/optimizer.py @@ -54,7 +54,7 @@ class Optimizer: """ def __init__(self, strategy: OptimizationStrategy, grid: GridConfig, batteries: List[BatteryConfig], time_series: TimeSeriesData, - eta_c: float = 0.95, eta_d: float = 0.95, M: float = 1e6, optimizer_settings: OptimizerSettings | None = None): + eta_c: float = 0.89, eta_d: float = 0.95, M: float = 1e6, optimizer_settings: OptimizerSettings | None = None): """ Optimizer Constructor """ @@ -615,8 +615,10 @@ def get_clean_objective_value(self): # charge for import power demand rate. The demand rate is applied to the maximum # power draw beyond the threshold within the time horizon. + p_max_imp_exc = None if self.is_grid_demand_rate_active: - clean_objective += - self.grid.prc_p_exc_imp \ - * pulp.value(self.variables['p_max_imp_exc']) + p_max_imp_exc = pulp.value(self.variables['p_max_imp_exc']) + if p_max_imp_exc is not None: + clean_objective += - self.grid.prc_p_exc_imp * p_max_imp_exc return clean_objective diff --git a/test_cases/000-default-openapi-example.json b/test_cases/000-default-openapi-example.json new file mode 100644 index 000000000..8ce561066 --- /dev/null +++ b/test_cases/000-default-openapi-example.json @@ -0,0 +1,90 @@ +{ + "expected_response": { + "status": "Optimal", + "objective_value": 0, + "limit_violations": { + "grid_import_limit_exceeded": false, + "grid_export_limit_hit": false + }, + "batteries": [ + { + "charging_power": [ + 0 + ], + "discharging_power": [ + 0 + ], + "state_of_charge": [ + 0 + ] + } + ], + "grid_import": [ + 0 + ], + "grid_export": [ + 0 + ], + "flow_direction": [ + 0 + ], + "grid_import_overshoot": [ + 0 + ], + "grid_export_overshoot": [ + 0 + ] + }, + "request": { + "strategy": { + "charging_strategy": "string", + "discharging_strategy": "string" + }, + "grid": { + "p_max_imp": 0, + "p_max_exp": 0, + "prc_p_exc_imp": 0 + }, + "batteries": [ + { + "charge_from_grid": true, + "discharge_to_grid": true, + "s_capacity": 0, + "s_min": 0, + "s_max": 0, + "s_initial": 0, + "p_demand": [ + 0 + ], + "s_goal": [ + 0 + ], + "c_min": 0, + "c_max": 0, + "d_max": 0, + "p_a": 0, + "c_priority": 0 + } + ], + "time_series": { + "dt": [ + 0 + ], + "gt": [ + 0 + ], + "ft": [ + 0 + ], + "p_N": [ + 0 + ], + "p_E": [ + 0 + ] + }, + "eta_c": 0.95, + "eta_d": 0.95 + }, + "test_items": {} +} \ No newline at end of file