diff --git a/NEWS.md b/NEWS.md index fd0c285a..53c85c24 100644 --- a/NEWS.md +++ b/NEWS.md @@ -13,6 +13,7 @@ NEW FEATURES : BUGFIXES : * Fix `filter_synthesis` and `filter_year_by_year` parameters of `editLink()` in API mode +* Fix `createDSR()` in API mode : daily binding constraint takes 366 rows # antaresEditObject 0.6.1 diff --git a/R/createDSR.R b/R/createDSR.R index 53940034..ad4b0e2a 100644 --- a/R/createDSR.R +++ b/R/createDSR.R @@ -262,10 +262,10 @@ createDSR <- function(areasAndDSRParam = NULL, #coef binding coefficientsDSR <- .getCoefDsr(areaName, nameDsr) - + # A binding constraint at a daily timestep expects 366 rows createBindingConstraint( nameBindDSR, - values = matrix(data = c(rep(installedCapacityLink * as.double(numberHour), 365), rep(0, 365 * 2)), ncol = 3), + values = matrix(data = c(rep(installedCapacityLink * as.double(numberHour), 366), rep(0, 366 * 2)), ncol = 3), enabled = TRUE, timeStep = "daily", operator = c("less"), @@ -440,9 +440,10 @@ editDSR <- function(area = NULL, #coef binding coefficientsDSR <- .getCoefDsr(area, previousNameDsr) + # A binding constraint at a daily timestep expects 366 rows createBindingConstraint( previousNameDsr, - values = matrix(data = c(rep(newCapacityLink * as.double(previousNumberHour), 365), rep(0, 365 * 2)), ncol = 3), + values = matrix(data = c(rep(newCapacityLink * as.double(previousNumberHour), 366), rep(0, 366 * 2)), ncol = 3), enabled = TRUE, timeStep = "daily", operator = c("less"), diff --git a/tests/testthat/test-createDSR.R b/tests/testthat/test-createDSR.R index 5b1d7aec..5eb4a1c8 100644 --- a/tests/testthat/test-createDSR.R +++ b/tests/testthat/test-createDSR.R @@ -35,7 +35,9 @@ sapply(studies, function(study) { expect_equal(bindingList$a_dsr_3h$operator, "less") expect_equal(as.double(bindingList$a_dsr_3h$coefs["a%a_dsr_3h"]), -1) expect_equal(as.double(bindingList$b_dsr_7h$coefs["b%b_dsr_7h"]), -1) - + expect_equal(nrow(bindingList$a_dsr_3h$values), 366) + expect_equal(nrow(bindingList$b_dsr_7h$values), 366) + expect_equal(unique(bindingList$a_dsr_3h$values$less)[1], dsrData[dsrData$area=="a",]$unit*dsrData[dsrData$area=="a",]$nominalCapacity*dsrData[dsrData$area=="a",]$hour) expect_equal(unique(bindingList$b_dsr_7h$values$less)[1], dsrData[dsrData$area=="b",]$unit*dsrData[dsrData$area=="b",]$nominalCapacity*dsrData[dsrData$area=="b",]$hour) @@ -136,4 +138,3 @@ sapply(studies, function(study) { unlink(x = file.path(pathstd, "test_case"), recursive = TRUE) }) -