generated from rl-institut/rli_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #196 from rl-institut/feature/cost_calculation_str…
…ategy Feature/cost calculation strategy
- Loading branch information
Showing
6 changed files
with
105 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
from tests.test_schedule import BasicSchedule | ||
from simba.util import uncomment_json_file | ||
from simba.costs import calculate_costs | ||
|
||
|
||
class TestCostCalculation: | ||
def test_cost_calculation(self): | ||
schedule, scenario, args = BasicSchedule().basic_run() | ||
file = args.cost_parameters_path | ||
with open(file, "r") as file: | ||
cost_params = uncomment_json_file(file) | ||
|
||
assert args.strategy_deps == "balanced" | ||
assert args.strategy_opps == "greedy" | ||
|
||
args.cost_calculation_strategy_deps = None | ||
args.cost_calculation_strategy_opps = None | ||
|
||
costs_vanilla = calculate_costs(cost_params, scenario, schedule, args) | ||
|
||
assert args.strategy_deps == "balanced" | ||
assert args.strategy_opps == "greedy" | ||
|
||
args.cost_calculation_strategy_deps = "balanced" | ||
args.cost_calculation_strategy_opps = "greedy" | ||
costs_with_same_strat = calculate_costs(cost_params, scenario, schedule, args) | ||
|
||
# assert all costs are the same | ||
for station in costs_vanilla.costs_per_gc: | ||
for key in costs_vanilla.costs_per_gc[station]: | ||
assert (costs_vanilla.costs_per_gc[station][key] == | ||
costs_with_same_strat.costs_per_gc[station][key]), station | ||
|
||
args.cost_calculation_strategy_opps = "balanced_market" | ||
args.cost_calculation_strategy_deps = "balanced_market" | ||
costs_with_other_strat = calculate_costs(cost_params, scenario, schedule, args) | ||
print(costs_vanilla.costs_per_gc["cumulated"]["c_total_annual"]) | ||
print(costs_with_other_strat.costs_per_gc["cumulated"]["c_total_annual"]) | ||
station = "cumulated" | ||
for key in costs_vanilla.costs_per_gc[station]: | ||
if "el_energy" not in key: | ||
continue | ||
assert (costs_vanilla.costs_per_gc[station][key] != | ||
costs_with_other_strat.costs_per_gc[station][key]), key | ||
|
||
args.cost_calculation_strategy_opps = "peak_load_window" | ||
args.cost_calculation_strategy_deps = "peak_load_window" | ||
costs_with_other_strat = calculate_costs(cost_params, scenario, schedule, args) | ||
station = "cumulated" | ||
for key in costs_vanilla.costs_per_gc[station]: | ||
if "el_energy" not in key: | ||
continue | ||
assert (costs_vanilla.costs_per_gc[station][key] != | ||
costs_with_other_strat.costs_per_gc[station][key]), key | ||
|
||
args.cost_calculation_strategy_opps = "peak_shaving" | ||
args.cost_calculation_strategy_deps = "peak_shaving" | ||
costs_with_other_strat = calculate_costs(cost_params, scenario, schedule, args) | ||
# assert all costs are the same | ||
for station in costs_vanilla.costs_per_gc: | ||
for key in costs_vanilla.costs_per_gc[station]: | ||
assert (costs_vanilla.costs_per_gc[station][key] == | ||
costs_with_other_strat.costs_per_gc[station][key]), station |