Finished baseline policy evaluator

This commit is contained in:
2024-02-26 18:20:53 +01:00
parent be38536758
commit ca120e5715
3 changed files with 158 additions and 22 deletions

View File

@@ -121,9 +121,6 @@ class PolicyEvaluator:
],
)
print("Profits calculated")
print(self.profits.head())
def plot_profits_table(self):
# Check if task or penalties are not set
if (
@@ -157,7 +154,11 @@ class PolicyEvaluator:
)
# Rename columns to match expected output
final_df.columns = ["Penalty", "Total Profit", "Total Charge Cycles"]
final_df.columns = [
"Penalty",
"Total Profit (per year)",
"Total Charge Cycles (per year)",
]
# Profits till 400
profits_till_400 = self.get_profits_till_400()
@@ -167,7 +168,7 @@ class PolicyEvaluator:
# Log the final results table
self.task.get_logger().report_table(
"Policy Results", "Policy Results", iteration=0, table_plot=final_df
"Test Set Results", "Profits per Penalty", iteration=0, table_plot=final_df
)
def plot_thresholds_per_day(self):
@@ -213,16 +214,19 @@ class PolicyEvaluator:
final_df.columns = ["Penalty", "Total Profit", "Total Charge Cycles"]
return final_df
def get_profits_till_400(self):
def get_profits_till_400(self, profits: pd.DataFrame = None):
if profits is None:
profits = self.profits
# calculates profits until 400 charge cycles per year are reached
number_of_days = len(self.profits["Date"].unique())
number_of_days = len(profits["Date"].unique())
usable_charge_cycles = (400 / 365) * number_of_days
# now sum the profit until the usable charge cycles are reached
penalty_profits = {}
penalty_charge_cycles = {}
for index, row in self.profits.iterrows():
for index, row in profits.iterrows():
penalty = row["Penalty"]
profit = row["Profit"]
charge_cycles = row["Charge Cycles"]