From c7a907910d31a1c6a228802db2f095b134e66519 Mon Sep 17 00:00:00 2001 From: Baptiste Date: Thu, 28 Sep 2017 11:40:06 +0200 Subject: [PATCH] Add possibility to enable/disable candidates in candidates.ini --- R/read_candidates.R | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/R/read_candidates.R b/R/read_candidates.R index 7eba7e7..d2062be 100644 --- a/R/read_candidates.R +++ b/R/read_candidates.R @@ -46,6 +46,7 @@ read_candidates <- function(file, opts = antaresRead::simOptions()) candidate <- list() candidate$id <- candidate_id[pr] candidate$name <- NA + candidate$enable <- TRUE candidate$candidate_type <- "investment" candidate$investment_type <- "generation" candidate$link <- NA @@ -78,6 +79,11 @@ read_candidates <- function(file, opts = antaresRead::simOptions()) option_value <- sub(pattern = " ", replacement = "_", option_value) candidate$name <- option_value } + else if (option_name == "enable") + { + assertthat::assert_that(option_value %in% c("true", "false")) + candidate$enable <- as.logical(option_value) + } else if (option_name == "candidate-type") { assertthat::assert_that(option_value %in% c("investment", "decommissioning")) @@ -158,9 +164,12 @@ read_candidates <- function(file, opts = antaresRead::simOptions()) assertthat::assert_that(!is.na(candidate$link)) assertthat::assert_that(candidate$link %in% opts$linkList) - # update candidate list - inv[[i]] <- candidate - i <- i + 1 + # update candidate list if the candidate is enabled + if(candidate$enable) + { + inv[[i]] <- candidate + i <- i + 1 + } } # check that candidates names are unique