Skip to content

Commit

Permalink
Fix optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulScheerRLI committed Jun 13, 2024
1 parent a15c07b commit d98e367
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion simba/station_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ def run_optimization(conf, sched=None, scen=None, args=None):
# remove none values from socs in the vehicle_socs so timeseries_calc can work
optimizer.replace_socs_from_none_to_value()

vehicle_socs = optimizer.timeseries_calc()
# Restore the rotations and the scenario which where the goal of optimization.
optimizer.schedule.rotations = rotations_for_opt
optimizer.scenario = optimizer.base_scenario

# Check if the rotations which were part of the optimization are not negative anymore
vehicle_socs = optimizer.timeseries_calc(optimizer.electrified_station_set)

new_events = optimizer.get_low_soc_events(soc_data=vehicle_socs)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_station_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def test_fast_calculations_and_events(self):
sopt.create_charging_curves()
# remove none values from socs in the vehicle_socs
sopt.replace_socs_from_none_to_value()
vehicle_socs_fast = sopt.timeseries_calc(ele_station_set=["Station-1"])
vehicle_socs_fast = sopt.timeseries_calc(set(sched.stations.keys()))
for vehicle, socs in scen.vehicle_socs.items():
assert vehicle_socs_fast[vehicle][-1] == pytest.approx(socs[-1], 0.01, abs=0.01)
events = sopt.get_low_soc_events(soc_data=vehicle_socs_fast, rel_soc=True)
Expand Down

0 comments on commit d98e367

Please sign in to comment.