Skip to content

Commit e963f17

Browse files
Update documentation
1 parent f4d8644 commit e963f17

15 files changed

+111
-10
lines changed

R/Grid_Matrix.R

+4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
#' @param controls_reward_calculation If method_old_gain=F, vector of controls evaluated
5353
#' @param max_hydro_hourly Hourly maximum pumping and turbining powers
5454
#' @param max_hydro_weekly Weekly maximum pumping and turbining powers
55+
#' @param force_final_level Binary. Whether final level should be constrained
56+
#' @param final_level_egal_initial Binary. Whether final level, if constrained, should be equal to initial level
57+
#' @param final_level Final level (in percent between 0 and 100) if final level is constrained but different from initial level
58+
#' @param penalty_final_level Penalties (for both bottom and top rule curves) to constrain final level
5559
#'
5660
#' @return List of a data.frame with aggregated water values and
5761
#' a data.frame of more detailed water values

R/Plot_functions.R

+2
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ plot_reward_variation_mc <- function(reward_base,week_id,Mc_year)
182182
#' @param penalty_low Penalty for the lower rule curve
183183
#' @param penalty_high Penalty for the higher rule curve
184184
#' @param week_number Numeric of length 1. number of the week to plot.
185+
#' @param force_final_level Binary. Whether final level should be constrained
186+
#' @param penalty_final_level Penalties (for both bottom and top rule curves) to constrain final level
185187
#'
186188
#' @return a \code{ggplot} object
187189
#' @export

R/functions.R

+2
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ getSimulationNames <- function(pattern, studyPath = NULL, opts = antaresRead::si
227227
#' @param penalty_level_low Penalty for violating the bottom rule curve, comparable to the unsupplied energy cost
228228
#' @param penalty_level_high Penalty for violating the top rule curve, comparable to the spilled energy cost
229229
#' @param constant Boolean. Generate daily constant values by week. FALSE to do interpolation.
230+
#' @param force_final_level Boolean. Whether final level should be constrained
231+
#' @param penalty_final_level Penalties (for both bottom and top rule curves) to constrain final level
230232
#'
231233
#' @return A 365*101 numeric matrix
232234
#' @export

R/math_functions.R

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#' @param reservoir Data frame describing rule curves, generated by \code{readReservoirLevels}
88
#' @param penalty_level_high Penalty for violating the bottom rule curve
99
#' @param penalty_level_low Penalty for violating the top rule curve
10+
#' @param force_final_level Binary. Whether final level should be constrained
11+
#' @param penalty_final_level Penalties (for both bottom and top rule curves) to constrain final level
1012
#'
1113
#' @return Data frame with water value (vu) for each week (weeks) and each state (states).
1214
#' vu_pen corresponds to water value without penalties

R/post_process.R

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#' @param max maximal accepted water value
1010
#' @param penalty_level_high Penalty for violating top rule curve
1111
#' @param penalty_level_low Penalty for violating bottom rule curve
12+
#' @param force_final_level Binary. Whether final level should be constrained
13+
#' @param penalty_final_level Penalties (for both bottom and top rule curves) to constrain final level
1214
#'
1315
#' @return a \code{data.table}
1416
#' @export

R/readReservoirLevels.R

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
#' @param opts
77
#' List of simulation parameters returned by the function
88
#' \code{antaresRead::setSimulationPath}
9+
#' @param force_final_level Binary. Whether final level should be constrained
10+
#' @param final_level_egal_initial Binary. Whether final level, if constrained, should be equal to initial level
11+
#' @param final_level Final level (in percent between 0 and 100) if final level is constrained but different from initial level
912
#'
1013
#' @return a data.table
1114
#' @export

R/shiny_calculate.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ calculateServer <- function(id, opts, silent) {
382382
if(is.null(simulation_res())){"Monte Carlo years :"}
383383
else {
384384
paste0("Monte Carlo years : from ",simulation_res()$mc_years[1], " to ",
385-
tail(simulation_res()$mc_years,n=1))}
385+
utils::tail(simulation_res()$mc_years,n=1))}
386386
})
387387

388388
constraints <- shiny::reactive({

README.Rmd

+20-2
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,26 @@ results <- Grid_Matrix(
107107
nb_disc_stock = 20,
108108
pumping = pumping,
109109
pumping_efficiency = pump_eff,
110-
opts=opts)# used for marginal prices interpolation
110+
opts=opts),# used for marginal prices interpolation
111+
force_final_level = F # T if you want to constrain final level with penalties (see Grid_Matrix documentation for more information)
111112
)
112113
aggregated_results <- results$aggregated_results
113114
```
114115

116+
Water values are written to Antares thanks to the following instructions
117+
118+
```{r eval=FALSE}
119+
reshaped_values <- aggregated_results[aggregated_results$weeks!=53,] %>%
120+
to_Antares_Format(penalty_level_low=3,
121+
penalty_level_high=0,
122+
force_final_level=F,
123+
penalty_final_level=0)
124+
antaresEditObject::writeWaterValues(
125+
area = area,
126+
data = reshaped_values
127+
)
128+
```
129+
115130
You can plot the results
116131

117132
```{r, include=FALSE}
@@ -127,7 +142,10 @@ waterValuesViz(Data=aggregated_results,filter_penalties = F)
127142
plot_Bellman(value_nodes_dt = aggregated_results,
128143
week_number = c(1,3),
129144
penalty_high = 0,
130-
penalty_low = 3)
145+
penalty_low = 3,
146+
force_final_level = F, #T if final level is constrained
147+
penalty_final_level = 0 # used if final level is constrained
148+
)
131149
```
132150

133151
You can also plot reward functions

README.md

+20-2
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,26 @@ results <- Grid_Matrix(
100100
nb_disc_stock = 20,
101101
pumping = pumping,
102102
pumping_efficiency = pump_eff,
103-
opts=opts)# used for marginal prices interpolation
103+
opts=opts),# used for marginal prices interpolation
104+
force_final_level = F # T if you want to constrain final level with penalties (see Grid_Matrix documentation for more information)
104105
)
105106
aggregated_results <- results$aggregated_results
106107
```
107108

109+
Water values are written to Antares thanks to the following instructions
110+
111+
``` r
112+
reshaped_values <- aggregated_results[aggregated_results$weeks!=53,] %>%
113+
to_Antares_Format(penalty_level_low=3,
114+
penalty_level_high=0,
115+
force_final_level=F,
116+
penalty_final_level=0)
117+
antaresEditObject::writeWaterValues(
118+
area = area,
119+
data = reshaped_values
120+
)
121+
```
122+
108123
You can plot the results
109124

110125
``` r
@@ -117,7 +132,10 @@ waterValuesViz(Data=aggregated_results,filter_penalties = F)
117132
plot_Bellman(value_nodes_dt = aggregated_results,
118133
week_number = c(1,3),
119134
penalty_high = 0,
120-
penalty_low = 3)
135+
penalty_low = 3,
136+
force_final_level = F, #T if final level is constrained
137+
penalty_final_level = 0 # used if final level is constrained
138+
)
121139
```
122140

123141
<img src="man/figures/README-bellman-1.png" width="100%" />

man/Grid_Matrix.Rd

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/build_data_watervalues.Rd

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/plot_Bellman.Rd

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/readReservoirLevels.Rd

+10-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/remove_out.Rd

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/to_Antares_Format.Rd

+12-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)