Skip to content

Commit

Permalink
Correct efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
Juliette-Gerbaux committed May 2, 2024
1 parent 487dfac commit 661a68b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
14 changes: 11 additions & 3 deletions src/calculate_reward_and_bellman_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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:
Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion src/functions_iterative.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
9 changes: 6 additions & 3 deletions src/simple_bellman_value_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
)
Expand All @@ -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,
)
Expand Down Expand Up @@ -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,
)
Expand Down

0 comments on commit 661a68b

Please sign in to comment.