From 661a68b3ae28c973395e7d0892a37528149ccc2d Mon Sep 17 00:00:00 2001 From: Juliette-Gerbaux Date: Thu, 2 May 2024 17:12:55 +0200 Subject: [PATCH] Correct efficiency --- src/calculate_reward_and_bellman_values.py | 14 +++++++++++--- src/functions_iterative.py | 3 ++- src/simple_bellman_value_calculation.py | 9 ++++++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/calculate_reward_and_bellman_values.py b/src/calculate_reward_and_bellman_values.py index 897d68b..2a82ad3 100644 --- a/src/calculate_reward_and_bellman_values.py +++ b/src/calculate_reward_and_bellman_values.py @@ -288,7 +288,7 @@ def solve_weekly_problem_with_approximation( for i_fut in range(len(X)): u = -X[i_fut] + level_i + stock.inflow[week, scenario] - if -stock.max_pumping[week] <= u: + if -stock.max_pumping[week] * stock.efficiency <= u: if ( self.reservoir_management.overflow or u <= stock.max_generating[week] @@ -312,7 +312,11 @@ def solve_weekly_problem_with_approximation( control = points[u] Umin = level_i + stock.inflow[week, scenario] - stock.bottom_rule_curve[week] - if -stock.max_pumping[week] <= Umin <= stock.max_generating[week]: + if ( + -stock.max_pumping[week] * stock.efficiency + <= Umin + <= stock.max_generating[week] + ): state_fut = level_i - Umin + stock.inflow[week, scenario] penalty = pen(state_fut) if (reward_fn(Umin) + V_fut(state_fut) + penalty) > Vu: @@ -321,7 +325,11 @@ def solve_weekly_problem_with_approximation( control = Umin Umax = level_i + stock.inflow[week, scenario] - stock.upper_rule_curve[week] - if -stock.max_pumping[week] <= Umax <= stock.max_generating[week]: + if ( + -stock.max_pumping[week] * stock.efficiency + <= Umax + <= stock.max_generating[week] + ): state_fut = level_i - Umax + stock.inflow[week, scenario] penalty = pen(state_fut) if (reward_fn(Umax) + V_fut(state_fut) + penalty) > Vu: diff --git a/src/functions_iterative.py b/src/functions_iterative.py index 4b7a4da..66396ad 100644 --- a/src/functions_iterative.py +++ b/src/functions_iterative.py @@ -356,7 +356,8 @@ def init_iterative_calculation( for week in range(len_week): for scenario in range(len_scenario): r = RewardApproximation( - lb_control=-reservoir_management.reservoir.max_pumping[week], + lb_control=-reservoir_management.reservoir.max_pumping[week] + * reservoir_management.reservoir.efficiency, ub_control=reservoir_management.reservoir.max_generating[week], ub_reward=0, ) diff --git a/src/simple_bellman_value_calculation.py b/src/simple_bellman_value_calculation.py index 67f8bd0..81968d2 100644 --- a/src/simple_bellman_value_calculation.py +++ b/src/simple_bellman_value_calculation.py @@ -22,7 +22,8 @@ def calculate_complete_reward( for week in range(param.len_week): for scenario in range(param.len_scenario): r = RewardApproximation( - lb_control=-reservoir_management.reservoir.max_pumping[week], + lb_control=-reservoir_management.reservoir.max_pumping[week] + * reservoir_management.reservoir.efficiency, ub_control=reservoir_management.reservoir.max_generating[week], ub_reward=float("inf"), ) @@ -31,7 +32,8 @@ def calculate_complete_reward( controls = np.array( [ np.linspace( - -reservoir_management.reservoir.max_pumping[week], + -reservoir_management.reservoir.max_pumping[week] + * reservoir_management.reservoir.efficiency, reservoir_management.reservoir.max_generating[week], num=len_controls, ) @@ -203,7 +205,8 @@ def calculate_bellman_value_directly( for week in range(param.len_week): for scenario in range(param.len_scenario): r = RewardApproximation( - lb_control=-reservoir_management.reservoir.max_pumping[week], + lb_control=-reservoir_management.reservoir.max_pumping[week] + * reservoir_management.reservoir.efficiency, ub_control=reservoir_management.reservoir.max_generating[week], ub_reward=0, )