Skip to content

Commit

Permalink
put control in .st_mandatory_param. enhance NEWS.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekmek7 committed May 29, 2024
1 parent 33d99e4 commit 14722dd
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 43 deletions.
21 changes: 11 additions & 10 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ BUGFIXES :

NEW FEATURES :

* Complete function `deleteStudy()` with new parameter `simulation` to delete a simulation in an Antares study.
* Complete function `deleteStudy()` with new parameter **simulation** to delete a simulation in an Antares study.
* New parameter `geographic.trimming` in `updateGeneralSettings()`to activate or deactivate this general parameter.
* Add `importZipStudyWeb()` to allow the user to import a local study in Antares Web

Expand All @@ -22,8 +22,8 @@ NEW FEATURES :
* `setPlaylist()` optimized for the API mode
- returned an updated list of simulation parameters returned by the function `setSimulationPath()` and `setSimulationPathAPI()`
* `.createCluster()` uses data.table::fwrite() instead of utils::write.table() for optimization
* `createCluster()` parameter `list_pollutants` default value to NULL.
* `createBindingConstraint()` parameter `coefficients` must be alphabetically ordered.
* `createCluster()` parameter **list_pollutants** default value to NULL.
* `createBindingConstraint()` parameter **coefficients** must be alphabetically ordered.
* `.createCluster()` default matrix in API mode.
* `removeArea()` :
- control the existence of an area in a binding constraint coefficient before deletion
Expand All @@ -32,20 +32,21 @@ NEW FEATURES :
* `removeCluster()` : control the existence of a cluster a in a binding constraint coefficient before deletion
* `createClusterST()` / `editClusterST()` :
- add a control to check if a cluster exists before running actions.
- warning if the value is different of default value when `initialleveloptim` = FALSE and `initiallevel` different of 0.5. Switch to 0.5 in this case.
* `storage_values_default()` : If antaresVersion >= 8.8.0, change `initiallevel` default value to 0.5 and add `enabled` to list of parameters with default value equal to TRUE.
* If antaresVersion >= 8.8.0 :
- warning when **initialleveloptim** == FALSE and **initiallevel** different of 0.5. Switch to 0.5 in this case.
-`storage_values_default()` : Change **initiallevel** default value to 0.5 and add **enabled** to list of parameters with default value equal to TRUE.
* `.removeCluster()` : add a control to check if a cluster exists before running actions in st-storage mode.
* Update documentation for scenarioBuilder : user must enable/disable `custom-scenario` property in `generaldata.ini` by himself
* Update documentation for scenarioBuilder : user must enable/disable **custom-scenario** property in `generaldata.ini` by himself


BUGFIXES :

* Fix `filter_synthesis` and `filter_year_by_year` parameters of `editLink()` in API mode
* Fix `filter_synthesis` and **filter_year_by_year** parameters of `editLink()` in API mode
* Fix `setPlaylist()` works in API and local mode with weights.
* Fix `getPlaylist()` works in API and local mode with weights.
* Fix `createDSR()` in API mode : daily binding constraint takes 366 rows.
* Fix `createCluster()` and `editCluster()` parameter `list_pollutants` stop if Antares Version < 8.6.0
* `getJobs()` no longer returns duplicates and displays the two new columns `owner_id` and `owner_name`.
* Fix `createCluster()` and `editCluster()` parameter **list_pollutants** stop if Antares Version < 8.6.0
* `getJobs()` no longer returns duplicates and displays the two new columns **owner_id** and **owner_name**.
* Allow the user to set symbol or full name as argument series in `updateScenarioBuilder()`
* `scenarioBuilder()` matrix has the same row repeated if the area is not rand
* Fix `createLink()` to update opts in API mode.
Expand Down Expand Up @@ -75,7 +76,7 @@ BUGFIXES :
* `createArea()` integrate "st-storage".
* `removeArea()` integrate "st-storage".
* `writeInputTS()` integrate "mingen" data and dependency between "mod.txt" and "mingen.txt" data.
* `createCluster()` / `editCluster()` have new parameter `list_pollutants` for list of pollutants.
* `createCluster()` / `editCluster()` have new parameter **list_pollutants** for list of pollutants.


