@@ -32,7 +32,8 @@ library(antaresWaterValues)
32
32
Now we are ready to use our package.
33
33
34
34
``` r
35
- shiny_water_values()
35
+ study_path <- " your/path/to/the/antares/study"
36
+ shiny_water_values(antaresRead :: setSimulationPath(study_path ," input" ))
36
37
```
37
38
38
39
![ ] ( inst/images/calculate_water_values.gif )
@@ -58,14 +59,14 @@ simulation_res <- runWaterValuesSimulation(
58
59
area = area ,
59
60
nb_disc_stock = 5 , # number of simulations
60
61
nb_mcyears = mcyears ,
61
- path_solver = " your/path/to/antares/bin/antares-8.1 -solver.exe" ,
62
+ path_solver = " your/path/to/antares/bin/antares-8.6 -solver.exe" ,
62
63
fictive_area = paste0(" watervalue_" ,area ),
63
64
thermal_cluster = " watervaluecluster" ,
64
65
overwrite = TRUE ,
65
66
link_from = area ,
66
67
opts = opts ,
67
68
otp_dest = paste0(study_path ," /user" ),
68
- file_name = paste0( j , " _ " , area ) , # name of the saving file
69
+ file_name = " water_values " , # name of the saving file
69
70
pumping = pumping ,
70
71
efficiency = pump_eff ,
71
72
launch_simulations = T ,
@@ -100,20 +101,20 @@ results <- Grid_Matrix(
100
101
nb_disc_stock = 20 ,
101
102
pumping = pumping ,
102
103
pumping_efficiency = pump_eff ,
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)
104
+ opts = opts ,
105
+ mcyears = mcyears ),# used for marginal prices interpolation
106
+ force_final_level = F , # T if you want to constrain final level with penalties (see Grid_Matrix documentation for more information)
107
+ final_level = get_initial_level(area = area ,opts = opts ), # wanted final level (between 0 and 100%)
108
+ penalty_final_level_low = 4 ,
109
+ penalty_final_level_high = 1
105
110
)
106
111
aggregated_results <- results $ aggregated_results
107
112
```
108
113
109
114
Water values are written to Antares thanks to the following instructions
110
115
111
116
``` 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
+ reshaped_values <- to_Antares_Format(aggregated_results )
117
118
antaresEditObject :: writeWaterValues(
118
119
area = area ,
119
120
data = reshaped_values
@@ -130,19 +131,21 @@ waterValuesViz(Data=aggregated_results,filter_penalties = F)
130
131
131
132
``` r
132
133
plot_Bellman(value_nodes_dt = aggregated_results ,
133
- week_number = c(1 ,3 ),
134
- penalty_high = 0 ,
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
- )
134
+ week_number = c(1 ,3 ))
139
135
```
140
136
141
137
<img src =" man/figures/README-bellman-1.png " width =" 100% " />
142
138
143
139
You can also plot reward functions
144
140
145
141
``` r
142
+ controls_reward_calculation <- constraint_generator(area = area ,
143
+ nb_disc_stock = 20 ,
144
+ pumping = pumping ,
145
+ pumping_efficiency = pump_eff ,
146
+ opts = opts ,
147
+ mcyears = mcyears )
148
+ controls_reward_calculation <- dplyr :: arrange(dplyr :: distinct(dplyr :: select(rbind(simulation_res $ simulation_values ,controls_reward_calculation ),- c(" sim" ))),.data $ week ,.data $ u )
146
149
reward <- get_Reward(
147
150
simulation_names = simulation_res $ simulation_names ,
148
151
simulation_values = simulation_res $ simulation_values ,
@@ -153,11 +156,8 @@ reward <- get_Reward(
153
156
method_old = T ,# T if you want a simple linear interpolation of rewards,
154
157
# F if you want to use marginal price to interpolate
155
158
hours = c(seq.int(0 ,168 ,10 ),168 ),# used for marginal prices interpolation
156
- possible_controls = constraint_generator(area = area ,
157
- nb_disc_stock = 20 ,
158
- pumping = pumping ,
159
- pumping_efficiency = pump_eff ,
160
- opts = opts )# used for marginal prices interpolation
159
+ possible_controls = controls_reward_calculation ,# used for marginal prices interpolation
160
+ max_hydro = get_max_hydro(area ,timeStep = " hourly" )
161
161
)
162
162
reward <- reward $ reward
163
163
```
0 commit comments