NEW FEATURES (Antares v8.6) :
Expand Down
40 changes: 19 additions & 21 deletions R/createClusterST.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,8 @@ createClusterST <- function(area,
paste0(names_parameters, collapse= ", ")))

# check values parameters
.st_mandatory_params(list_values = storage_parameters)

# Check 880 rule for storage_parameters
if (opts$antaresVersion >= 880){
if ("initiallevel" %in% names(storage_parameters) & "initialleveloptim" %in% names(storage_parameters)){
if (storage_parameters$initiallevel != 0.5 & !storage_parameters$initialleveloptim) {
warning("`initiallevel` value will be replaced by 0.5 because `initialleveloptim` = FALSE.")
storage_parameters$initiallevel <- 0.5
}
}
}
.st_mandatory_params(list_values = storage_parameters,
opts = opts)


# DATA parameters : default value + name txt file
Expand Down Expand Up @@ -300,34 +291,41 @@ createClusterST <- function(area,

# check parameters (`list`)
#' @return `list`
.st_mandatory_params <- function(list_values){
.st_mandatory_params <- function(list_values,
opts = antaresRead::simOptions()){
.is_ratio(list_values$efficiency,
"efficiency")

.check_capacity(list_values$reservoircapacity,
"reservoircapacity")
# if(!list_values$reservoircapacity >= 0)
# stop("reservoircapacity must be >= 0",
# call. = FALSE)

.is_ratio(list_values$initiallevel,
"initiallevel")

.check_capacity(list_values$withdrawalnominalcapacity,
"withdrawalnominalcapacity")
# if(!list_values$withdrawalnominalcapacity >= 0)
# stop("withdrawalnominalcapacity must be >= 0",
# call. = FALSE)

.check_capacity(list_values$injectionnominalcapacity,
"injectionnominalcapacity")
# if(!list_values$injectionnominalcapacity >= 0)
# stop("injectionnominalcapacity must be >= 0",
# call. = FALSE)

if(!is.null(list_values$initialleveloptim))
assertthat::assert_that(inherits(list_values$initialleveloptim,
"logical"))

# Check 880 rule for storage_parameters
if (opts$antaresVersion >= 880){

if(!is.null(list_values$enabled))
assertthat::assert_that(inherits(list_values$enabled,
"logical"))

if ("initiallevel" %in% names(storage_parameters) & "initialleveloptim" %in% names(storage_parameters)){
if (storage_parameters$initiallevel != 0.5 & !storage_parameters$initialleveloptim) {
warning("`initiallevel` value will be replaced by 0.5 because `initialleveloptim` = FALSE.")
storage_parameters$initiallevel <- 0.5
}
}
}
}

.is_ratio <- function(x, mess){
Expand Down
13 changes: 2 additions & 11 deletions R/editClusterST.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,8 @@ editClusterST <- function(area,
paste0(names_parameters, collapse= ", ")))

# check values parameters
.st_mandatory_params(list_values = storage_parameters)

# Check 880 rule for storage_parameters
if (opts$antaresVersion >= 880){
if ("initiallevel" %in% names(storage_parameters) & "initialleveloptim" %in% names(storage_parameters)){
if (storage_parameters$initiallevel != 0.5 & !storage_parameters$initialleveloptim) {
warning("`initiallevel` value will be replaced by 0.5 because `initialleveloptim` = FALSE.")
storage_parameters$initiallevel <- 0.5
}
}
}
.st_mandatory_params(list_values = storage_parameters,
opts = opts)

# check list of parameters
params_cluster <- hyphenize_names(storage_parameters)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-createClusterST.R
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ test_that("Test the behaviour of createClusterST() if the ST cluster already exi
test_that("Test warning when storage_parameters incorrect", {

ant_version <- "8.8.0"
st_test <- paste0("my_study_860_", paste0(sample(letters,5),collapse = ""))
st_test <- "my_study_880"
suppressWarnings(opts <- createStudy(path = pathstd, study_name = st_test, antares_version = ant_version))
area <- "zone51"
createArea(area)
Expand Down

0 comments on commit 14722dd

Please sign in to comment.